From 579315af32f354294585c651783298d2a99dc90a Mon Sep 17 00:00:00 2001 From: Phoenix He Date: Wed, 29 Apr 2020 16:17:33 +0800 Subject: [PATCH] Generated from bc1d17c9272cd7d40a4eea5db24064e1e92ff3f5 undo links changes --- sdk/resources/azure-mgmt-resource/README.md | 25 +- .../resource/deploymentscripts/__init__.py | 19 +- .../deploymentscripts/_configuration.py | 80 +- .../v2019_10_preview/__init__.py | 19 +- .../v2019_10_preview/_configuration.py | 80 +- .../_deployment_scripts_client.py | 65 +- .../v2019_10_preview/_metadata.json | 53 + .../v2019_10_preview/aio/__init__.py | 10 + .../aio/_configuration_async.py | 65 + .../aio/_deployment_scripts_client_async.py | 59 + .../aio/operations_async/__init__.py | 13 + .../_deployment_scripts_operations_async.py | 587 +++ .../v2019_10_preview/models/__init__.py | 72 +- .../_deployment_scripts_client_enums.py | 37 +- .../v2019_10_preview/models/_models.py | 909 ++-- .../v2019_10_preview/models/_models_py3.py | 1006 +++-- .../v2019_10_preview/models/_paged_models.py | 27 - .../v2019_10_preview/operations/__init__.py | 7 +- .../_deployment_scripts_operations.py | 678 +-- .../v2019_10_preview/py.typed | 1 + .../azure/mgmt/resource/features/__init__.py | 19 +- .../mgmt/resource/features/_configuration.py | 77 +- .../resource/features/v2015_12_01/__init__.py | 19 +- .../features/v2015_12_01/_configuration.py | 77 +- .../features/v2015_12_01/_feature_client.py | 62 +- .../features/v2015_12_01/_metadata.json | 66 + .../features/v2015_12_01/aio/__init__.py | 10 + .../v2015_12_01/aio/_configuration_async.py | 65 + .../v2015_12_01/aio/_feature_client_async.py | 60 + .../aio/operations_async/__init__.py | 15 + .../_feature_client_operations_async.py | 81 + .../_features_operations_async.py | 341 ++ .../features/v2015_12_01/models/__init__.py | 25 +- .../features/v2015_12_01/models/_models.py | 92 +- .../v2015_12_01/models/_models_py3.py | 114 +- .../v2015_12_01/models/_paged_models.py | 40 - .../v2015_12_01/operations/__init__.py | 11 +- .../operations/_feature_client_operations.py | 96 +- .../operations/_features_operations.py | 380 +- .../resource/features/v2015_12_01/py.typed | 1 + .../azure/mgmt/resource/links/__init__.py | 19 +- .../mgmt/resource/links/_configuration.py | 77 +- .../resource/links/v2016_09_01/__init__.py | 19 +- .../links/v2016_09_01/_configuration.py | 77 +- .../v2016_09_01/_management_link_client.py | 64 +- .../resource/links/v2016_09_01/_metadata.json | 54 + .../links/v2016_09_01/aio/__init__.py | 10 + .../v2016_09_01/aio/_configuration_async.py | 65 + .../aio/_management_link_client_async.py | 64 + .../aio/operations_async/__init__.py | 15 + .../aio/operations_async/_operations_async.py | 101 + .../_resource_links_operations_async.py | 357 ++ .../links/v2016_09_01/models/__init__.py | 31 +- .../links/v2016_09_01/models/_models.py | 136 +- .../links/v2016_09_01/models/_models_py3.py | 152 +- .../links/v2016_09_01/models/_paged_models.py | 40 - .../links/v2016_09_01/operations/__init__.py | 7 +- .../v2016_09_01/operations/_operations.py | 106 +- .../operations/_resource_links_operations.py | 417 +- .../mgmt/resource/links/v2016_09_01/py.typed | 1 + .../azure/mgmt/resource/locks/__init__.py | 19 +- .../mgmt/resource/locks/_configuration.py | 77 +- .../resource/locks/v2015_01_01/__init__.py | 19 +- .../locks/v2015_01_01/_configuration.py | 77 +- .../v2015_01_01/_management_lock_client.py | 64 +- .../resource/locks/v2015_01_01/_metadata.json | 53 + .../locks/v2015_01_01/aio/__init__.py | 10 + .../v2015_01_01/aio/_configuration_async.py | 65 + .../aio/_management_lock_client_async.py | 59 + .../aio/operations_async/__init__.py | 13 + .../_management_locks_operations_async.py | 768 ++++ .../locks/v2015_01_01/models/__init__.py | 15 +- .../models/_management_lock_client_enums.py | 10 +- .../locks/v2015_01_01/models/_models.py | 57 +- .../locks/v2015_01_01/models/_models_py3.py | 68 +- .../locks/v2015_01_01/models/_paged_models.py | 27 - .../locks/v2015_01_01/operations/__init__.py | 7 +- .../_management_locks_operations.py | 805 ++-- .../mgmt/resource/locks/v2015_01_01/py.typed | 1 + .../resource/locks/v2016_09_01/__init__.py | 19 +- .../locks/v2016_09_01/_configuration.py | 77 +- .../v2016_09_01/_management_lock_client.py | 72 +- .../resource/locks/v2016_09_01/_metadata.json | 54 + .../locks/v2016_09_01/aio/__init__.py | 10 + .../v2016_09_01/aio/_configuration_async.py | 65 + .../aio/_management_lock_client_async.py | 64 + .../aio/operations_async/__init__.py | 15 + ...thorization_operations_operations_async.py | 101 + .../_management_locks_operations_async.py | 1113 +++++ .../locks/v2016_09_01/models/__init__.py | 26 +- .../models/_management_lock_client_enums.py | 12 +- .../locks/v2016_09_01/models/_models.py | 128 +- .../locks/v2016_09_01/models/_models_py3.py | 151 +- .../locks/v2016_09_01/models/_paged_models.py | 40 - .../locks/v2016_09_01/operations/__init__.py | 11 +- .../operations/_authorization_operations.py | 102 - .../_authorization_operations_operations.py | 106 + .../_management_locks_operations.py | 1270 +++--- .../mgmt/resource/locks/v2016_09_01/py.typed | 1 + .../resource/locks/v2016_09_01/version.py | 13 - .../resource/managedapplications/__init__.py | 19 +- .../_application_client.py | 68 +- .../managedapplications/_configuration.py | 77 +- .../managedapplications/_metadata.json | 54 + .../aio/__init__.py} | 15 +- .../aio/_application_client_async.py | 64 + .../aio/_configuration_async.py | 65 + .../aio/operations_async/__init__.py | 15 + ...pplication_definitions_operations_async.py | 612 +++ .../_applications_operations_async.py | 810 ++++ .../managedapplications/models/__init__.py | 56 +- .../models/_application_client_enums.py | 41 +- .../managedapplications/models/_models.py | 389 +- .../managedapplications/models/_models_py3.py | 455 +- .../models/_paged_models.py | 40 - .../operations/__init__.py | 7 +- .../_application_definitions_operations.py | 712 +-- .../operations/_applications_operations.py | 955 ++-- .../resource/managedapplications/py.typed | 1 + .../resource/managedapplications/version.py | 13 - .../azure/mgmt/resource/policy/__init__.py | 19 +- .../mgmt/resource/policy/_configuration.py | 77 +- .../policy/v2015_10_01_preview/__init__.py | 19 +- .../v2015_10_01_preview/_configuration.py | 77 +- .../policy/v2015_10_01_preview/_metadata.json | 54 + .../v2015_10_01_preview/_policy_client.py | 66 +- .../v2015_10_01_preview/aio/__init__.py} | 11 +- .../aio/_configuration_async.py | 65 + .../aio/_policy_client_async.py | 64 + .../aio/operations_async/__init__.py | 15 + .../_policy_assignments_operations_async.py | 618 +++ .../_policy_definitions_operations_async.py | 271 ++ .../v2015_10_01_preview/models/__init__.py | 22 +- .../v2015_10_01_preview/models/_models.py | 131 +- .../v2015_10_01_preview/models/_models_py3.py | 150 +- .../models/_paged_models.py | 40 - .../models/_policy_client_enums.py | 10 +- .../operations/__init__.py | 7 +- .../_policy_assignments_operations.py | 735 ++- .../_policy_definitions_operations.py | 309 +- .../policy/v2015_10_01_preview/py.typed | 1 + .../policy/v2015_10_01_preview/version.py | 13 - .../resource/policy/v2016_04_01/__init__.py | 19 +- .../policy/v2016_04_01/_configuration.py | 77 +- .../policy/v2016_04_01/_metadata.json | 54 + .../policy/v2016_04_01/_policy_client.py | 66 +- .../v2016_04_01/aio/__init__.py} | 11 +- .../v2016_04_01/aio/_configuration_async.py | 65 + .../v2016_04_01/aio/_policy_client_async.py | 64 + .../aio/operations_async/__init__.py | 15 + .../_policy_assignments_operations_async.py | 618 +++ .../_policy_definitions_operations_async.py | 271 ++ .../policy/v2016_04_01/models/__init__.py | 22 +- .../policy/v2016_04_01/models/_models.py | 131 +- .../policy/v2016_04_01/models/_models_py3.py | 150 +- .../v2016_04_01/models/_paged_models.py | 40 - .../models/_policy_client_enums.py | 10 +- .../policy/v2016_04_01/operations/__init__.py | 7 +- .../_policy_assignments_operations.py | 735 ++- .../_policy_definitions_operations.py | 309 +- .../mgmt/resource/policy/v2016_04_01/py.typed | 1 + .../resource/policy/v2016_04_01/version.py | 13 - .../resource/policy/v2016_12_01/__init__.py | 19 +- .../policy/v2016_12_01/_configuration.py | 77 +- .../policy/v2016_12_01/_metadata.json | 54 + .../policy/v2016_12_01/_policy_client.py | 66 +- .../v2016_12_01/aio/__init__.py} | 11 +- .../v2016_12_01/aio/_configuration_async.py | 65 + .../v2016_12_01/aio/_policy_client_async.py | 64 + .../aio/operations_async/__init__.py | 15 + .../_policy_assignments_operations_async.py | 620 +++ .../_policy_definitions_operations_async.py | 612 +++ .../policy/v2016_12_01/models/__init__.py | 26 +- .../policy/v2016_12_01/models/_models.py | 144 +- .../policy/v2016_12_01/models/_models_py3.py | 166 +- .../v2016_12_01/models/_paged_models.py | 40 - .../models/_policy_client_enums.py | 23 +- .../policy/v2016_12_01/operations/__init__.py | 7 +- .../_policy_assignments_operations.py | 733 ++- .../_policy_definitions_operations.py | 726 ++- .../mgmt/resource/policy/v2016_12_01/py.typed | 1 + .../resource/policy/v2016_12_01/version.py | 13 - .../policy/v2017_06_01_preview/__init__.py | 19 +- .../v2017_06_01_preview/_configuration.py | 76 +- .../policy/v2017_06_01_preview/_metadata.json | 55 + .../v2017_06_01_preview/_policy_client.py | 69 +- .../v2017_06_01_preview/aio/__init__.py} | 11 +- .../aio/_configuration_async.py | 64 + .../aio/_policy_client_async.py | 69 + .../aio/operations_async/__init__.py | 17 + .../_policy_assignments_operations_async.py | 629 +++ .../_policy_definitions_operations_async.py | 612 +++ ...policy_set_definitions_operations_async.py | 632 +++ .../v2017_06_01_preview/models/__init__.py | 43 +- .../v2017_06_01_preview/models/_models.py | 275 +- .../v2017_06_01_preview/models/_models_py3.py | 316 +- .../models/_paged_models.py | 53 - .../models/_policy_client_enums.py | 23 +- .../operations/__init__.py | 7 +- .../_policy_assignments_operations.py | 732 ++- .../_policy_definitions_operations.py | 726 ++- .../_policy_set_definitions_operations.py | 727 ++- .../policy/v2017_06_01_preview/py.typed | 1 + .../policy/v2017_06_01_preview/version.py | 13 - .../resource/policy/v2018_03_01/__init__.py | 19 +- .../policy/v2018_03_01/_configuration.py | 77 +- .../policy/v2018_03_01/_metadata.json | 55 + .../policy/v2018_03_01/_policy_client.py | 70 +- .../policy/v2018_03_01/aio/__init__.py | 10 + .../v2018_03_01/aio/_configuration_async.py | 65 + .../v2018_03_01/aio/_policy_client_async.py | 69 + .../aio/operations_async/__init__.py | 17 + .../_policy_assignments_operations_async.py | 657 +++ .../_policy_definitions_operations_async.py | 632 +++ ...policy_set_definitions_operations_async.py | 652 +++ .../policy/v2018_03_01/models/__init__.py | 43 +- .../policy/v2018_03_01/models/_models.py | 288 +- .../policy/v2018_03_01/models/_models_py3.py | 329 +- .../v2018_03_01/models/_paged_models.py | 53 - .../models/_policy_client_enums.py | 23 +- .../policy/v2018_03_01/operations/__init__.py | 7 +- .../_policy_assignments_operations.py | 904 ++-- .../_policy_definitions_operations.py | 784 ++-- .../_policy_set_definitions_operations.py | 786 ++-- .../mgmt/resource/policy/v2018_03_01/py.typed | 1 + .../resource/policy/v2018_03_01/version.py | 13 - .../resource/policy/v2018_05_01/__init__.py | 19 +- .../policy/v2018_05_01/_configuration.py | 77 +- .../policy/v2018_05_01/_metadata.json | 55 + .../policy/v2018_05_01/_policy_client.py | 70 +- .../policy/v2018_05_01/aio/__init__.py | 10 + .../v2018_05_01/aio/_configuration_async.py | 65 + .../v2018_05_01/aio/_policy_client_async.py | 69 + .../aio/operations_async/__init__.py | 17 + .../_policy_assignments_operations_async.py | 657 +++ .../_policy_definitions_operations_async.py | 632 +++ ...policy_set_definitions_operations_async.py | 652 +++ .../policy/v2018_05_01/models/__init__.py | 49 +- .../policy/v2018_05_01/models/_models.py | 325 +- .../policy/v2018_05_01/models/_models_py3.py | 370 +- .../v2018_05_01/models/_paged_models.py | 53 - .../models/_policy_client_enums.py | 30 +- .../policy/v2018_05_01/operations/__init__.py | 7 +- .../_policy_assignments_operations.py | 904 ++-- .../_policy_definitions_operations.py | 784 ++-- .../_policy_set_definitions_operations.py | 786 ++-- .../mgmt/resource/policy/v2018_05_01/py.typed | 1 + .../resource/policy/v2018_05_01/version.py | 13 - .../resource/policy/v2019_01_01/__init__.py | 19 +- .../policy/v2019_01_01/_configuration.py | 77 +- .../policy/v2019_01_01/_metadata.json | 55 + .../policy/v2019_01_01/_policy_client.py | 70 +- .../policy/v2019_01_01/aio/__init__.py | 10 + .../v2019_01_01/aio/_configuration_async.py | 65 + .../v2019_01_01/aio/_policy_client_async.py | 69 + .../aio/operations_async/__init__.py | 17 + .../_policy_assignments_operations_async.py | 657 +++ .../_policy_definitions_operations_async.py | 632 +++ ...policy_set_definitions_operations_async.py | 652 +++ .../policy/v2019_01_01/models/__init__.py | 45 +- .../policy/v2019_01_01/models/_models.py | 315 +- .../policy/v2019_01_01/models/_models_py3.py | 360 +- .../v2019_01_01/models/_paged_models.py | 53 - .../models/_policy_client_enums.py | 23 +- .../policy/v2019_01_01/operations/__init__.py | 7 +- .../_policy_assignments_operations.py | 904 ++-- .../_policy_definitions_operations.py | 784 ++-- .../_policy_set_definitions_operations.py | 786 ++-- .../mgmt/resource/policy/v2019_01_01/py.typed | 1 + .../resource/policy/v2019_01_01/version.py | 13 - .../resource/policy/v2019_06_01/__init__.py | 19 +- .../policy/v2019_06_01/_configuration.py | 77 +- .../policy/v2019_06_01/_metadata.json | 55 + .../policy/v2019_06_01/_policy_client.py | 70 +- .../policy/v2019_06_01/aio/__init__.py | 10 + .../v2019_06_01/aio/_configuration_async.py | 65 + .../v2019_06_01/aio/_policy_client_async.py | 69 + .../aio/operations_async/__init__.py | 17 + .../_policy_assignments_operations_async.py | 657 +++ .../_policy_definitions_operations_async.py | 632 +++ ...policy_set_definitions_operations_async.py | 652 +++ .../policy/v2019_06_01/models/__init__.py | 45 +- .../policy/v2019_06_01/models/_models.py | 323 +- .../policy/v2019_06_01/models/_models_py3.py | 369 +- .../v2019_06_01/models/_paged_models.py | 53 - .../models/_policy_client_enums.py | 26 +- .../policy/v2019_06_01/operations/__init__.py | 7 +- .../_policy_assignments_operations.py | 904 ++-- .../_policy_definitions_operations.py | 784 ++-- .../_policy_set_definitions_operations.py | 786 ++-- .../mgmt/resource/policy/v2019_06_01/py.typed | 1 + .../resource/policy/v2019_06_01/version.py | 13 - .../resource/policy/v2019_09_01/__init__.py | 19 +- .../policy/v2019_09_01/_configuration.py | 77 +- .../policy/v2019_09_01/_metadata.json | 55 + .../policy/v2019_09_01/_policy_client.py | 70 +- .../policy/v2019_09_01/aio/__init__.py | 10 + .../v2019_09_01/aio/_configuration_async.py | 65 + .../v2019_09_01/aio/_policy_client_async.py | 69 + .../aio/operations_async/__init__.py | 17 + .../_policy_assignments_operations_async.py | 722 +++ .../_policy_definitions_operations_async.py | 632 +++ ...policy_set_definitions_operations_async.py | 642 +++ .../policy/v2019_09_01/models/__init__.py | 55 +- .../policy/v2019_09_01/models/_models.py | 431 +- .../policy/v2019_09_01/models/_models_py3.py | 489 +- .../v2019_09_01/models/_paged_models.py | 53 - .../models/_policy_client_enums.py | 42 +- .../policy/v2019_09_01/operations/__init__.py | 7 +- .../_policy_assignments_operations.py | 1002 ++--- .../_policy_definitions_operations.py | 784 ++-- .../_policy_set_definitions_operations.py | 787 ++-- .../mgmt/resource/policy/v2019_09_01/py.typed | 1 + .../resource/policy/v2019_09_01/version.py | 13 - .../azure/mgmt/resource/resources/__init__.py | 19 +- .../mgmt/resource/resources/_configuration.py | 77 +- .../resources/v2016_02_01/__init__.py | 19 +- .../resources/v2016_02_01/_configuration.py | 77 +- .../resources/v2016_02_01/_metadata.json | 58 + .../_resource_management_client.py | 90 +- .../resources/v2016_02_01/aio/__init__.py | 10 + .../v2016_02_01/aio/_configuration_async.py | 65 + .../aio/_resource_management_client_async.py | 84 + .../aio/operations_async/__init__.py | 23 + ..._deployment_operations_operations_async.py | 178 + .../_deployments_operations_async.py | 661 +++ .../_providers_operations_async.py | 278 ++ .../_resource_groups_operations_async.py | 582 +++ .../_resources_operations_async.py | 624 +++ .../_tags_operations_async.py | 323 ++ .../resources/v2016_02_01/models/__init__.py | 124 +- .../resources/v2016_02_01/models/_models.py | 730 +-- .../v2016_02_01/models/_models_py3.py | 904 ++-- .../v2016_02_01/models/_paged_models.py | 92 - .../_resource_management_client_enums.py | 15 +- .../v2016_02_01/operations/__init__.py | 11 +- .../operations/_deployment_operations.py | 183 - .../_deployment_operations_operations.py | 184 + .../operations/_deployments_operations.py | 751 ++-- .../operations/_providers_operations.py | 308 +- .../operations/_resource_groups_operations.py | 696 ++- .../operations/_resources_operations.py | 656 +-- .../operations/_tags_operations.py | 338 +- .../resource/resources/v2016_02_01/py.typed | 1 + .../resource/resources/v2016_02_01/version.py | 13 - .../resources/v2016_09_01/__init__.py | 19 +- .../resources/v2016_09_01/_configuration.py | 77 +- .../resources/v2016_09_01/_metadata.json | 58 + .../_resource_management_client.py | 88 +- .../resources/v2016_09_01/aio/__init__.py | 10 + .../v2016_09_01/aio/_configuration_async.py | 65 + .../aio/_resource_management_client_async.py | 84 + .../aio/operations_async/__init__.py | 23 + ..._deployment_operations_operations_async.py | 178 + .../_deployments_operations_async.py | 670 +++ .../_providers_operations_async.py | 279 ++ .../_resource_groups_operations_async.py | 585 +++ .../_resources_operations_async.py | 1100 +++++ .../_tags_operations_async.py | 327 ++ .../resources/v2016_09_01/models/__init__.py | 124 +- .../resources/v2016_09_01/models/_models.py | 812 ++-- .../v2016_09_01/models/_models_py3.py | 960 ++-- .../v2016_09_01/models/_paged_models.py | 92 - .../_resource_management_client_enums.py | 19 +- .../v2016_09_01/operations/__init__.py | 11 +- .../operations/_deployment_operations.py | 184 - .../_deployment_operations_operations.py | 184 + .../operations/_deployments_operations.py | 805 ++-- .../operations/_providers_operations.py | 311 +- .../operations/_resource_groups_operations.py | 702 ++- .../operations/_resources_operations.py | 1263 +++--- .../operations/_tags_operations.py | 354 +- .../resource/resources/v2016_09_01/py.typed | 1 + .../resource/resources/v2016_09_01/version.py | 13 - .../resources/v2017_05_10/__init__.py | 19 +- .../resources/v2017_05_10/_configuration.py | 77 +- .../resources/v2017_05_10/_metadata.json | 58 + .../_resource_management_client.py | 88 +- .../resources/v2017_05_10/aio/__init__.py | 10 + .../v2017_05_10/aio/_configuration_async.py | 65 + .../aio/_resource_management_client_async.py | 84 + .../aio/operations_async/__init__.py | 23 + ..._deployment_operations_operations_async.py | 178 + .../_deployments_operations_async.py | 670 +++ .../_providers_operations_async.py | 279 ++ .../_resource_groups_operations_async.py | 501 +++ .../_resources_operations_async.py | 1284 ++++++ .../_tags_operations_async.py | 327 ++ .../resources/v2017_05_10/models/__init__.py | 126 +- .../resources/v2017_05_10/models/_models.py | 829 ++-- .../v2017_05_10/models/_models_py3.py | 983 ++-- .../v2017_05_10/models/_paged_models.py | 92 - .../_resource_management_client_enums.py | 19 +- .../v2017_05_10/operations/__init__.py | 11 +- .../operations/_deployment_operations.py | 184 - .../_deployment_operations_operations.py | 184 + .../operations/_deployments_operations.py | 805 ++-- .../operations/_providers_operations.py | 311 +- .../operations/_resource_groups_operations.py | 611 ++- .../operations/_resources_operations.py | 1487 ++++--- .../operations/_tags_operations.py | 354 +- .../resource/resources/v2017_05_10/py.typed | 1 + .../resource/resources/v2017_05_10/version.py | 13 - .../resources/v2018_02_01/__init__.py | 19 +- .../resources/v2018_02_01/_configuration.py | 77 +- .../resources/v2018_02_01/_metadata.json | 58 + .../_resource_management_client.py | 88 +- .../resources/v2018_02_01/aio/__init__.py | 10 + .../v2018_02_01/aio/_configuration_async.py | 65 + .../aio/_resource_management_client_async.py | 84 + .../aio/operations_async/__init__.py | 23 + ..._deployment_operations_operations_async.py | 178 + .../_deployments_operations_async.py | 670 +++ .../_providers_operations_async.py | 279 ++ .../_resource_groups_operations_async.py | 501 +++ .../_resources_operations_async.py | 1282 ++++++ .../_tags_operations_async.py | 327 ++ .../resources/v2018_02_01/models/__init__.py | 128 +- .../resources/v2018_02_01/models/_models.py | 870 ++-- .../v2018_02_01/models/_models_py3.py | 1034 +++-- .../v2018_02_01/models/_paged_models.py | 92 - .../_resource_management_client_enums.py | 21 +- .../v2018_02_01/operations/__init__.py | 11 +- .../operations/_deployment_operations.py | 184 - .../_deployment_operations_operations.py | 184 + .../operations/_deployments_operations.py | 805 ++-- .../operations/_providers_operations.py | 311 +- .../operations/_resource_groups_operations.py | 611 ++- .../operations/_resources_operations.py | 1480 ++++--- .../operations/_tags_operations.py | 354 +- .../resource/resources/v2018_02_01/py.typed | 1 + .../resource/resources/v2018_02_01/version.py | 13 - .../resources/v2018_05_01/__init__.py | 19 +- .../resources/v2018_05_01/_configuration.py | 77 +- .../resources/v2018_05_01/_metadata.json | 59 + .../_resource_management_client.py | 90 +- .../resources/v2018_05_01/aio/__init__.py | 10 + .../v2018_05_01/aio/_configuration_async.py | 65 + .../aio/_resource_management_client_async.py | 89 + .../aio/operations_async/__init__.py | 25 + ..._deployment_operations_operations_async.py | 306 ++ .../_deployments_operations_async.py | 1218 +++++ .../aio/operations_async/_operations_async.py | 101 + .../_providers_operations_async.py | 279 ++ .../_resource_groups_operations_async.py | 505 +++ .../_resources_operations_async.py | 1308 ++++++ .../_tags_operations_async.py | 327 ++ .../resources/v2018_05_01/models/__init__.py | 143 +- .../resources/v2018_05_01/models/_models.py | 966 ++-- .../v2018_05_01/models/_models_py3.py | 1144 +++-- .../v2018_05_01/models/_paged_models.py | 105 - .../_resource_management_client_enums.py | 21 +- .../v2018_05_01/operations/__init__.py | 11 +- .../operations/_deployment_operations.py | 320 -- .../_deployment_operations_operations.py | 314 ++ .../operations/_deployments_operations.py | 1457 +++--- .../v2018_05_01/operations/_operations.py | 106 +- .../operations/_providers_operations.py | 311 +- .../operations/_resource_groups_operations.py | 621 ++- .../operations/_resources_operations.py | 1549 +++---- .../operations/_tags_operations.py | 354 +- .../resource/resources/v2018_05_01/py.typed | 1 + .../resource/resources/v2018_05_01/version.py | 13 - .../resources/v2019_05_01/__init__.py | 19 +- .../resources/v2019_05_01/_configuration.py | 77 +- .../resources/v2019_05_01/_metadata.json | 59 + .../_resource_management_client.py | 90 +- .../resources/v2019_05_01/aio/__init__.py | 10 + .../v2019_05_01/aio/_configuration_async.py | 65 + .../aio/_resource_management_client_async.py | 89 + .../aio/operations_async/__init__.py | 25 + ..._deployment_operations_operations_async.py | 440 ++ .../_deployments_operations_async.py | 1786 ++++++++ .../aio/operations_async/_operations_async.py | 101 + .../_providers_operations_async.py | 279 ++ .../_resource_groups_operations_async.py | 505 +++ .../_resources_operations_async.py | 1308 ++++++ .../_tags_operations_async.py | 327 ++ .../resources/v2019_05_01/models/__init__.py | 143 +- .../resources/v2019_05_01/models/_models.py | 968 ++-- .../v2019_05_01/models/_models_py3.py | 1147 +++-- .../v2019_05_01/models/_paged_models.py | 105 - .../_resource_management_client_enums.py | 21 +- .../v2019_05_01/operations/__init__.py | 11 +- .../operations/_deployment_operations.py | 457 -- .../_deployment_operations_operations.py | 450 ++ .../operations/_deployments_operations.py | 2107 +++++---- .../v2019_05_01/operations/_operations.py | 106 +- .../operations/_providers_operations.py | 311 +- .../operations/_resource_groups_operations.py | 621 ++- .../operations/_resources_operations.py | 1549 +++---- .../operations/_tags_operations.py | 354 +- .../resource/resources/v2019_05_01/py.typed | 1 + .../resource/resources/v2019_05_01/version.py | 13 - .../resources/v2019_05_10/__init__.py | 19 +- .../resources/v2019_05_10/_configuration.py | 77 +- .../resources/v2019_05_10/_metadata.json | 59 + .../_resource_management_client.py | 90 +- .../resources/v2019_05_10/aio/__init__.py | 10 + .../v2019_05_10/aio/_configuration_async.py | 65 + .../aio/_resource_management_client_async.py | 89 + .../aio/operations_async/__init__.py | 25 + ..._deployment_operations_operations_async.py | 440 ++ .../_deployments_operations_async.py | 1786 ++++++++ .../aio/operations_async/_operations_async.py | 101 + .../_providers_operations_async.py | 407 ++ .../_resource_groups_operations_async.py | 505 +++ .../_resources_operations_async.py | 1308 ++++++ .../_tags_operations_async.py | 327 ++ .../resources/v2019_05_10/models/__init__.py | 143 +- .../resources/v2019_05_10/models/_models.py | 968 ++-- .../v2019_05_10/models/_models_py3.py | 1147 +++-- .../v2019_05_10/models/_paged_models.py | 105 - .../_resource_management_client_enums.py | 21 +- .../v2019_05_10/operations/__init__.py | 11 +- .../operations/_deployment_operations.py | 457 -- .../_deployment_operations_operations.py | 450 ++ .../operations/_deployments_operations.py | 2107 +++++---- .../v2019_05_10/operations/_operations.py | 106 +- .../operations/_providers_operations.py | 462 +- .../operations/_resource_groups_operations.py | 621 ++- .../operations/_resources_operations.py | 1549 +++---- .../operations/_tags_operations.py | 354 +- .../resource/resources/v2019_05_10/py.typed | 1 + .../resource/resources/v2019_05_10/version.py | 13 - .../resources/v2019_07_01/__init__.py | 19 +- .../resources/v2019_07_01/_configuration.py | 77 +- .../resources/v2019_07_01/_metadata.json | 59 + .../_resource_management_client.py | 90 +- .../resources/v2019_07_01/aio/__init__.py | 10 + .../v2019_07_01/aio/_configuration_async.py | 65 + .../aio/_resource_management_client_async.py | 89 + .../aio/operations_async/__init__.py | 25 + ..._deployment_operations_operations_async.py | 700 +++ .../_deployments_operations_async.py | 3112 +++++++++++++ .../aio/operations_async/_operations_async.py | 101 + .../_providers_operations_async.py | 407 ++ .../_resource_groups_operations_async.py | 505 +++ .../_resources_operations_async.py | 1308 ++++++ .../_tags_operations_async.py | 327 ++ .../resources/v2019_07_01/models/__init__.py | 165 +- .../resources/v2019_07_01/models/_models.py | 1131 +++-- .../v2019_07_01/models/_models_py3.py | 1330 ++++-- .../v2019_07_01/models/_paged_models.py | 105 - .../_resource_management_client_enums.py | 62 +- .../v2019_07_01/operations/__init__.py | 11 +- .../operations/_deployment_operations.py | 729 --- .../_deployment_operations_operations.py | 714 +++ .../operations/_deployments_operations.py | 3693 ++++++++-------- .../v2019_07_01/operations/_operations.py | 106 +- .../operations/_providers_operations.py | 462 +- .../operations/_resource_groups_operations.py | 621 ++- .../operations/_resources_operations.py | 1549 +++---- .../operations/_tags_operations.py | 354 +- .../resource/resources/v2019_07_01/py.typed | 1 + .../resource/resources/v2019_07_01/version.py | 13 - .../resources/v2019_08_01/__init__.py | 19 +- .../resources/v2019_08_01/_configuration.py | 77 +- .../resources/v2019_08_01/_metadata.json | 59 + .../_resource_management_client.py | 90 +- .../resources/v2019_08_01/aio/__init__.py | 10 + .../v2019_08_01/aio/_configuration_async.py | 65 + .../aio/_resource_management_client_async.py | 89 + .../aio/operations_async/__init__.py | 25 + ..._deployment_operations_operations_async.py | 700 +++ .../_deployments_operations_async.py | 3112 +++++++++++++ .../aio/operations_async/_operations_async.py | 101 + .../_providers_operations_async.py | 407 ++ .../_resource_groups_operations_async.py | 545 +++ .../_resources_operations_async.py | 1310 ++++++ .../_tags_operations_async.py | 327 ++ .../resources/v2019_08_01/models/__init__.py | 167 +- .../resources/v2019_08_01/models/_models.py | 1145 +++-- .../v2019_08_01/models/_models_py3.py | 1343 ++++-- .../v2019_08_01/models/_paged_models.py | 105 - .../_resource_management_client_enums.py | 62 +- .../v2019_08_01/operations/__init__.py | 11 +- .../operations/_deployment_operations.py | 729 --- .../_deployment_operations_operations.py | 714 +++ .../operations/_deployments_operations.py | 3693 ++++++++-------- .../v2019_08_01/operations/_operations.py | 106 +- .../operations/_providers_operations.py | 462 +- .../operations/_resource_groups_operations.py | 667 ++- .../operations/_resources_operations.py | 1553 +++---- .../operations/_tags_operations.py | 354 +- .../resource/resources/v2019_08_01/py.typed | 1 + .../resource/resources/v2019_08_01/version.py | 13 - .../resources/v2019_10_01/__init__.py | 19 +- .../resources/v2019_10_01/_configuration.py | 77 +- .../resources/v2019_10_01/_metadata.json | 59 + .../_resource_management_client.py | 90 +- .../resources/v2019_10_01/aio/__init__.py | 10 + .../v2019_10_01/aio/_configuration_async.py | 65 + .../aio/_resource_management_client_async.py | 89 + .../aio/operations_async/__init__.py | 25 + ..._deployment_operations_operations_async.py | 700 +++ .../_deployments_operations_async.py | 3238 ++++++++++++++ .../aio/operations_async/_operations_async.py | 101 + .../_providers_operations_async.py | 407 ++ .../_resource_groups_operations_async.py | 545 +++ .../_resources_operations_async.py | 1342 ++++++ .../_tags_operations_async.py | 566 +++ .../resources/v2019_10_01/models/__init__.py | 201 +- .../resources/v2019_10_01/models/_models.py | 1324 +++--- .../v2019_10_01/models/_models_py3.py | 1530 ++++--- .../v2019_10_01/models/_paged_models.py | 105 - .../_resource_management_client_enums.py | 107 +- .../v2019_10_01/operations/__init__.py | 11 +- .../operations/_deployment_operations.py | 729 --- .../_deployment_operations_operations.py | 714 +++ .../operations/_deployments_operations.py | 3935 +++++++++-------- .../v2019_10_01/operations/_operations.py | 106 +- .../operations/_providers_operations.py | 462 +- .../operations/_resource_groups_operations.py | 667 ++- .../operations/_resources_operations.py | 1533 +++---- .../operations/_tags_operations.py | 670 ++- .../resource/resources/v2019_10_01/py.typed | 1 + .../resource/resources/v2019_10_01/version.py | 13 - .../mgmt/resource/subscriptions/__init__.py | 19 +- .../resource/subscriptions/_configuration.py | 78 +- .../subscriptions/v2016_06_01/__init__.py | 19 +- .../v2016_06_01/_configuration.py | 78 +- .../subscriptions/v2016_06_01/_metadata.json | 43 + .../v2016_06_01/_subscription_client.py | 67 +- .../subscriptions/v2016_06_01/aio/__init__.py | 10 + .../v2016_06_01/aio/_configuration_async.py | 59 + .../aio/_subscription_client_async.py | 66 + .../aio/operations_async/__init__.py | 17 + .../aio/operations_async/_operations_async.py | 101 + .../_subscriptions_operations_async.py | 220 + .../_tenants_operations_async.py | 101 + .../v2016_06_01/models/__init__.py | 44 +- .../v2016_06_01/models/_models.py | 213 +- .../v2016_06_01/models/_models_py3.py | 235 +- .../v2016_06_01/models/_paged_models.py | 66 - .../models/_subscription_client_enums.py | 23 +- .../v2016_06_01/operations/__init__.py | 7 +- .../v2016_06_01/operations/_operations.py | 106 +- .../operations/_subscriptions_operations.py | 247 +- .../operations/_tenants_operations.py | 106 +- .../subscriptions/v2016_06_01/py.typed | 1 + .../subscriptions/v2016_06_01/version.py | 13 - .../subscriptions/v2018_06_01/__init__.py | 19 +- .../v2018_06_01/_configuration.py | 78 +- .../subscriptions/v2018_06_01/_metadata.json | 43 + .../v2018_06_01/_subscription_client.py | 67 +- .../subscriptions/v2018_06_01/aio/__init__.py | 10 + .../v2018_06_01/aio/_configuration_async.py | 59 + .../aio/_subscription_client_async.py | 66 + .../aio/operations_async/__init__.py | 17 + .../aio/operations_async/_operations_async.py | 101 + .../_subscriptions_operations_async.py | 220 + .../_tenants_operations_async.py | 101 + .../v2018_06_01/models/__init__.py | 44 +- .../v2018_06_01/models/_models.py | 213 +- .../v2018_06_01/models/_models_py3.py | 235 +- .../v2018_06_01/models/_paged_models.py | 66 - .../models/_subscription_client_enums.py | 23 +- .../v2018_06_01/operations/__init__.py | 7 +- .../v2018_06_01/operations/_operations.py | 106 +- .../operations/_subscriptions_operations.py | 247 +- .../operations/_tenants_operations.py | 106 +- .../subscriptions/v2018_06_01/py.typed | 1 + .../subscriptions/v2018_06_01/version.py | 13 - .../subscriptions/v2019_06_01/__init__.py | 19 +- .../v2019_06_01/_configuration.py | 78 +- .../subscriptions/v2019_06_01/_metadata.json | 43 + .../v2019_06_01/_subscription_client.py | 67 +- .../subscriptions/v2019_06_01/aio/__init__.py | 10 + .../v2019_06_01/aio/_configuration_async.py | 59 + .../aio/_subscription_client_async.py | 66 + .../aio/operations_async/__init__.py | 17 + .../aio/operations_async/_operations_async.py | 101 + .../_subscriptions_operations_async.py | 220 + .../_tenants_operations_async.py | 101 + .../v2019_06_01/models/__init__.py | 46 +- .../v2019_06_01/models/_models.py | 232 +- .../v2019_06_01/models/_models_py3.py | 255 +- .../v2019_06_01/models/_paged_models.py | 66 - .../models/_subscription_client_enums.py | 26 +- .../v2019_06_01/operations/__init__.py | 7 +- .../v2019_06_01/operations/_operations.py | 106 +- .../operations/_subscriptions_operations.py | 247 +- .../operations/_tenants_operations.py | 106 +- .../subscriptions/v2019_06_01/py.typed | 1 + .../subscriptions/v2019_06_01/version.py | 13 - .../subscriptions/v2019_11_01/__init__.py | 19 +- .../v2019_11_01/_configuration.py | 78 +- .../subscriptions/v2019_11_01/_metadata.json | 43 + .../v2019_11_01/_subscription_client.py | 67 +- .../subscriptions/v2019_11_01/aio/__init__.py | 10 + .../v2019_11_01/aio/_configuration_async.py | 59 + .../aio/_subscription_client_async.py | 66 + .../aio/operations_async/__init__.py | 17 + .../aio/operations_async/_operations_async.py | 101 + .../_subscriptions_operations_async.py | 220 + .../_tenants_operations_async.py | 101 + .../v2019_11_01/models/__init__.py | 54 +- .../v2019_11_01/models/_models.py | 276 +- .../v2019_11_01/models/_models_py3.py | 304 +- .../v2019_11_01/models/_paged_models.py | 66 - .../models/_subscription_client_enums.py | 38 +- .../v2019_11_01/operations/__init__.py | 7 +- .../v2019_11_01/operations/_operations.py | 106 +- .../operations/_subscriptions_operations.py | 247 +- .../operations/_tenants_operations.py | 106 +- .../subscriptions/v2019_11_01/py.typed | 1 + .../subscriptions/v2019_11_01/version.py | 13 - 708 files changed, 140021 insertions(+), 59372 deletions(-) create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_preview/_metadata.json create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_preview/aio/__init__.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_preview/aio/_configuration_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_preview/aio/_deployment_scripts_client_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_preview/aio/operations_async/__init__.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_preview/aio/operations_async/_deployment_scripts_operations_async.py delete mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_preview/models/_paged_models.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_preview/py.typed create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/_metadata.json create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/aio/__init__.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/aio/_configuration_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/aio/_feature_client_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/aio/operations_async/__init__.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/aio/operations_async/_feature_client_operations_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/aio/operations_async/_features_operations_async.py delete mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/models/_paged_models.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/py.typed create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/_metadata.json create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/aio/__init__.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/aio/_configuration_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/aio/_management_link_client_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/aio/operations_async/__init__.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/aio/operations_async/_operations_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/aio/operations_async/_resource_links_operations_async.py delete mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/models/_paged_models.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/py.typed create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/_metadata.json create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/aio/__init__.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/aio/_configuration_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/aio/_management_lock_client_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/aio/operations_async/__init__.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/aio/operations_async/_management_locks_operations_async.py delete mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/models/_paged_models.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/py.typed create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/_metadata.json create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/aio/__init__.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/aio/_configuration_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/aio/_management_lock_client_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/aio/operations_async/__init__.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/aio/operations_async/_authorization_operations_operations_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/aio/operations_async/_management_locks_operations_async.py delete mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/models/_paged_models.py delete mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/operations/_authorization_operations.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/operations/_authorization_operations_operations.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/py.typed delete mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/version.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/_metadata.json rename sdk/resources/azure-mgmt-resource/azure/mgmt/resource/{links/v2016_09_01/models/_management_link_client_enums.py => managedapplications/aio/__init__.py} (74%) create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/aio/_application_client_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/aio/_configuration_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/aio/operations_async/__init__.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/aio/operations_async/_application_definitions_operations_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/aio/operations_async/_applications_operations_async.py delete mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/models/_paged_models.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/py.typed delete mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/version.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/_metadata.json rename sdk/resources/azure-mgmt-resource/azure/mgmt/resource/{links/v2016_09_01/version.py => policy/v2015_10_01_preview/aio/__init__.py} (76%) create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/aio/_configuration_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/aio/_policy_client_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/aio/operations_async/__init__.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/aio/operations_async/_policy_assignments_operations_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/aio/operations_async/_policy_definitions_operations_async.py delete mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/models/_paged_models.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/py.typed delete mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/version.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/_metadata.json rename sdk/resources/azure-mgmt-resource/azure/mgmt/resource/{deploymentscripts/v2019_10_preview/version.py => policy/v2016_04_01/aio/__init__.py} (76%) create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/aio/_configuration_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/aio/_policy_client_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/aio/operations_async/__init__.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/aio/operations_async/_policy_assignments_operations_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/aio/operations_async/_policy_definitions_operations_async.py delete mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/models/_paged_models.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/py.typed delete mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/version.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/_metadata.json rename sdk/resources/azure-mgmt-resource/azure/mgmt/resource/{locks/v2015_01_01/version.py => policy/v2016_12_01/aio/__init__.py} (76%) create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/aio/_configuration_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/aio/_policy_client_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/aio/operations_async/__init__.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/aio/operations_async/_policy_assignments_operations_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/aio/operations_async/_policy_definitions_operations_async.py delete mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/models/_paged_models.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/py.typed delete mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/version.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/_metadata.json rename sdk/resources/azure-mgmt-resource/azure/mgmt/resource/{features/v2015_12_01/version.py => policy/v2017_06_01_preview/aio/__init__.py} (76%) create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/aio/_configuration_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/aio/_policy_client_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/aio/operations_async/__init__.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/aio/operations_async/_policy_assignments_operations_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/aio/operations_async/_policy_definitions_operations_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/aio/operations_async/_policy_set_definitions_operations_async.py delete mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/models/_paged_models.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/py.typed delete mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/version.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/_metadata.json create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/aio/__init__.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/aio/_configuration_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/aio/_policy_client_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/aio/operations_async/__init__.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/aio/operations_async/_policy_assignments_operations_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/aio/operations_async/_policy_definitions_operations_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/aio/operations_async/_policy_set_definitions_operations_async.py delete mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/models/_paged_models.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/py.typed delete mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/version.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/_metadata.json create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/aio/__init__.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/aio/_configuration_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/aio/_policy_client_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/aio/operations_async/__init__.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/aio/operations_async/_policy_assignments_operations_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/aio/operations_async/_policy_definitions_operations_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/aio/operations_async/_policy_set_definitions_operations_async.py delete mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/models/_paged_models.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/py.typed delete mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/version.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/_metadata.json create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/aio/__init__.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/aio/_configuration_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/aio/_policy_client_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/aio/operations_async/__init__.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/aio/operations_async/_policy_assignments_operations_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/aio/operations_async/_policy_definitions_operations_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/aio/operations_async/_policy_set_definitions_operations_async.py delete mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/models/_paged_models.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/py.typed delete mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/version.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/_metadata.json create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/aio/__init__.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/aio/_configuration_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/aio/_policy_client_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/aio/operations_async/__init__.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/aio/operations_async/_policy_assignments_operations_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/aio/operations_async/_policy_definitions_operations_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/aio/operations_async/_policy_set_definitions_operations_async.py delete mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/models/_paged_models.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/py.typed delete mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/version.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/_metadata.json create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/aio/__init__.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/aio/_configuration_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/aio/_policy_client_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/aio/operations_async/__init__.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/aio/operations_async/_policy_assignments_operations_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/aio/operations_async/_policy_definitions_operations_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/aio/operations_async/_policy_set_definitions_operations_async.py delete mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/models/_paged_models.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/py.typed delete mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/version.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/_metadata.json create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/__init__.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/_configuration_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/_resource_management_client_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/operations_async/__init__.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/operations_async/_deployment_operations_operations_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/operations_async/_deployments_operations_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/operations_async/_providers_operations_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/operations_async/_resource_groups_operations_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/operations_async/_resources_operations_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/operations_async/_tags_operations_async.py delete mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/models/_paged_models.py delete mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/operations/_deployment_operations.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/operations/_deployment_operations_operations.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/py.typed delete mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/version.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/_metadata.json create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/__init__.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/_configuration_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/_resource_management_client_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/operations_async/__init__.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/operations_async/_deployment_operations_operations_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/operations_async/_deployments_operations_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/operations_async/_providers_operations_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/operations_async/_resource_groups_operations_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/operations_async/_resources_operations_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/operations_async/_tags_operations_async.py delete mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/models/_paged_models.py delete mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/operations/_deployment_operations.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/operations/_deployment_operations_operations.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/py.typed delete mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/version.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/_metadata.json create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/__init__.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/_configuration_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/_resource_management_client_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/operations_async/__init__.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/operations_async/_deployment_operations_operations_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/operations_async/_deployments_operations_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/operations_async/_providers_operations_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/operations_async/_resource_groups_operations_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/operations_async/_resources_operations_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/operations_async/_tags_operations_async.py delete mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/models/_paged_models.py delete mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/operations/_deployment_operations.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/operations/_deployment_operations_operations.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/py.typed delete mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/version.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/_metadata.json create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/__init__.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/_configuration_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/_resource_management_client_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/operations_async/__init__.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/operations_async/_deployment_operations_operations_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/operations_async/_deployments_operations_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/operations_async/_providers_operations_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/operations_async/_resource_groups_operations_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/operations_async/_resources_operations_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/operations_async/_tags_operations_async.py delete mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/models/_paged_models.py delete mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/operations/_deployment_operations.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/operations/_deployment_operations_operations.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/py.typed delete mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/version.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/_metadata.json create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/__init__.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/_configuration_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/_resource_management_client_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/operations_async/__init__.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/operations_async/_deployment_operations_operations_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/operations_async/_deployments_operations_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/operations_async/_operations_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/operations_async/_providers_operations_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/operations_async/_resource_groups_operations_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/operations_async/_resources_operations_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/operations_async/_tags_operations_async.py delete mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/models/_paged_models.py delete mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/operations/_deployment_operations.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/operations/_deployment_operations_operations.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/py.typed delete mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/version.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/_metadata.json create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/__init__.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/_configuration_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/_resource_management_client_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/operations_async/__init__.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/operations_async/_deployment_operations_operations_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/operations_async/_deployments_operations_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/operations_async/_operations_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/operations_async/_providers_operations_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/operations_async/_resource_groups_operations_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/operations_async/_resources_operations_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/operations_async/_tags_operations_async.py delete mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/models/_paged_models.py delete mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/operations/_deployment_operations.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/operations/_deployment_operations_operations.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/py.typed delete mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/version.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/_metadata.json create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/__init__.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/_configuration_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/_resource_management_client_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/operations_async/__init__.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/operations_async/_deployment_operations_operations_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/operations_async/_deployments_operations_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/operations_async/_operations_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/operations_async/_providers_operations_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/operations_async/_resource_groups_operations_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/operations_async/_resources_operations_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/operations_async/_tags_operations_async.py delete mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/models/_paged_models.py delete mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/operations/_deployment_operations.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/operations/_deployment_operations_operations.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/py.typed delete mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/version.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/_metadata.json create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/__init__.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/_configuration_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/_resource_management_client_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/operations_async/__init__.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/operations_async/_deployment_operations_operations_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/operations_async/_deployments_operations_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/operations_async/_operations_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/operations_async/_providers_operations_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/operations_async/_resource_groups_operations_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/operations_async/_resources_operations_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/operations_async/_tags_operations_async.py delete mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/models/_paged_models.py delete mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/operations/_deployment_operations.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/operations/_deployment_operations_operations.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/py.typed delete mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/version.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/_metadata.json create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/__init__.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/_configuration_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/_resource_management_client_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/operations_async/__init__.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/operations_async/_deployment_operations_operations_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/operations_async/_deployments_operations_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/operations_async/_operations_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/operations_async/_providers_operations_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/operations_async/_resource_groups_operations_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/operations_async/_resources_operations_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/operations_async/_tags_operations_async.py delete mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/models/_paged_models.py delete mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/operations/_deployment_operations.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/operations/_deployment_operations_operations.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/py.typed delete mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/version.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/_metadata.json create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/__init__.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/_configuration_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/_resource_management_client_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/operations_async/__init__.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/operations_async/_deployment_operations_operations_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/operations_async/_deployments_operations_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/operations_async/_operations_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/operations_async/_providers_operations_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/operations_async/_resource_groups_operations_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/operations_async/_resources_operations_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/operations_async/_tags_operations_async.py delete mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/models/_paged_models.py delete mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/operations/_deployment_operations.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/operations/_deployment_operations_operations.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/py.typed delete mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/version.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/_metadata.json create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/aio/__init__.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/aio/_configuration_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/aio/_subscription_client_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/aio/operations_async/__init__.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/aio/operations_async/_operations_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/aio/operations_async/_subscriptions_operations_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/aio/operations_async/_tenants_operations_async.py delete mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/models/_paged_models.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/py.typed delete mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/version.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/_metadata.json create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/aio/__init__.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/aio/_configuration_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/aio/_subscription_client_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/aio/operations_async/__init__.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/aio/operations_async/_operations_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/aio/operations_async/_subscriptions_operations_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/aio/operations_async/_tenants_operations_async.py delete mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/models/_paged_models.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/py.typed delete mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/version.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/_metadata.json create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/aio/__init__.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/aio/_configuration_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/aio/_subscription_client_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/aio/operations_async/__init__.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/aio/operations_async/_operations_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/aio/operations_async/_subscriptions_operations_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/aio/operations_async/_tenants_operations_async.py delete mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/models/_paged_models.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/py.typed delete mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/version.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/_metadata.json create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/aio/__init__.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/aio/_configuration_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/aio/_subscription_client_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/aio/operations_async/__init__.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/aio/operations_async/_operations_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/aio/operations_async/_subscriptions_operations_async.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/aio/operations_async/_tenants_operations_async.py delete mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/models/_paged_models.py create mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/py.typed delete mode 100644 sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/version.py diff --git a/sdk/resources/azure-mgmt-resource/README.md b/sdk/resources/azure-mgmt-resource/README.md index 7fd9ba27948c..bc1a2096c766 100644 --- a/sdk/resources/azure-mgmt-resource/README.md +++ b/sdk/resources/azure-mgmt-resource/README.md @@ -1,28 +1,21 @@ -## Microsoft Azure SDK for Python +# Microsoft Azure SDK for Python This is the Microsoft Azure Resource Management Client Library. - -Azure Resource Manager (ARM) is the next generation of management APIs -that replace the old Azure Service Management (ASM). - This package has been tested with Python 2.7, 3.5, 3.6, 3.7 and 3.8. +For a more complete view of Azure libraries, see the [Github repo](https://github.com/Azure/azure-sdk-for-python/) -For the older Azure Service Management (ASM) libraries, see -[azure-servicemanagement-legacy](https://pypi.python.org/pypi/azure-servicemanagement-legacy) -library. - -For a more complete set of Azure libraries, see the -[azure](https://pypi.python.org/pypi/azure) bundle package. -## Usage +# Usage For code examples, see [Resource Management](https://docs.microsoft.com/python/api/overview/azure/resources) on docs.microsoft.com. -## Provide Feedback -If you encounter any bugs or have suggestions, please file an issue in -the [Issues](https://github.com/Azure/azure-sdk-for-python/issues) +# Provide Feedback + +If you encounter any bugs or have suggestions, please file an issue in the +[Issues](https://github.com/Azure/azure-sdk-for-python/issues) section of the project. -![image](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-python%2Fazure-mgmt-resource%2FREADME.png) + +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-python%2Fazure-mgmt-resource%2FREADME.png) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/__init__.py index 0353e2a97e4b..4af90c3524bb 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/__init__.py @@ -1,19 +1,16 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._configuration import DeploymentScriptsClientConfiguration from ._deployment_scripts_client import DeploymentScriptsClient -__all__ = ['DeploymentScriptsClient', 'DeploymentScriptsClientConfiguration'] - -from ..version import VERSION - -__version__ = VERSION +__all__ = ['DeploymentScriptsClient'] +try: + from ._patch import patch_sdk + patch_sdk() +except ImportError: + pass 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 3b7a52685ae1..8afb19cd52b5 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 @@ -1,49 +1,69 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrestazure import AzureConfiguration -from ..version import VERSION +from typing import TYPE_CHECKING +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + + from azure.core.credentials import TokenCredential + +VERSION = "unknown" + +class DeploymentScriptsClientConfiguration(Configuration): + """Configuration for DeploymentScriptsClient. -class DeploymentScriptsClientConfiguration(AzureConfiguration): - """Configuration for DeploymentScriptsClient Note that all parameters used to create this instance are saved as instance attributes. - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` - :param subscription_id: Subscription Id which forms part of the URI for - every service call. + :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 """ def __init__( - self, credentials, subscription_id, base_url=None): - - if credentials is None: - raise ValueError("Parameter 'credentials' must not be None.") + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + 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.") - if not base_url: - base_url = 'https://management.azure.com' + super(DeploymentScriptsClientConfiguration, self).__init__(**kwargs) - super(DeploymentScriptsClientConfiguration, self).__init__(base_url) - - # Starting Autorest.Python 4.0.64, make connection pool activated by default - self.keep_alive = True - - self.add_user_agent('azure-mgmt-resource/{}'.format(VERSION)) - self.add_user_agent('Azure-SDK-For-Python') - - self.credentials = credentials + self.credential = credential self.subscription_id = subscription_id + self.api_version = "2019-10-01-preview" + self.credential_scopes = ['https://management.azure.com/.default'] + self.credential_scopes.extend(kwargs.pop('credential_scopes', [])) + kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + 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) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_preview/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_preview/__init__.py index 08e241ee1ed8..4af90c3524bb 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_preview/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_preview/__init__.py @@ -1,19 +1,16 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._configuration import DeploymentScriptsClientConfiguration from ._deployment_scripts_client import DeploymentScriptsClient -__all__ = ['DeploymentScriptsClient', 'DeploymentScriptsClientConfiguration'] - -from .version import VERSION - -__version__ = VERSION +__all__ = ['DeploymentScriptsClient'] +try: + from ._patch import patch_sdk + patch_sdk() +except ImportError: + pass diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_preview/_configuration.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_preview/_configuration.py index 142be065a596..8afb19cd52b5 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_preview/_configuration.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_preview/_configuration.py @@ -1,49 +1,69 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrestazure import AzureConfiguration -from .version import VERSION +from typing import TYPE_CHECKING +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + + from azure.core.credentials import TokenCredential + +VERSION = "unknown" + +class DeploymentScriptsClientConfiguration(Configuration): + """Configuration for DeploymentScriptsClient. -class DeploymentScriptsClientConfiguration(AzureConfiguration): - """Configuration for DeploymentScriptsClient Note that all parameters used to create this instance are saved as instance attributes. - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` - :param subscription_id: Subscription Id which forms part of the URI for - every service call. + :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 """ def __init__( - self, credentials, subscription_id, base_url=None): - - if credentials is None: - raise ValueError("Parameter 'credentials' must not be None.") + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + 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.") - if not base_url: - base_url = 'https://management.azure.com' + super(DeploymentScriptsClientConfiguration, self).__init__(**kwargs) - super(DeploymentScriptsClientConfiguration, self).__init__(base_url) - - # Starting Autorest.Python 4.0.64, make connection pool activated by default - self.keep_alive = True - - self.add_user_agent('azure-mgmt-resource/{}'.format(VERSION)) - self.add_user_agent('Azure-SDK-For-Python') - - self.credentials = credentials + self.credential = credential self.subscription_id = subscription_id + self.api_version = "2019-10-01-preview" + self.credential_scopes = ['https://management.azure.com/.default'] + self.credential_scopes.extend(kwargs.pop('credential_scopes', [])) + kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + 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) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_preview/_deployment_scripts_client.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_preview/_deployment_scripts_client.py index 5cae315224cc..df58f5d77b7f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_preview/_deployment_scripts_client.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_preview/_deployment_scripts_client.py @@ -1,50 +1,67 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.service_client import SDKClient -from msrest import Serializer, Deserializer +from typing import TYPE_CHECKING + +from azure.mgmt.core import ARMPipelineClient +from msrest import Deserializer, Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional from ._configuration import DeploymentScriptsClientConfiguration from .operations import DeploymentScriptsOperations from . import models -class DeploymentScriptsClient(SDKClient): +class DeploymentScriptsClient(object): """The APIs listed in this specification can be used to manage Deployment Scripts resource through the Azure Resource Manager. - :ivar config: Configuration for client. - :vartype config: DeploymentScriptsClientConfiguration - - :ivar deployment_scripts: DeploymentScripts operations + :ivar deployment_scripts: DeploymentScriptsOperations operations :vartype deployment_scripts: azure.mgmt.resource.deploymentscripts.v2019_10_preview.operations.DeploymentScriptsOperations - - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` - :param subscription_id: Subscription Id which forms part of the URI for - every service call. + :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. """ def __init__( - self, credentials, subscription_id, base_url=None): - - self.config = DeploymentScriptsClientConfiguration(credentials, subscription_id, base_url) - super(DeploymentScriptsClient, self).__init__(self.config.credentials, self.config) + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = 'https://management.azure.com' + self._config = DeploymentScriptsClientConfiguration(credential, 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.api_version = '2019-10-01-preview' self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self.deployment_scripts = DeploymentScriptsOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> DeploymentScriptsClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_preview/_metadata.json b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_preview/_metadata.json new file mode 100644 index 000000000000..4a33dd40200d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_preview/_metadata.json @@ -0,0 +1,53 @@ +{ + "chosen_version": "2019-10-01-preview", + "total_api_version_list": ["2019-10-01-preview"], + "client": { + "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." + }, + "global_parameters": { + "sync_method": { + "credential": { + "method_signature": "credential, # type: \"TokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials.TokenCredential", + "required": true + }, + "subscription_id": { + "method_signature": "subscription_id, # type: str", + "description": "Subscription Id which forms part of the URI for every service call.", + "docstring_type": "str", + "required": true + } + }, + "async_method": { + "credential": { + "method_signature": "credential, # type: \"AsyncTokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + }, + "subscription_id": { + "method_signature": "subscription_id, # type: str", + "description": "Subscription Id which forms part of the URI for every service call.", + "docstring_type": "str", + "required": true + } + }, + "constant": { + }, + "call": "credential, subscription_id" + }, + "config": { + "credential": true, + "credential_scopes": ["https://management.azure.com/.default"] + }, + "operation_groups": { + "deployment_scripts": "DeploymentScriptsOperations" + }, + "operation_mixins": { + }, + "sync_imports": "None", + "async_imports": "None" +} \ No newline at end of file diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_preview/aio/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_preview/aio/__init__.py new file mode 100644 index 000000000000..20aac1c20f99 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_preview/aio/__init__.py @@ -0,0 +1,10 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._deployment_scripts_client_async import DeploymentScriptsClient +__all__ = ['DeploymentScriptsClient'] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_preview/aio/_configuration_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_preview/aio/_configuration_async.py new file mode 100644 index 000000000000..ea8b9d77c22f --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_preview/aio/_configuration_async.py @@ -0,0 +1,65 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + +VERSION = "unknown" + +class DeploymentScriptsClientConfiguration(Configuration): + """Configuration for DeploymentScriptsClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :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 + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + 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 + self.api_version = "2019-10-01-preview" + self.credential_scopes = ['https://management.azure.com/.default'] + self.credential_scopes.extend(kwargs.pop('credential_scopes', [])) + kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs: Any + ) -> None: + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + 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) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_preview/aio/_deployment_scripts_client_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_preview/aio/_deployment_scripts_client_async.py new file mode 100644 index 000000000000..5b9f863c9a4c --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_preview/aio/_deployment_scripts_client_async.py @@ -0,0 +1,59 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, Optional + +from azure.mgmt.core import AsyncARMPipelineClient +from msrest import Deserializer, Serializer + +from ._configuration_async import DeploymentScriptsClientConfiguration +from .operations_async import DeploymentScriptsOperations +from .. import models + + +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_preview.aio.operations_async.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. + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: Optional[str] = None, + **kwargs: 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) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + + self.deployment_scripts = DeploymentScriptsOperations( + self._client, self._config, self._serialize, self._deserialize) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "DeploymentScriptsClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_preview/aio/operations_async/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_preview/aio/operations_async/__init__.py new file mode 100644 index 000000000000..bb5a688d754f --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_preview/aio/operations_async/__init__.py @@ -0,0 +1,13 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._deployment_scripts_operations_async import DeploymentScriptsOperations + +__all__ = [ + 'DeploymentScriptsOperations', +] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_preview/aio/operations_async/_deployment_scripts_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_preview/aio/operations_async/_deployment_scripts_operations_async.py new file mode 100644 index 000000000000..ad5f20ec0879 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_preview/aio/operations_async/_deployment_scripts_operations_async.py @@ -0,0 +1,587 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.polling import AsyncNoPolling, AsyncPollingMethod, async_poller +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class DeploymentScriptsOperations: + """DeploymentScriptsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def _create_initial( + self, + resource_group_name: str, + script_name: str, + deployment_script: "models.DeploymentScript", + **kwargs + ) -> "models.DeploymentScript": + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentScript"] + error_map = {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") + + # 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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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(models.DeploymentScriptsError, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('DeploymentScript', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('DeploymentScript', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}'} # type: ignore + + async def create( + self, + resource_group_name: str, + script_name: str, + deployment_script: "models.DeploymentScript", + **kwargs + ) -> "models.DeploymentScript": + """Creates a deployment script. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :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_preview.models.DeploymentScript + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: DeploymentScript + :rtype: ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.DeploymentScript + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentScript"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._create_initial( + resource_group_name=resource_group_name, + script_name=script_name, + deployment_script=deployment_script, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('DeploymentScript', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + create.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}'} # type: ignore + + async def update( + self, + resource_group_name: str, + script_name: str, + tags: Optional[Dict[str, str]] = None, + **kwargs + ) -> "models.DeploymentScript": + """Updates deployment script tags with specified values. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param script_name: Name of the deployment script. + :type script_name: str + :param tags: Resource tags to be updated. + :type tags: dict[str, str] + :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_preview.models.DeploymentScript + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentScript"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _deployment_script = models.DeploymentScriptUpdateParameter(tags=tags) + api_version = "2019-10-01-preview" + content_type = kwargs.pop("content_type", "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'] = 'application/json' + + # Construct and send request + body_content_kwargs = {} # type: Dict[str, Any] + if _deployment_script is not None: + body_content = 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) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.DeploymentScriptsError, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentScript', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}'} # type: ignore + + async def get( + self, + resource_group_name: str, + script_name: str, + **kwargs + ) -> "models.DeploymentScript": + """Gets a deployment script with a given name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param script_name: Name of the deployment script. + :type script_name: str + :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_preview.models.DeploymentScript + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentScript"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01-preview" + + # 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'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.DeploymentScriptsError, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentScript', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}'} # type: ignore + + async def delete( + self, + resource_group_name: str, + script_name: str, + **kwargs + ) -> None: + """Deletes a deployment script. When operation completes, status code 200 returned without content. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param script_name: Name of the deployment script. + :type script_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01-preview" + + # 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] + + # Construct and send request + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.DeploymentScriptsError, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}'} # type: ignore + + def list_by_subscription( + self, + **kwargs + ) -> AsyncIterable["models.DeploymentScriptListResult"]: + """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 DeploymentScriptListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.DeploymentScriptListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentScriptListResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01-preview" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentScriptListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.DeploymentScriptsError, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + 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 + + async def get_logs( + self, + resource_group_name: str, + script_name: str, + **kwargs + ) -> "models.ScriptLogsList": + """Gets deployment script logs for a given deployment script name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param script_name: Name of the deployment script. + :type script_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ScriptLogsList or the result of cls(response) + :rtype: ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.ScriptLogsList + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ScriptLogsList"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01-preview" + + # 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'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.DeploymentScriptsError, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ScriptLogsList', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_logs.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}/logs'} # type: ignore + + async def get_logs_default( + self, + resource_group_name: str, + script_name: str, + tail: Optional[int] = None, + **kwargs + ) -> "models.ScriptLog": + """Gets deployment script logs for a given deployment script name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param script_name: Name of the deployment script. + :type script_name: str + :param tail: The number of lines to show from the tail of the deployment script log. Valid + value is a positive number up to 1000. If 'tail' is not provided, all available logs are shown + up to container instance log capacity of 4mb. + :type tail: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ScriptLog or the result of cls(response) + :rtype: ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.ScriptLog + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ScriptLog"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01-preview" + + # 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'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.DeploymentScriptsError, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ScriptLog', pipeline_response) + + if cls: + 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 + + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs + ) -> AsyncIterable["models.DeploymentScriptListResult"]: + """Lists deployments scripts. + + :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 DeploymentScriptListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.DeploymentScriptListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentScriptListResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01-preview" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentScriptListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.DeploymentScriptsError, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + 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.Resources/deploymentScripts'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_preview/models/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_preview/models/__init__.py index d0f4592785b5..c21bacf0a19d 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_preview/models/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_preview/models/__init__.py @@ -1,76 +1,90 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- try: from ._models_py3 import AzureCliScript + from ._models_py3 import AzureCliScriptProperties from ._models_py3 import AzurePowerShellScript + from ._models_py3 import AzurePowerShellScriptProperties from ._models_py3 import AzureResourceBase from ._models_py3 import ContainerConfiguration from ._models_py3 import DeploymentScript + from ._models_py3 import DeploymentScriptListResult + from ._models_py3 import DeploymentScriptPropertiesBase from ._models_py3 import DeploymentScriptUpdateParameter - from ._models_py3 import DeploymentScriptsError, DeploymentScriptsErrorException + from ._models_py3 import DeploymentScriptsError from ._models_py3 import EnvironmentVariable from ._models_py3 import ErrorAdditionalInfo from ._models_py3 import ErrorResponse from ._models_py3 import ManagedServiceIdentity + from ._models_py3 import ScriptConfigurationBase from ._models_py3 import ScriptLog from ._models_py3 import ScriptLogsList from ._models_py3 import ScriptStatus + from ._models_py3 import StorageAccountConfiguration from ._models_py3 import SystemData from ._models_py3 import UserAssignedIdentity except (SyntaxError, ImportError): - from ._models import AzureCliScript - from ._models import AzurePowerShellScript - from ._models import AzureResourceBase - from ._models import ContainerConfiguration - from ._models import DeploymentScript - from ._models import DeploymentScriptUpdateParameter - from ._models import DeploymentScriptsError, DeploymentScriptsErrorException - from ._models import EnvironmentVariable - from ._models import ErrorAdditionalInfo - from ._models import ErrorResponse - from ._models import ManagedServiceIdentity - from ._models import ScriptLog - from ._models import ScriptLogsList - from ._models import ScriptStatus - from ._models import SystemData - from ._models import UserAssignedIdentity -from ._paged_models import DeploymentScriptPaged + from ._models import AzureCliScript # type: ignore + from ._models import AzureCliScriptProperties # type: ignore + from ._models import AzurePowerShellScript # type: ignore + from ._models import AzurePowerShellScriptProperties # type: ignore + from ._models import AzureResourceBase # type: ignore + from ._models import ContainerConfiguration # type: ignore + from ._models import DeploymentScript # type: ignore + from ._models import DeploymentScriptListResult # type: ignore + from ._models import DeploymentScriptPropertiesBase # type: ignore + from ._models import DeploymentScriptUpdateParameter # type: ignore + from ._models import DeploymentScriptsError # type: ignore + from ._models import EnvironmentVariable # type: ignore + from ._models import ErrorAdditionalInfo # type: ignore + from ._models import ErrorResponse # type: ignore + from ._models import ManagedServiceIdentity # type: ignore + from ._models import ScriptConfigurationBase # type: ignore + from ._models import ScriptLog # type: ignore + from ._models import ScriptLogsList # type: ignore + from ._models import ScriptStatus # type: ignore + from ._models import StorageAccountConfiguration # type: ignore + from ._models import SystemData # type: ignore + from ._models import UserAssignedIdentity # type: ignore + from ._deployment_scripts_client_enums import ( - ManagedServiceIdentityType, - CreatedByType, CleanupOptions, + CreatedByType, ScriptProvisioningState, + ScriptType, ) __all__ = [ 'AzureCliScript', + 'AzureCliScriptProperties', 'AzurePowerShellScript', + 'AzurePowerShellScriptProperties', 'AzureResourceBase', 'ContainerConfiguration', 'DeploymentScript', + 'DeploymentScriptListResult', + 'DeploymentScriptPropertiesBase', 'DeploymentScriptUpdateParameter', - 'DeploymentScriptsError', 'DeploymentScriptsErrorException', + 'DeploymentScriptsError', 'EnvironmentVariable', 'ErrorAdditionalInfo', 'ErrorResponse', 'ManagedServiceIdentity', + 'ScriptConfigurationBase', 'ScriptLog', 'ScriptLogsList', 'ScriptStatus', + 'StorageAccountConfiguration', 'SystemData', 'UserAssignedIdentity', - 'DeploymentScriptPaged', - 'ManagedServiceIdentityType', - 'CreatedByType', 'CleanupOptions', + 'CreatedByType', 'ScriptProvisioningState', + 'ScriptType', ] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_preview/models/_deployment_scripts_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_preview/models/_deployment_scripts_client_enums.py index b59700cab06f..1f17a4932c11 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_preview/models/_deployment_scripts_client_enums.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_preview/models/_deployment_scripts_client_enums.py @@ -1,38 +1,34 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from enum import Enum +class CleanupOptions(str, Enum): + """The clean up preference when the script execution gets in a terminal state. Default setting is + 'Always'. + """ -class ManagedServiceIdentityType(str, Enum): - - user_assigned = "UserAssigned" - + always = "Always" + on_success = "OnSuccess" + on_expiration = "OnExpiration" class CreatedByType(str, Enum): + """The type of identity that created the resource. + """ user = "User" application = "Application" managed_identity = "ManagedIdentity" key = "Key" - -class CleanupOptions(str, Enum): - - always = "Always" - on_success = "OnSuccess" - on_expiration = "OnExpiration" - - class ScriptProvisioningState(str, Enum): + """State of the script execution. This only appears in the response. + """ creating = "Creating" provisioning_resources = "ProvisioningResources" @@ -40,3 +36,10 @@ class ScriptProvisioningState(str, Enum): succeeded = "Succeeded" failed = "Failed" canceled = "Canceled" + +class ScriptType(str, Enum): + """Type of the script. + """ + + azure_power_shell = "AzurePowerShell" + azure_cli = "AzureCLI" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_preview/models/_models.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_preview/models/_models.py index c3c6f414ae8b..97c610abd311 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_preview/models/_models.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_preview/models/_models.py @@ -1,23 +1,19 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.serialization import Model -from msrest.exceptions import HttpOperationError +from azure.core.exceptions import HttpResponseError +import msrest.serialization -class AzureResourceBase(Model): +class AzureResourceBase(msrest.serialization.Model): """Common properties for all Azure resources. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: String Id used to locate any resource on Azure. :vartype id: str @@ -39,7 +35,10 @@ class AzureResourceBase(Model): 'type': {'key': 'type', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(AzureResourceBase, self).__init__(**kwargs) self.id = None self.name = None @@ -50,10 +49,9 @@ class DeploymentScript(AzureResourceBase): """Deployment script object. You probably want to use the sub-classes and not this class directly. Known - sub-classes are: AzurePowerShellScript, AzureCliScript + sub-classes are: AzureCliScript, AzurePowerShellScript. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. @@ -63,20 +61,20 @@ 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, only user-assigned MSI is supported. + :param identity: Required. Managed identity to be used for this deployment script. Currently, + only user-assigned MSI is supported. :type identity: ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.ManagedServiceIdentity - :param location: Required. The location of the ACI and the storage account - for the deployment script. + :param location: Required. The location of the ACI and the storage account for the deployment + script. :type location: str - :param tags: Resource tags. + :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: + "AzurePowerShell", "AzureCLI". + :type kind: str or ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.ScriptType :ivar system_data: The system metadata related to this resource. - :vartype system_data: - ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.SystemData - :param kind: Required. Constant filled by server. - :type kind: str + :vartype system_data: ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.SystemData """ _validation = { @@ -85,8 +83,8 @@ class DeploymentScript(AzureResourceBase): 'type': {'readonly': True}, 'identity': {'required': True}, 'location': {'required': True}, - 'system_data': {'readonly': True}, 'kind': {'required': True}, + 'system_data': {'readonly': True}, } _attribute_map = { @@ -96,29 +94,30 @@ class DeploymentScript(AzureResourceBase): 'identity': {'key': 'identity', 'type': 'ManagedServiceIdentity'}, 'location': {'key': 'location', 'type': 'str'}, 'tags': {'key': 'tags', 'type': '{str}'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, 'kind': {'key': 'kind', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, } _subtype_map = { - 'kind': {'AzurePowerShell': 'AzurePowerShellScript', 'AzureCLI': 'AzureCliScript'} + 'kind': {'AzureCLI': 'AzureCliScript', 'AzurePowerShell': 'AzurePowerShellScript'} } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentScript, self).__init__(**kwargs) - self.identity = kwargs.get('identity', None) - self.location = kwargs.get('location', None) + self.identity = kwargs['identity'] + self.location = kwargs['location'] self.tags = kwargs.get('tags', None) - self.system_data = None - self.kind = None self.kind = 'DeploymentScript' + self.system_data = None class AzureCliScript(DeploymentScript): """Object model for the Azure CLI script. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. @@ -128,64 +127,62 @@ 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, only user-assigned MSI is supported. + :param identity: Required. Managed identity to be used for this deployment script. Currently, + only user-assigned MSI is supported. :type identity: ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.ManagedServiceIdentity - :param location: Required. The location of the ACI and the storage account - for the deployment script. + :param location: Required. The location of the ACI and the storage account for the deployment + script. :type location: str - :param tags: Resource tags. + :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: + "AzurePowerShell", "AzureCLI". + :type kind: str or ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.ScriptType :ivar system_data: The system metadata related to this resource. - :vartype system_data: - ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.SystemData - :param kind: Required. Constant filled by server. - :type kind: str + :vartype system_data: ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.SystemData :param container_settings: Container settings. :type container_settings: ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.ContainerConfiguration - :param 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' + :param storage_account_settings: Storage Account settings. + :type storage_account_settings: + ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.StorageAccountConfiguration + :param 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". :type cleanup_preference: str or ~azure.mgmt.resource.deploymentscripts.v2019_10_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', 'Canceled' + :ivar provisioning_state: State of the script execution. This only appears in the response. + Possible values include: "Creating", "ProvisioningResources", "Running", "Succeeded", "Failed", + "Canceled". :vartype provisioning_state: str or ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.ScriptProvisioningState :ivar status: Contains the results of script execution. - :vartype status: - ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.ScriptStatus + :vartype status: ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.ScriptStatus :ivar outputs: List of script outputs. :vartype outputs: dict[str, object] - :param primary_script_uri: Uri for the script. This is the entry point for - the external script. + :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 spaces. ex: -Name blue* -Location 'West US 2' + :param 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. + :param environment_variables: The environment variables to pass over to the script. :type environment_variables: list[~azure.mgmt.resource.deploymentscripts.v2019_10_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. + :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 after it reaches a terminal state. Resource - will be deleted when this duration expires. Duration is based on ISO 8601 - pattern (for example P7D means one week). - :type retention_interval: timedelta - :param timeout: Maximum allowed script execution time specified in ISO - 8601 format. Default value is PT1H - :type timeout: timedelta + :param 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 P7D means one week). + :type retention_interval: ~datetime.timedelta + :param timeout: Maximum allowed script execution time specified in ISO 8601 format. Default + value is PT1H. + :type timeout: ~datetime.timedelta :param az_cli_version: Required. Azure CLI module version to be used. :type az_cli_version: str """ @@ -196,12 +193,12 @@ class AzureCliScript(DeploymentScript): 'type': {'readonly': True}, 'identity': {'required': True}, 'location': {'required': True}, - 'system_data': {'readonly': True}, 'kind': {'required': True}, + 'system_data': {'readonly': True}, 'provisioning_state': {'readonly': True}, 'status': {'readonly': True}, 'outputs': {'readonly': True}, - 'script_content': {'max_length': 32000}, + 'script_content': {'max_length': 32000, 'min_length': 0}, 'retention_interval': {'required': True}, 'az_cli_version': {'required': True}, } @@ -213,9 +210,10 @@ class AzureCliScript(DeploymentScript): 'identity': {'key': 'identity', 'type': 'ManagedServiceIdentity'}, 'location': {'key': 'location', 'type': 'str'}, 'tags': {'key': 'tags', 'type': '{str}'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, 'kind': {'key': 'kind', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, 'container_settings': {'key': 'properties.containerSettings', 'type': 'ContainerConfiguration'}, + 'storage_account_settings': {'key': 'properties.storageAccountSettings', 'type': 'StorageAccountConfiguration'}, 'cleanup_preference': {'key': 'properties.cleanupPreference', 'type': 'str'}, 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, 'status': {'key': 'properties.status', 'type': 'ScriptStatus'}, @@ -231,9 +229,14 @@ class AzureCliScript(DeploymentScript): 'az_cli_version': {'key': 'properties.azCliVersion', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(AzureCliScript, self).__init__(**kwargs) + self.kind = 'AzureCLI' self.container_settings = kwargs.get('container_settings', None) + self.storage_account_settings = kwargs.get('storage_account_settings', None) self.cleanup_preference = kwargs.get('cleanup_preference', None) self.provisioning_state = None self.status = None @@ -244,17 +247,233 @@ def __init__(self, **kwargs): self.arguments = kwargs.get('arguments', None) self.environment_variables = kwargs.get('environment_variables', None) self.force_update_tag = kwargs.get('force_update_tag', None) - self.retention_interval = kwargs.get('retention_interval', None) + self.retention_interval = kwargs['retention_interval'] self.timeout = kwargs.get('timeout', None) - self.az_cli_version = kwargs.get('az_cli_version', None) - self.kind = 'AzureCLI' + self.az_cli_version = kwargs['az_cli_version'] + + +class ScriptConfigurationBase(msrest.serialization.Model): + """Common configuration settings for both Azure PowerShell and Azure CLI scripts. + + 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 + 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: + list[~azure.mgmt.resource.deploymentscripts.v2019_10_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 + after it reaches a terminal state. Resource will be deleted when this duration expires. + Duration is based on ISO 8601 pattern (for example P7D means one week). + :type retention_interval: ~datetime.timedelta + :param timeout: Maximum allowed script execution time specified in ISO 8601 format. Default + value is PT1H. + :type timeout: ~datetime.timedelta + """ + + _validation = { + 'script_content': {'max_length': 32000, 'min_length': 0}, + 'retention_interval': {'required': True}, + } + + _attribute_map = { + 'primary_script_uri': {'key': 'primaryScriptUri', 'type': 'str'}, + 'supporting_script_uris': {'key': 'supportingScriptUris', 'type': '[str]'}, + 'script_content': {'key': 'scriptContent', 'type': 'str'}, + 'arguments': {'key': 'arguments', 'type': 'str'}, + 'environment_variables': {'key': 'environmentVariables', 'type': '[EnvironmentVariable]'}, + 'force_update_tag': {'key': 'forceUpdateTag', 'type': 'str'}, + 'retention_interval': {'key': 'retentionInterval', 'type': 'duration'}, + 'timeout': {'key': 'timeout', 'type': 'duration'}, + } + + def __init__( + self, + **kwargs + ): + 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) + self.script_content = kwargs.get('script_content', None) + self.arguments = kwargs.get('arguments', None) + self.environment_variables = kwargs.get('environment_variables', None) + self.force_update_tag = kwargs.get('force_update_tag', None) + self.retention_interval = kwargs['retention_interval'] + self.timeout = kwargs.get('timeout', None) + + +class DeploymentScriptPropertiesBase(msrest.serialization.Model): + """Common properties for the deployment script. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param container_settings: Container settings. + :type container_settings: + ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.ContainerConfiguration + :param storage_account_settings: Storage Account settings. + :type storage_account_settings: + ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.StorageAccountConfiguration + :param 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". + :type cleanup_preference: str or + ~azure.mgmt.resource.deploymentscripts.v2019_10_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", + "Canceled". + :vartype provisioning_state: str or + ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.ScriptProvisioningState + :ivar status: Contains the results of script execution. + :vartype status: ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.ScriptStatus + :ivar outputs: List of script outputs. + :vartype outputs: dict[str, object] + """ + + _validation = { + 'provisioning_state': {'readonly': True}, + 'status': {'readonly': True}, + 'outputs': {'readonly': True}, + } + + _attribute_map = { + 'container_settings': {'key': 'containerSettings', 'type': 'ContainerConfiguration'}, + 'storage_account_settings': {'key': 'storageAccountSettings', 'type': 'StorageAccountConfiguration'}, + 'cleanup_preference': {'key': 'cleanupPreference', 'type': 'str'}, + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'ScriptStatus'}, + 'outputs': {'key': 'outputs', 'type': '{object}'}, + } + + def __init__( + self, + **kwargs + ): + super(DeploymentScriptPropertiesBase, self).__init__(**kwargs) + self.container_settings = kwargs.get('container_settings', None) + self.storage_account_settings = kwargs.get('storage_account_settings', None) + self.cleanup_preference = kwargs.get('cleanup_preference', None) + self.provisioning_state = None + self.status = None + self.outputs = None + + +class AzureCliScriptProperties(DeploymentScriptPropertiesBase, ScriptConfigurationBase): + """Properties of the Azure CLI script object. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :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 + 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: + list[~azure.mgmt.resource.deploymentscripts.v2019_10_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 + after it reaches a terminal state. Resource will be deleted when this duration expires. + Duration is based on ISO 8601 pattern (for example P7D means one week). + :type retention_interval: ~datetime.timedelta + :param timeout: Maximum allowed script execution time specified in ISO 8601 format. Default + value is PT1H. + :type timeout: ~datetime.timedelta + :param container_settings: Container settings. + :type container_settings: + ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.ContainerConfiguration + :param storage_account_settings: Storage Account settings. + :type storage_account_settings: + ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.StorageAccountConfiguration + :param 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". + :type cleanup_preference: str or + ~azure.mgmt.resource.deploymentscripts.v2019_10_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", + "Canceled". + :vartype provisioning_state: str or + ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.ScriptProvisioningState + :ivar status: Contains the results of script execution. + :vartype status: ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.ScriptStatus + :ivar outputs: List of script outputs. + :vartype outputs: dict[str, object] + :param az_cli_version: Required. Azure CLI module version to be used. + :type az_cli_version: str + """ + + _validation = { + 'script_content': {'max_length': 32000, 'min_length': 0}, + 'retention_interval': {'required': True}, + 'provisioning_state': {'readonly': True}, + 'status': {'readonly': True}, + 'outputs': {'readonly': True}, + 'az_cli_version': {'required': True}, + } + + _attribute_map = { + 'primary_script_uri': {'key': 'primaryScriptUri', 'type': 'str'}, + 'supporting_script_uris': {'key': 'supportingScriptUris', 'type': '[str]'}, + 'script_content': {'key': 'scriptContent', 'type': 'str'}, + 'arguments': {'key': 'arguments', 'type': 'str'}, + 'environment_variables': {'key': 'environmentVariables', 'type': '[EnvironmentVariable]'}, + 'force_update_tag': {'key': 'forceUpdateTag', 'type': 'str'}, + 'retention_interval': {'key': 'retentionInterval', 'type': 'duration'}, + 'timeout': {'key': 'timeout', 'type': 'duration'}, + 'container_settings': {'key': 'containerSettings', 'type': 'ContainerConfiguration'}, + 'storage_account_settings': {'key': 'storageAccountSettings', 'type': 'StorageAccountConfiguration'}, + 'cleanup_preference': {'key': 'cleanupPreference', 'type': 'str'}, + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'ScriptStatus'}, + 'outputs': {'key': 'outputs', 'type': '{object}'}, + 'az_cli_version': {'key': 'azCliVersion', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + 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) + self.script_content = kwargs.get('script_content', None) + self.arguments = kwargs.get('arguments', None) + self.environment_variables = kwargs.get('environment_variables', None) + self.force_update_tag = kwargs.get('force_update_tag', None) + self.retention_interval = kwargs['retention_interval'] + self.timeout = kwargs.get('timeout', None) + self.az_cli_version = kwargs['az_cli_version'] + self.container_settings = kwargs.get('container_settings', None) + self.storage_account_settings = kwargs.get('storage_account_settings', None) + self.cleanup_preference = kwargs.get('cleanup_preference', None) + self.provisioning_state = None + self.status = None + self.outputs = None + self.az_cli_version = kwargs['az_cli_version'] class AzurePowerShellScript(DeploymentScript): """Object model for the Azure PowerShell script. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. @@ -264,66 +483,63 @@ 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, only user-assigned MSI is supported. + :param identity: Required. Managed identity to be used for this deployment script. Currently, + only user-assigned MSI is supported. :type identity: ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.ManagedServiceIdentity - :param location: Required. The location of the ACI and the storage account - for the deployment script. + :param location: Required. The location of the ACI and the storage account for the deployment + script. :type location: str - :param tags: Resource tags. + :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: + "AzurePowerShell", "AzureCLI". + :type kind: str or ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.ScriptType :ivar system_data: The system metadata related to this resource. - :vartype system_data: - ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.SystemData - :param kind: Required. Constant filled by server. - :type kind: str + :vartype system_data: ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.SystemData :param container_settings: Container settings. :type container_settings: ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.ContainerConfiguration - :param 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' + :param storage_account_settings: Storage Account settings. + :type storage_account_settings: + ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.StorageAccountConfiguration + :param 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". :type cleanup_preference: str or ~azure.mgmt.resource.deploymentscripts.v2019_10_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', 'Canceled' + :ivar provisioning_state: State of the script execution. This only appears in the response. + Possible values include: "Creating", "ProvisioningResources", "Running", "Succeeded", "Failed", + "Canceled". :vartype provisioning_state: str or ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.ScriptProvisioningState :ivar status: Contains the results of script execution. - :vartype status: - ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.ScriptStatus + :vartype status: ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.ScriptStatus :ivar outputs: List of script outputs. :vartype outputs: dict[str, object] - :param primary_script_uri: Uri for the script. This is the entry point for - the external script. + :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 spaces. ex: -Name blue* -Location 'West US 2' + :param 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. + :param environment_variables: The environment variables to pass over to the script. :type environment_variables: list[~azure.mgmt.resource.deploymentscripts.v2019_10_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. + :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 after it reaches a terminal state. Resource - will be deleted when this duration expires. Duration is based on ISO 8601 - pattern (for example P7D means one week). - :type retention_interval: timedelta - :param timeout: Maximum allowed script execution time specified in ISO - 8601 format. Default value is PT1H - :type timeout: timedelta - :param az_power_shell_version: Required. Azure PowerShell module version - to be used. + :param 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 P7D means one week). + :type retention_interval: ~datetime.timedelta + :param timeout: Maximum allowed script execution time specified in ISO 8601 format. Default + value is PT1H. + :type timeout: ~datetime.timedelta + :param az_power_shell_version: Required. Azure PowerShell module version to be used. :type az_power_shell_version: str """ @@ -333,12 +549,12 @@ class AzurePowerShellScript(DeploymentScript): 'type': {'readonly': True}, 'identity': {'required': True}, 'location': {'required': True}, - 'system_data': {'readonly': True}, 'kind': {'required': True}, + 'system_data': {'readonly': True}, 'provisioning_state': {'readonly': True}, 'status': {'readonly': True}, 'outputs': {'readonly': True}, - 'script_content': {'max_length': 32000}, + 'script_content': {'max_length': 32000, 'min_length': 0}, 'retention_interval': {'required': True}, 'az_power_shell_version': {'required': True}, } @@ -350,9 +566,10 @@ class AzurePowerShellScript(DeploymentScript): 'identity': {'key': 'identity', 'type': 'ManagedServiceIdentity'}, 'location': {'key': 'location', 'type': 'str'}, 'tags': {'key': 'tags', 'type': '{str}'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, 'kind': {'key': 'kind', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, 'container_settings': {'key': 'properties.containerSettings', 'type': 'ContainerConfiguration'}, + 'storage_account_settings': {'key': 'properties.storageAccountSettings', 'type': 'StorageAccountConfiguration'}, 'cleanup_preference': {'key': 'properties.cleanupPreference', 'type': 'str'}, 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, 'status': {'key': 'properties.status', 'type': 'ScriptStatus'}, @@ -368,9 +585,14 @@ class AzurePowerShellScript(DeploymentScript): 'az_power_shell_version': {'key': 'properties.azPowerShellVersion', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(AzurePowerShellScript, self).__init__(**kwargs) + self.kind = 'AzurePowerShell' self.container_settings = kwargs.get('container_settings', None) + self.storage_account_settings = kwargs.get('storage_account_settings', None) self.cleanup_preference = kwargs.get('cleanup_preference', None) self.provisioning_state = None self.status = None @@ -381,164 +603,232 @@ def __init__(self, **kwargs): self.arguments = kwargs.get('arguments', None) self.environment_variables = kwargs.get('environment_variables', None) self.force_update_tag = kwargs.get('force_update_tag', None) - self.retention_interval = kwargs.get('retention_interval', None) + self.retention_interval = kwargs['retention_interval'] self.timeout = kwargs.get('timeout', None) - self.az_power_shell_version = kwargs.get('az_power_shell_version', None) - self.kind = 'AzurePowerShell' - - -class CloudError(Model): - """CloudError. - """ - - _attribute_map = { - } + self.az_power_shell_version = kwargs['az_power_shell_version'] -class ContainerConfiguration(Model): - """Settings to customize ACI container instance. +class AzurePowerShellScriptProperties(DeploymentScriptPropertiesBase, ScriptConfigurationBase): + """Properties of the Azure PowerShell script object. - :param 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. - :type container_group_name: str - """ + Variables are only populated by the server, and will be ignored when sending a request. - _validation = { - 'container_group_name': {'max_length': 63, 'min_length': 1}, - } - - _attribute_map = { - 'container_group_name': {'key': 'containerGroupName', 'type': 'str'}, - } - - def __init__(self, **kwargs): - super(ContainerConfiguration, self).__init__(**kwargs) - self.container_group_name = kwargs.get('container_group_name', None) - - -class DeploymentScriptPropertiesBase(Model): - """Common properties for the deployment script. - - Variables are only populated by the server, and will be ignored when - sending a request. + All required parameters must be populated in order to send to Azure. + :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 + 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: + list[~azure.mgmt.resource.deploymentscripts.v2019_10_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 + after it reaches a terminal state. Resource will be deleted when this duration expires. + Duration is based on ISO 8601 pattern (for example P7D means one week). + :type retention_interval: ~datetime.timedelta + :param timeout: Maximum allowed script execution time specified in ISO 8601 format. Default + value is PT1H. + :type timeout: ~datetime.timedelta :param container_settings: Container settings. :type container_settings: ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.ContainerConfiguration - :param 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' + :param storage_account_settings: Storage Account settings. + :type storage_account_settings: + ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.StorageAccountConfiguration + :param 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". :type cleanup_preference: str or ~azure.mgmt.resource.deploymentscripts.v2019_10_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', 'Canceled' + :ivar provisioning_state: State of the script execution. This only appears in the response. + Possible values include: "Creating", "ProvisioningResources", "Running", "Succeeded", "Failed", + "Canceled". :vartype provisioning_state: str or ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.ScriptProvisioningState :ivar status: Contains the results of script execution. - :vartype status: - ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.ScriptStatus + :vartype status: ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.ScriptStatus :ivar outputs: List of script outputs. :vartype outputs: dict[str, object] + :param az_power_shell_version: Required. Azure PowerShell module version to be used. + :type az_power_shell_version: str """ _validation = { + 'script_content': {'max_length': 32000, 'min_length': 0}, + 'retention_interval': {'required': True}, 'provisioning_state': {'readonly': True}, 'status': {'readonly': True}, 'outputs': {'readonly': True}, + 'az_power_shell_version': {'required': True}, } _attribute_map = { + 'primary_script_uri': {'key': 'primaryScriptUri', 'type': 'str'}, + 'supporting_script_uris': {'key': 'supportingScriptUris', 'type': '[str]'}, + 'script_content': {'key': 'scriptContent', 'type': 'str'}, + 'arguments': {'key': 'arguments', 'type': 'str'}, + 'environment_variables': {'key': 'environmentVariables', 'type': '[EnvironmentVariable]'}, + 'force_update_tag': {'key': 'forceUpdateTag', 'type': 'str'}, + 'retention_interval': {'key': 'retentionInterval', 'type': 'duration'}, + 'timeout': {'key': 'timeout', 'type': 'duration'}, 'container_settings': {'key': 'containerSettings', 'type': 'ContainerConfiguration'}, + 'storage_account_settings': {'key': 'storageAccountSettings', 'type': 'StorageAccountConfiguration'}, 'cleanup_preference': {'key': 'cleanupPreference', 'type': 'str'}, 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, 'status': {'key': 'status', 'type': 'ScriptStatus'}, 'outputs': {'key': 'outputs', 'type': '{object}'}, + 'az_power_shell_version': {'key': 'azPowerShellVersion', 'type': 'str'}, } - def __init__(self, **kwargs): - super(DeploymentScriptPropertiesBase, self).__init__(**kwargs) + def __init__( + self, + **kwargs + ): + 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) + self.script_content = kwargs.get('script_content', None) + self.arguments = kwargs.get('arguments', None) + self.environment_variables = kwargs.get('environment_variables', None) + self.force_update_tag = kwargs.get('force_update_tag', None) + self.retention_interval = kwargs['retention_interval'] + self.timeout = kwargs.get('timeout', None) + self.az_power_shell_version = kwargs['az_power_shell_version'] self.container_settings = kwargs.get('container_settings', None) + self.storage_account_settings = kwargs.get('storage_account_settings', None) self.cleanup_preference = kwargs.get('cleanup_preference', None) self.provisioning_state = None self.status = None self.outputs = None + self.az_power_shell_version = kwargs['az_power_shell_version'] -class DeploymentScriptUpdateParameter(AzureResourceBase): - """Deployment script parameters to be updated. . +class ContainerConfiguration(msrest.serialization.Model): + """Settings to customize ACI container instance. - Variables are only populated by the server, and will be ignored when - sending a request. + :param 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. + :type container_group_name: str + """ - :ivar id: String Id used to locate any resource on Azure. - :vartype id: str - :ivar name: Name of this resource. - :vartype name: str - :ivar type: Type of this resource. - :vartype type: str - :param tags: Resource tags to be updated. - :type tags: dict[str, str] + _validation = { + 'container_group_name': {'max_length': 63, 'min_length': 1}, + } + + _attribute_map = { + 'container_group_name': {'key': 'containerGroupName', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ContainerConfiguration, self).__init__(**kwargs) + self.container_group_name = kwargs.get('container_group_name', None) + + +class DeploymentScriptListResult(msrest.serialization.Model): + """List of deployment scripts. + + 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.v2019_10_preview.models.DeploymentScript] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + 'next_link': {'readonly': True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + 'value': {'key': 'value', 'type': '[DeploymentScript]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, } - def __init__(self, **kwargs): - super(DeploymentScriptUpdateParameter, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) + def __init__( + self, + **kwargs + ): + super(DeploymentScriptListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = None -class DeploymentScriptsError(Model): +class DeploymentScriptsError(msrest.serialization.Model): """Deployment scripts error response. - :param error: - :type error: - ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.ErrorResponse + :param error: The resource management error response. + :type error: ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.ErrorResponse """ _attribute_map = { 'error': {'key': 'error', 'type': 'ErrorResponse'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentScriptsError, self).__init__(**kwargs) self.error = kwargs.get('error', None) -class DeploymentScriptsErrorException(HttpOperationError): - """Server responsed with exception of type: 'DeploymentScriptsError'. +class DeploymentScriptUpdateParameter(AzureResourceBase): + """Deployment script parameters to be updated. + + Variables are only populated by the server, and will be ignored when sending a request. - :param deserialize: A deserializer - :param response: Server response to be deserialized. + :ivar id: String Id used to locate any resource on Azure. + :vartype id: str + :ivar name: Name of this resource. + :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] """ - def __init__(self, deserialize, response, *args): + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } - super(DeploymentScriptsErrorException, self).__init__(deserialize, response, 'DeploymentScriptsError', *args) + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__( + self, + **kwargs + ): + super(DeploymentScriptUpdateParameter, self).__init__(**kwargs) + self.tags = kwargs.get('tags', None) -class EnvironmentVariable(Model): +class EnvironmentVariable(msrest.serialization.Model): """The environment variable to pass to the script in the container instance. All required parameters must be populated in order to send to Azure. @@ -561,18 +851,20 @@ class EnvironmentVariable(Model): 'secure_value': {'key': 'secureValue', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(EnvironmentVariable, self).__init__(**kwargs) - self.name = kwargs.get('name', None) + self.name = kwargs['name'] self.value = kwargs.get('value', None) self.secure_value = kwargs.get('secure_value', None) -class ErrorAdditionalInfo(Model): +class ErrorAdditionalInfo(msrest.serialization.Model): """The resource management error additional info. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar type: The additional info type. :vartype type: str @@ -590,17 +882,19 @@ class ErrorAdditionalInfo(Model): 'info': {'key': 'info', 'type': 'object'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None -class ErrorResponse(Model): +class ErrorResponse(msrest.serialization.Model): """The resource management error response. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar code: The error code. :vartype code: str @@ -632,7 +926,10 @@ class ErrorResponse(Model): 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ErrorResponse, self).__init__(**kwargs) self.code = None self.message = None @@ -641,98 +938,42 @@ def __init__(self, **kwargs): self.additional_info = None -class ManagedServiceIdentity(Model): +class ManagedServiceIdentity(msrest.serialization.Model): """Managed identity generic object. - :param type: Type of the managed identity. Possible values include: - 'UserAssigned' - :type type: str or - ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.ManagedServiceIdentityType - :param user_assigned_identities: The list of user-assigned managed - identities associated with the resource. Key is the Azure resource Id of - the managed identity. + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar type: Type of the managed identity. Default value: "UserAssigned". + :vartype type: str + :param 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, ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.UserAssignedIdentity] """ + _validation = { + 'type': {'constant': True}, + } + _attribute_map = { 'type': {'key': 'type', 'type': 'str'}, 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{UserAssignedIdentity}'}, } - def __init__(self, **kwargs): + type = "UserAssigned" + + def __init__( + self, + **kwargs + ): super(ManagedServiceIdentity, self).__init__(**kwargs) - self.type = kwargs.get('type', None) self.user_assigned_identities = kwargs.get('user_assigned_identities', None) -class ScriptConfigurationBase(Model): - """Common configuration settings for both Azure PowerShell and Azure CLI - scripts. - - 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 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: - list[~azure.mgmt.resource.deploymentscripts.v2019_10_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 after it reaches a terminal state. Resource - will be deleted when this duration expires. Duration is based on ISO 8601 - pattern (for example P7D means one week). - :type retention_interval: timedelta - :param timeout: Maximum allowed script execution time specified in ISO - 8601 format. Default value is PT1H - :type timeout: timedelta - """ - - _validation = { - 'script_content': {'max_length': 32000}, - 'retention_interval': {'required': True}, - } - - _attribute_map = { - 'primary_script_uri': {'key': 'primaryScriptUri', 'type': 'str'}, - 'supporting_script_uris': {'key': 'supportingScriptUris', 'type': '[str]'}, - 'script_content': {'key': 'scriptContent', 'type': 'str'}, - 'arguments': {'key': 'arguments', 'type': 'str'}, - 'environment_variables': {'key': 'environmentVariables', 'type': '[EnvironmentVariable]'}, - 'force_update_tag': {'key': 'forceUpdateTag', 'type': 'str'}, - 'retention_interval': {'key': 'retentionInterval', 'type': 'duration'}, - 'timeout': {'key': 'timeout', 'type': 'duration'}, - } - - def __init__(self, **kwargs): - 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) - self.script_content = kwargs.get('script_content', None) - self.arguments = kwargs.get('arguments', None) - self.environment_variables = kwargs.get('environment_variables', None) - self.force_update_tag = kwargs.get('force_update_tag', None) - self.retention_interval = kwargs.get('retention_interval', None) - self.timeout = kwargs.get('timeout', None) - - class ScriptLog(AzureResourceBase): """Script execution log object. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: String Id used to locate any resource on Azure. :vartype id: str @@ -758,47 +999,50 @@ class ScriptLog(AzureResourceBase): 'log': {'key': 'properties.log', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ScriptLog, self).__init__(**kwargs) self.log = None -class ScriptLogsList(Model): +class ScriptLogsList(msrest.serialization.Model): """Deployment script execution logs. :param value: Deployment scripts logs. - :type value: - list[~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.ScriptLog] + :type value: list[~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.ScriptLog] """ _attribute_map = { 'value': {'key': 'value', 'type': '[ScriptLog]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ScriptLogsList, self).__init__(**kwargs) self.value = kwargs.get('value', None) -class ScriptStatus(Model): +class ScriptStatus(msrest.serialization.Model): """Generic object modeling results of script execution. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar container_instance_id: ACI resource Id. :vartype container_instance_id: str :ivar storage_account_id: Storage account resource Id. :vartype storage_account_id: str :ivar start_time: Start time of the script execution. - :vartype start_time: datetime + :vartype start_time: ~datetime.datetime :ivar end_time: End time of the script execution. - :vartype end_time: datetime + :vartype end_time: ~datetime.datetime :ivar expiration_time: Time the deployment script resource will expire. - :vartype expiration_time: datetime + :vartype expiration_time: ~datetime.datetime :param error: Error that is relayed from the script execution. - :type error: - ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.ErrorResponse + :type error: ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.ErrorResponse """ _validation = { @@ -818,7 +1062,10 @@ class ScriptStatus(Model): 'error': {'key': 'error', 'type': 'ErrorResponse'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ScriptStatus, self).__init__(**kwargs) self.container_instance_id = None self.storage_account_id = None @@ -828,27 +1075,48 @@ def __init__(self, **kwargs): self.error = kwargs.get('error', None) -class SystemData(Model): +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 + """ + + _attribute_map = { + 'storage_account_name': {'key': 'storageAccountName', 'type': 'str'}, + 'storage_account_key': {'key': 'storageAccountKey', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + 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) + + +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' + :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.deploymentscripts.v2019_10_preview.models.CreatedByType :param created_at: The timestamp of resource creation (UTC). - :type created_at: datetime + :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 values include: 'User', 'Application', - 'ManagedIdentity', 'Key' + :param 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 ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.CreatedByType - :param last_modified_at: The type of identity that last modified the - resource. - :type last_modified_at: datetime + :param last_modified_at: The type of identity that last modified the resource. + :type last_modified_at: ~datetime.datetime """ _attribute_map = { @@ -860,7 +1128,10 @@ class SystemData(Model): 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(SystemData, self).__init__(**kwargs) self.created_by = kwargs.get('created_by', None) self.created_by_type = kwargs.get('created_by_type', None) @@ -870,11 +1141,10 @@ def __init__(self, **kwargs): self.last_modified_at = kwargs.get('last_modified_at', None) -class UserAssignedIdentity(Model): +class UserAssignedIdentity(msrest.serialization.Model): """User-assigned managed identity. - :param principal_id: Azure Active Directory principal ID associated with - this identity. + :param principal_id: Azure Active Directory principal ID associated with this identity. :type principal_id: str :param client_id: Client App Id associated with this identity. :type client_id: str @@ -885,7 +1155,10 @@ class UserAssignedIdentity(Model): 'client_id': {'key': 'clientId', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(UserAssignedIdentity, self).__init__(**kwargs) self.principal_id = kwargs.get('principal_id', None) self.client_id = kwargs.get('client_id', None) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_preview/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_preview/models/_models_py3.py index e4fe023d0a69..eb8330f2ab91 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_preview/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_preview/models/_models_py3.py @@ -1,23 +1,24 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.serialization import Model -from msrest.exceptions import HttpOperationError +import datetime +from typing import Dict, List, Optional, Union +from azure.core.exceptions import HttpResponseError +import msrest.serialization -class AzureResourceBase(Model): +from ._deployment_scripts_client_enums import * + + +class AzureResourceBase(msrest.serialization.Model): """Common properties for all Azure resources. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: String Id used to locate any resource on Azure. :vartype id: str @@ -39,7 +40,10 @@ class AzureResourceBase(Model): 'type': {'key': 'type', 'type': 'str'}, } - def __init__(self, **kwargs) -> None: + def __init__( + self, + **kwargs + ): super(AzureResourceBase, self).__init__(**kwargs) self.id = None self.name = None @@ -50,10 +54,9 @@ class DeploymentScript(AzureResourceBase): """Deployment script object. You probably want to use the sub-classes and not this class directly. Known - sub-classes are: AzurePowerShellScript, AzureCliScript + sub-classes are: AzureCliScript, AzurePowerShellScript. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. @@ -63,20 +66,20 @@ 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, only user-assigned MSI is supported. + :param identity: Required. Managed identity to be used for this deployment script. Currently, + only user-assigned MSI is supported. :type identity: ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.ManagedServiceIdentity - :param location: Required. The location of the ACI and the storage account - for the deployment script. + :param location: Required. The location of the ACI and the storage account for the deployment + script. :type location: str - :param tags: Resource tags. + :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: + "AzurePowerShell", "AzureCLI". + :type kind: str or ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.ScriptType :ivar system_data: The system metadata related to this resource. - :vartype system_data: - ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.SystemData - :param kind: Required. Constant filled by server. - :type kind: str + :vartype system_data: ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.SystemData """ _validation = { @@ -85,8 +88,8 @@ class DeploymentScript(AzureResourceBase): 'type': {'readonly': True}, 'identity': {'required': True}, 'location': {'required': True}, - 'system_data': {'readonly': True}, 'kind': {'required': True}, + 'system_data': {'readonly': True}, } _attribute_map = { @@ -96,29 +99,34 @@ class DeploymentScript(AzureResourceBase): 'identity': {'key': 'identity', 'type': 'ManagedServiceIdentity'}, 'location': {'key': 'location', 'type': 'str'}, 'tags': {'key': 'tags', 'type': '{str}'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, 'kind': {'key': 'kind', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, } _subtype_map = { - 'kind': {'AzurePowerShell': 'AzurePowerShellScript', 'AzureCLI': 'AzureCliScript'} + 'kind': {'AzureCLI': 'AzureCliScript', 'AzurePowerShell': 'AzurePowerShellScript'} } - def __init__(self, *, identity, location: str, tags=None, **kwargs) -> None: + def __init__( + self, + *, + identity: "ManagedServiceIdentity", + location: str, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): super(DeploymentScript, self).__init__(**kwargs) self.identity = identity self.location = location self.tags = tags + self.kind: str = 'DeploymentScript' self.system_data = None - self.kind = None - self.kind = 'DeploymentScript' class AzureCliScript(DeploymentScript): """Object model for the Azure CLI script. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. @@ -128,64 +136,62 @@ 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, only user-assigned MSI is supported. + :param identity: Required. Managed identity to be used for this deployment script. Currently, + only user-assigned MSI is supported. :type identity: ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.ManagedServiceIdentity - :param location: Required. The location of the ACI and the storage account - for the deployment script. + :param location: Required. The location of the ACI and the storage account for the deployment + script. :type location: str - :param tags: Resource tags. + :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: + "AzurePowerShell", "AzureCLI". + :type kind: str or ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.ScriptType :ivar system_data: The system metadata related to this resource. - :vartype system_data: - ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.SystemData - :param kind: Required. Constant filled by server. - :type kind: str + :vartype system_data: ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.SystemData :param container_settings: Container settings. :type container_settings: ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.ContainerConfiguration - :param 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' + :param storage_account_settings: Storage Account settings. + :type storage_account_settings: + ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.StorageAccountConfiguration + :param 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". :type cleanup_preference: str or ~azure.mgmt.resource.deploymentscripts.v2019_10_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', 'Canceled' + :ivar provisioning_state: State of the script execution. This only appears in the response. + Possible values include: "Creating", "ProvisioningResources", "Running", "Succeeded", "Failed", + "Canceled". :vartype provisioning_state: str or ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.ScriptProvisioningState :ivar status: Contains the results of script execution. - :vartype status: - ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.ScriptStatus + :vartype status: ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.ScriptStatus :ivar outputs: List of script outputs. :vartype outputs: dict[str, object] - :param primary_script_uri: Uri for the script. This is the entry point for - the external script. + :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 spaces. ex: -Name blue* -Location 'West US 2' + :param 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. + :param environment_variables: The environment variables to pass over to the script. :type environment_variables: list[~azure.mgmt.resource.deploymentscripts.v2019_10_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. + :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 after it reaches a terminal state. Resource - will be deleted when this duration expires. Duration is based on ISO 8601 - pattern (for example P7D means one week). - :type retention_interval: timedelta - :param timeout: Maximum allowed script execution time specified in ISO - 8601 format. Default value is PT1H - :type timeout: timedelta + :param 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 P7D means one week). + :type retention_interval: ~datetime.timedelta + :param timeout: Maximum allowed script execution time specified in ISO 8601 format. Default + value is PT1H. + :type timeout: ~datetime.timedelta :param az_cli_version: Required. Azure CLI module version to be used. :type az_cli_version: str """ @@ -196,12 +202,12 @@ class AzureCliScript(DeploymentScript): 'type': {'readonly': True}, 'identity': {'required': True}, 'location': {'required': True}, - 'system_data': {'readonly': True}, 'kind': {'required': True}, + 'system_data': {'readonly': True}, 'provisioning_state': {'readonly': True}, 'status': {'readonly': True}, 'outputs': {'readonly': True}, - 'script_content': {'max_length': 32000}, + 'script_content': {'max_length': 32000, 'min_length': 0}, 'retention_interval': {'required': True}, 'az_cli_version': {'required': True}, } @@ -213,9 +219,10 @@ class AzureCliScript(DeploymentScript): 'identity': {'key': 'identity', 'type': 'ManagedServiceIdentity'}, 'location': {'key': 'location', 'type': 'str'}, 'tags': {'key': 'tags', 'type': '{str}'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, 'kind': {'key': 'kind', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, 'container_settings': {'key': 'properties.containerSettings', 'type': 'ContainerConfiguration'}, + 'storage_account_settings': {'key': 'properties.storageAccountSettings', 'type': 'StorageAccountConfiguration'}, 'cleanup_preference': {'key': 'properties.cleanupPreference', 'type': 'str'}, 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, 'status': {'key': 'properties.status', 'type': 'ScriptStatus'}, @@ -231,13 +238,271 @@ class AzureCliScript(DeploymentScript): 'az_cli_version': {'key': 'properties.azCliVersion', 'type': 'str'}, } - def __init__(self, *, identity, location: str, retention_interval, az_cli_version: str, tags=None, container_settings=None, cleanup_preference=None, primary_script_uri: str=None, supporting_script_uris=None, script_content: str=None, arguments: str=None, environment_variables=None, force_update_tag: str=None, timeout=None, **kwargs) -> None: + def __init__( + self, + *, + identity: "ManagedServiceIdentity", + location: str, + retention_interval: datetime.timedelta, + az_cli_version: str, + tags: Optional[Dict[str, str]] = None, + container_settings: Optional["ContainerConfiguration"] = None, + storage_account_settings: Optional["StorageAccountConfiguration"] = None, + cleanup_preference: Optional[Union[str, "CleanupOptions"]] = None, + primary_script_uri: Optional[str] = None, + supporting_script_uris: Optional[List[str]] = None, + script_content: Optional[str] = None, + arguments: Optional[str] = None, + environment_variables: Optional[List["EnvironmentVariable"]] = None, + force_update_tag: Optional[str] = None, + timeout: Optional[datetime.timedelta] = None, + **kwargs + ): super(AzureCliScript, self).__init__(identity=identity, location=location, tags=tags, **kwargs) + self.kind: str = 'AzureCLI' + self.container_settings = container_settings + self.storage_account_settings = storage_account_settings + self.cleanup_preference = cleanup_preference + self.provisioning_state = None + self.status = None + self.outputs = None + self.primary_script_uri = primary_script_uri + self.supporting_script_uris = supporting_script_uris + self.script_content = script_content + self.arguments = arguments + self.environment_variables = environment_variables + self.force_update_tag = force_update_tag + self.retention_interval = retention_interval + self.timeout = timeout + self.az_cli_version = az_cli_version + + +class ScriptConfigurationBase(msrest.serialization.Model): + """Common configuration settings for both Azure PowerShell and Azure CLI scripts. + + 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 + 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: + list[~azure.mgmt.resource.deploymentscripts.v2019_10_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 + after it reaches a terminal state. Resource will be deleted when this duration expires. + Duration is based on ISO 8601 pattern (for example P7D means one week). + :type retention_interval: ~datetime.timedelta + :param timeout: Maximum allowed script execution time specified in ISO 8601 format. Default + value is PT1H. + :type timeout: ~datetime.timedelta + """ + + _validation = { + 'script_content': {'max_length': 32000, 'min_length': 0}, + 'retention_interval': {'required': True}, + } + + _attribute_map = { + 'primary_script_uri': {'key': 'primaryScriptUri', 'type': 'str'}, + 'supporting_script_uris': {'key': 'supportingScriptUris', 'type': '[str]'}, + 'script_content': {'key': 'scriptContent', 'type': 'str'}, + 'arguments': {'key': 'arguments', 'type': 'str'}, + 'environment_variables': {'key': 'environmentVariables', 'type': '[EnvironmentVariable]'}, + 'force_update_tag': {'key': 'forceUpdateTag', 'type': 'str'}, + 'retention_interval': {'key': 'retentionInterval', 'type': 'duration'}, + 'timeout': {'key': 'timeout', 'type': 'duration'}, + } + + def __init__( + self, + *, + retention_interval: datetime.timedelta, + primary_script_uri: Optional[str] = None, + supporting_script_uris: Optional[List[str]] = None, + script_content: Optional[str] = None, + arguments: Optional[str] = None, + environment_variables: Optional[List["EnvironmentVariable"]] = None, + force_update_tag: Optional[str] = None, + timeout: Optional[datetime.timedelta] = None, + **kwargs + ): + super(ScriptConfigurationBase, self).__init__(**kwargs) + self.primary_script_uri = primary_script_uri + self.supporting_script_uris = supporting_script_uris + self.script_content = script_content + self.arguments = arguments + self.environment_variables = environment_variables + self.force_update_tag = force_update_tag + self.retention_interval = retention_interval + self.timeout = timeout + + +class DeploymentScriptPropertiesBase(msrest.serialization.Model): + """Common properties for the deployment script. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param container_settings: Container settings. + :type container_settings: + ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.ContainerConfiguration + :param storage_account_settings: Storage Account settings. + :type storage_account_settings: + ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.StorageAccountConfiguration + :param 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". + :type cleanup_preference: str or + ~azure.mgmt.resource.deploymentscripts.v2019_10_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", + "Canceled". + :vartype provisioning_state: str or + ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.ScriptProvisioningState + :ivar status: Contains the results of script execution. + :vartype status: ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.ScriptStatus + :ivar outputs: List of script outputs. + :vartype outputs: dict[str, object] + """ + + _validation = { + 'provisioning_state': {'readonly': True}, + 'status': {'readonly': True}, + 'outputs': {'readonly': True}, + } + + _attribute_map = { + 'container_settings': {'key': 'containerSettings', 'type': 'ContainerConfiguration'}, + 'storage_account_settings': {'key': 'storageAccountSettings', 'type': 'StorageAccountConfiguration'}, + 'cleanup_preference': {'key': 'cleanupPreference', 'type': 'str'}, + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'ScriptStatus'}, + 'outputs': {'key': 'outputs', 'type': '{object}'}, + } + + def __init__( + self, + *, + container_settings: Optional["ContainerConfiguration"] = None, + storage_account_settings: Optional["StorageAccountConfiguration"] = None, + cleanup_preference: Optional[Union[str, "CleanupOptions"]] = None, + **kwargs + ): + super(DeploymentScriptPropertiesBase, self).__init__(**kwargs) self.container_settings = container_settings + self.storage_account_settings = storage_account_settings self.cleanup_preference = cleanup_preference self.provisioning_state = None self.status = None self.outputs = None + + +class AzureCliScriptProperties(DeploymentScriptPropertiesBase, ScriptConfigurationBase): + """Properties of the Azure CLI script object. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :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 + 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: + list[~azure.mgmt.resource.deploymentscripts.v2019_10_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 + after it reaches a terminal state. Resource will be deleted when this duration expires. + Duration is based on ISO 8601 pattern (for example P7D means one week). + :type retention_interval: ~datetime.timedelta + :param timeout: Maximum allowed script execution time specified in ISO 8601 format. Default + value is PT1H. + :type timeout: ~datetime.timedelta + :param container_settings: Container settings. + :type container_settings: + ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.ContainerConfiguration + :param storage_account_settings: Storage Account settings. + :type storage_account_settings: + ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.StorageAccountConfiguration + :param 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". + :type cleanup_preference: str or + ~azure.mgmt.resource.deploymentscripts.v2019_10_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", + "Canceled". + :vartype provisioning_state: str or + ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.ScriptProvisioningState + :ivar status: Contains the results of script execution. + :vartype status: ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.ScriptStatus + :ivar outputs: List of script outputs. + :vartype outputs: dict[str, object] + :param az_cli_version: Required. Azure CLI module version to be used. + :type az_cli_version: str + """ + + _validation = { + 'script_content': {'max_length': 32000, 'min_length': 0}, + 'retention_interval': {'required': True}, + 'provisioning_state': {'readonly': True}, + 'status': {'readonly': True}, + 'outputs': {'readonly': True}, + 'az_cli_version': {'required': True}, + } + + _attribute_map = { + 'primary_script_uri': {'key': 'primaryScriptUri', 'type': 'str'}, + 'supporting_script_uris': {'key': 'supportingScriptUris', 'type': '[str]'}, + 'script_content': {'key': 'scriptContent', 'type': 'str'}, + 'arguments': {'key': 'arguments', 'type': 'str'}, + 'environment_variables': {'key': 'environmentVariables', 'type': '[EnvironmentVariable]'}, + 'force_update_tag': {'key': 'forceUpdateTag', 'type': 'str'}, + 'retention_interval': {'key': 'retentionInterval', 'type': 'duration'}, + 'timeout': {'key': 'timeout', 'type': 'duration'}, + 'container_settings': {'key': 'containerSettings', 'type': 'ContainerConfiguration'}, + 'storage_account_settings': {'key': 'storageAccountSettings', 'type': 'StorageAccountConfiguration'}, + 'cleanup_preference': {'key': 'cleanupPreference', 'type': 'str'}, + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'ScriptStatus'}, + 'outputs': {'key': 'outputs', 'type': '{object}'}, + 'az_cli_version': {'key': 'azCliVersion', 'type': 'str'}, + } + + def __init__( + self, + *, + retention_interval: datetime.timedelta, + az_cli_version: str, + primary_script_uri: Optional[str] = None, + supporting_script_uris: Optional[List[str]] = None, + script_content: Optional[str] = None, + arguments: Optional[str] = None, + environment_variables: Optional[List["EnvironmentVariable"]] = None, + force_update_tag: Optional[str] = None, + timeout: Optional[datetime.timedelta] = None, + container_settings: Optional["ContainerConfiguration"] = None, + storage_account_settings: Optional["StorageAccountConfiguration"] = None, + cleanup_preference: Optional[Union[str, "CleanupOptions"]] = None, + **kwargs + ): + 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 self.script_content = script_content @@ -247,14 +512,19 @@ def __init__(self, *, identity, location: str, retention_interval, az_cli_versio self.retention_interval = retention_interval self.timeout = timeout self.az_cli_version = az_cli_version - self.kind = 'AzureCLI' + self.container_settings = container_settings + self.storage_account_settings = storage_account_settings + self.cleanup_preference = cleanup_preference + self.provisioning_state = None + self.status = None + self.outputs = None + self.az_cli_version = az_cli_version class AzurePowerShellScript(DeploymentScript): """Object model for the Azure PowerShell script. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. @@ -264,66 +534,63 @@ 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, only user-assigned MSI is supported. + :param identity: Required. Managed identity to be used for this deployment script. Currently, + only user-assigned MSI is supported. :type identity: ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.ManagedServiceIdentity - :param location: Required. The location of the ACI and the storage account - for the deployment script. + :param location: Required. The location of the ACI and the storage account for the deployment + script. :type location: str - :param tags: Resource tags. + :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: + "AzurePowerShell", "AzureCLI". + :type kind: str or ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.ScriptType :ivar system_data: The system metadata related to this resource. - :vartype system_data: - ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.SystemData - :param kind: Required. Constant filled by server. - :type kind: str + :vartype system_data: ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.SystemData :param container_settings: Container settings. :type container_settings: ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.ContainerConfiguration - :param 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' + :param storage_account_settings: Storage Account settings. + :type storage_account_settings: + ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.StorageAccountConfiguration + :param 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". :type cleanup_preference: str or ~azure.mgmt.resource.deploymentscripts.v2019_10_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', 'Canceled' + :ivar provisioning_state: State of the script execution. This only appears in the response. + Possible values include: "Creating", "ProvisioningResources", "Running", "Succeeded", "Failed", + "Canceled". :vartype provisioning_state: str or ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.ScriptProvisioningState :ivar status: Contains the results of script execution. - :vartype status: - ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.ScriptStatus + :vartype status: ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.ScriptStatus :ivar outputs: List of script outputs. :vartype outputs: dict[str, object] - :param primary_script_uri: Uri for the script. This is the entry point for - the external script. + :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 spaces. ex: -Name blue* -Location 'West US 2' + :param 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. + :param environment_variables: The environment variables to pass over to the script. :type environment_variables: list[~azure.mgmt.resource.deploymentscripts.v2019_10_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. + :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 after it reaches a terminal state. Resource - will be deleted when this duration expires. Duration is based on ISO 8601 - pattern (for example P7D means one week). - :type retention_interval: timedelta - :param timeout: Maximum allowed script execution time specified in ISO - 8601 format. Default value is PT1H - :type timeout: timedelta - :param az_power_shell_version: Required. Azure PowerShell module version - to be used. + :param 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 P7D means one week). + :type retention_interval: ~datetime.timedelta + :param timeout: Maximum allowed script execution time specified in ISO 8601 format. Default + value is PT1H. + :type timeout: ~datetime.timedelta + :param az_power_shell_version: Required. Azure PowerShell module version to be used. :type az_power_shell_version: str """ @@ -333,12 +600,12 @@ class AzurePowerShellScript(DeploymentScript): 'type': {'readonly': True}, 'identity': {'required': True}, 'location': {'required': True}, - 'system_data': {'readonly': True}, 'kind': {'required': True}, + 'system_data': {'readonly': True}, 'provisioning_state': {'readonly': True}, 'status': {'readonly': True}, 'outputs': {'readonly': True}, - 'script_content': {'max_length': 32000}, + 'script_content': {'max_length': 32000, 'min_length': 0}, 'retention_interval': {'required': True}, 'az_power_shell_version': {'required': True}, } @@ -350,9 +617,10 @@ class AzurePowerShellScript(DeploymentScript): 'identity': {'key': 'identity', 'type': 'ManagedServiceIdentity'}, 'location': {'key': 'location', 'type': 'str'}, 'tags': {'key': 'tags', 'type': '{str}'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, 'kind': {'key': 'kind', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, 'container_settings': {'key': 'properties.containerSettings', 'type': 'ContainerConfiguration'}, + 'storage_account_settings': {'key': 'properties.storageAccountSettings', 'type': 'StorageAccountConfiguration'}, 'cleanup_preference': {'key': 'properties.cleanupPreference', 'type': 'str'}, 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, 'status': {'key': 'properties.status', 'type': 'ScriptStatus'}, @@ -368,9 +636,30 @@ class AzurePowerShellScript(DeploymentScript): 'az_power_shell_version': {'key': 'properties.azPowerShellVersion', 'type': 'str'}, } - def __init__(self, *, identity, location: str, retention_interval, az_power_shell_version: str, tags=None, container_settings=None, cleanup_preference=None, primary_script_uri: str=None, supporting_script_uris=None, script_content: str=None, arguments: str=None, environment_variables=None, force_update_tag: str=None, timeout=None, **kwargs) -> None: + def __init__( + self, + *, + identity: "ManagedServiceIdentity", + location: str, + retention_interval: datetime.timedelta, + az_power_shell_version: str, + tags: Optional[Dict[str, str]] = None, + container_settings: Optional["ContainerConfiguration"] = None, + storage_account_settings: Optional["StorageAccountConfiguration"] = None, + cleanup_preference: Optional[Union[str, "CleanupOptions"]] = None, + primary_script_uri: Optional[str] = None, + supporting_script_uris: Optional[List[str]] = None, + script_content: Optional[str] = None, + arguments: Optional[str] = None, + environment_variables: Optional[List["EnvironmentVariable"]] = None, + force_update_tag: Optional[str] = None, + timeout: Optional[datetime.timedelta] = None, + **kwargs + ): super(AzurePowerShellScript, self).__init__(identity=identity, location=location, tags=tags, **kwargs) + self.kind: str = 'AzurePowerShell' self.container_settings = container_settings + self.storage_account_settings = storage_account_settings self.cleanup_preference = cleanup_preference self.provisioning_state = None self.status = None @@ -384,161 +673,250 @@ def __init__(self, *, identity, location: str, retention_interval, az_power_shel self.retention_interval = retention_interval self.timeout = timeout self.az_power_shell_version = az_power_shell_version - self.kind = 'AzurePowerShell' - - -class CloudError(Model): - """CloudError. - """ - - _attribute_map = { - } -class ContainerConfiguration(Model): - """Settings to customize ACI container instance. +class AzurePowerShellScriptProperties(DeploymentScriptPropertiesBase, ScriptConfigurationBase): + """Properties of the Azure PowerShell script object. - :param 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. - :type container_group_name: str - """ + Variables are only populated by the server, and will be ignored when sending a request. - _validation = { - 'container_group_name': {'max_length': 63, 'min_length': 1}, - } - - _attribute_map = { - 'container_group_name': {'key': 'containerGroupName', 'type': 'str'}, - } - - def __init__(self, *, container_group_name: str=None, **kwargs) -> None: - super(ContainerConfiguration, self).__init__(**kwargs) - self.container_group_name = container_group_name - - -class DeploymentScriptPropertiesBase(Model): - """Common properties for the deployment script. - - Variables are only populated by the server, and will be ignored when - sending a request. + All required parameters must be populated in order to send to Azure. + :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 + 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: + list[~azure.mgmt.resource.deploymentscripts.v2019_10_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 + after it reaches a terminal state. Resource will be deleted when this duration expires. + Duration is based on ISO 8601 pattern (for example P7D means one week). + :type retention_interval: ~datetime.timedelta + :param timeout: Maximum allowed script execution time specified in ISO 8601 format. Default + value is PT1H. + :type timeout: ~datetime.timedelta :param container_settings: Container settings. :type container_settings: ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.ContainerConfiguration - :param 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' + :param storage_account_settings: Storage Account settings. + :type storage_account_settings: + ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.StorageAccountConfiguration + :param 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". :type cleanup_preference: str or ~azure.mgmt.resource.deploymentscripts.v2019_10_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', 'Canceled' + :ivar provisioning_state: State of the script execution. This only appears in the response. + Possible values include: "Creating", "ProvisioningResources", "Running", "Succeeded", "Failed", + "Canceled". :vartype provisioning_state: str or ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.ScriptProvisioningState :ivar status: Contains the results of script execution. - :vartype status: - ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.ScriptStatus + :vartype status: ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.ScriptStatus :ivar outputs: List of script outputs. :vartype outputs: dict[str, object] + :param az_power_shell_version: Required. Azure PowerShell module version to be used. + :type az_power_shell_version: str """ _validation = { + 'script_content': {'max_length': 32000, 'min_length': 0}, + 'retention_interval': {'required': True}, 'provisioning_state': {'readonly': True}, 'status': {'readonly': True}, 'outputs': {'readonly': True}, + 'az_power_shell_version': {'required': True}, } _attribute_map = { + 'primary_script_uri': {'key': 'primaryScriptUri', 'type': 'str'}, + 'supporting_script_uris': {'key': 'supportingScriptUris', 'type': '[str]'}, + 'script_content': {'key': 'scriptContent', 'type': 'str'}, + 'arguments': {'key': 'arguments', 'type': 'str'}, + 'environment_variables': {'key': 'environmentVariables', 'type': '[EnvironmentVariable]'}, + 'force_update_tag': {'key': 'forceUpdateTag', 'type': 'str'}, + 'retention_interval': {'key': 'retentionInterval', 'type': 'duration'}, + 'timeout': {'key': 'timeout', 'type': 'duration'}, 'container_settings': {'key': 'containerSettings', 'type': 'ContainerConfiguration'}, + 'storage_account_settings': {'key': 'storageAccountSettings', 'type': 'StorageAccountConfiguration'}, 'cleanup_preference': {'key': 'cleanupPreference', 'type': 'str'}, 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, 'status': {'key': 'status', 'type': 'ScriptStatus'}, 'outputs': {'key': 'outputs', 'type': '{object}'}, + 'az_power_shell_version': {'key': 'azPowerShellVersion', 'type': 'str'}, } - def __init__(self, *, container_settings=None, cleanup_preference=None, **kwargs) -> None: - super(DeploymentScriptPropertiesBase, self).__init__(**kwargs) + def __init__( + self, + *, + retention_interval: datetime.timedelta, + az_power_shell_version: str, + primary_script_uri: Optional[str] = None, + supporting_script_uris: Optional[List[str]] = None, + script_content: Optional[str] = None, + arguments: Optional[str] = None, + environment_variables: Optional[List["EnvironmentVariable"]] = None, + force_update_tag: Optional[str] = None, + timeout: Optional[datetime.timedelta] = None, + container_settings: Optional["ContainerConfiguration"] = None, + storage_account_settings: Optional["StorageAccountConfiguration"] = None, + cleanup_preference: Optional[Union[str, "CleanupOptions"]] = None, + **kwargs + ): + 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 + self.script_content = script_content + self.arguments = arguments + self.environment_variables = environment_variables + self.force_update_tag = force_update_tag + self.retention_interval = retention_interval + self.timeout = timeout + self.az_power_shell_version = az_power_shell_version self.container_settings = container_settings + self.storage_account_settings = storage_account_settings self.cleanup_preference = cleanup_preference self.provisioning_state = None self.status = None self.outputs = None + self.az_power_shell_version = az_power_shell_version -class DeploymentScriptUpdateParameter(AzureResourceBase): - """Deployment script parameters to be updated. . +class ContainerConfiguration(msrest.serialization.Model): + """Settings to customize ACI container instance. - Variables are only populated by the server, and will be ignored when - sending a request. + :param 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. + :type container_group_name: str + """ - :ivar id: String Id used to locate any resource on Azure. - :vartype id: str - :ivar name: Name of this resource. - :vartype name: str - :ivar type: Type of this resource. - :vartype type: str - :param tags: Resource tags to be updated. - :type tags: dict[str, str] + _validation = { + 'container_group_name': {'max_length': 63, 'min_length': 1}, + } + + _attribute_map = { + 'container_group_name': {'key': 'containerGroupName', 'type': 'str'}, + } + + def __init__( + self, + *, + container_group_name: Optional[str] = None, + **kwargs + ): + super(ContainerConfiguration, self).__init__(**kwargs) + self.container_group_name = container_group_name + + +class DeploymentScriptListResult(msrest.serialization.Model): + """List of deployment scripts. + + 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.v2019_10_preview.models.DeploymentScript] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + 'next_link': {'readonly': True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + 'value': {'key': 'value', 'type': '[DeploymentScript]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, } - def __init__(self, *, tags=None, **kwargs) -> None: - super(DeploymentScriptUpdateParameter, self).__init__(**kwargs) - self.tags = tags + def __init__( + self, + *, + value: Optional[List["DeploymentScript"]] = None, + **kwargs + ): + super(DeploymentScriptListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None -class DeploymentScriptsError(Model): +class DeploymentScriptsError(msrest.serialization.Model): """Deployment scripts error response. - :param error: - :type error: - ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.ErrorResponse + :param error: The resource management error response. + :type error: ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.ErrorResponse """ _attribute_map = { 'error': {'key': 'error', 'type': 'ErrorResponse'}, } - def __init__(self, *, error=None, **kwargs) -> None: + def __init__( + self, + *, + error: Optional["ErrorResponse"] = None, + **kwargs + ): super(DeploymentScriptsError, self).__init__(**kwargs) self.error = error -class DeploymentScriptsErrorException(HttpOperationError): - """Server responsed with exception of type: 'DeploymentScriptsError'. +class DeploymentScriptUpdateParameter(AzureResourceBase): + """Deployment script parameters to be updated. + + Variables are only populated by the server, and will be ignored when sending a request. - :param deserialize: A deserializer - :param response: Server response to be deserialized. + :ivar id: String Id used to locate any resource on Azure. + :vartype id: str + :ivar name: Name of this resource. + :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] """ - def __init__(self, deserialize, response, *args): + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } - super(DeploymentScriptsErrorException, self).__init__(deserialize, response, 'DeploymentScriptsError', *args) + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + super(DeploymentScriptUpdateParameter, self).__init__(**kwargs) + self.tags = tags -class EnvironmentVariable(Model): +class EnvironmentVariable(msrest.serialization.Model): """The environment variable to pass to the script in the container instance. All required parameters must be populated in order to send to Azure. @@ -561,18 +939,24 @@ class EnvironmentVariable(Model): 'secure_value': {'key': 'secureValue', 'type': 'str'}, } - def __init__(self, *, name: str, value: str=None, secure_value: str=None, **kwargs) -> None: + def __init__( + self, + *, + name: str, + value: Optional[str] = None, + secure_value: Optional[str] = None, + **kwargs + ): super(EnvironmentVariable, self).__init__(**kwargs) self.name = name self.value = value self.secure_value = secure_value -class ErrorAdditionalInfo(Model): +class ErrorAdditionalInfo(msrest.serialization.Model): """The resource management error additional info. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar type: The additional info type. :vartype type: str @@ -590,17 +974,19 @@ class ErrorAdditionalInfo(Model): 'info': {'key': 'info', 'type': 'object'}, } - def __init__(self, **kwargs) -> None: + def __init__( + self, + **kwargs + ): super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None -class ErrorResponse(Model): +class ErrorResponse(msrest.serialization.Model): """The resource management error response. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar code: The error code. :vartype code: str @@ -632,7 +1018,10 @@ class ErrorResponse(Model): 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, } - def __init__(self, **kwargs) -> None: + def __init__( + self, + **kwargs + ): super(ErrorResponse, self).__init__(**kwargs) self.code = None self.message = None @@ -641,98 +1030,44 @@ def __init__(self, **kwargs) -> None: self.additional_info = None -class ManagedServiceIdentity(Model): +class ManagedServiceIdentity(msrest.serialization.Model): """Managed identity generic object. - :param type: Type of the managed identity. Possible values include: - 'UserAssigned' - :type type: str or - ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.ManagedServiceIdentityType - :param user_assigned_identities: The list of user-assigned managed - identities associated with the resource. Key is the Azure resource Id of - the managed identity. + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar type: Type of the managed identity. Default value: "UserAssigned". + :vartype type: str + :param 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, ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.UserAssignedIdentity] """ + _validation = { + 'type': {'constant': True}, + } + _attribute_map = { 'type': {'key': 'type', 'type': 'str'}, 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{UserAssignedIdentity}'}, } - def __init__(self, *, type=None, user_assigned_identities=None, **kwargs) -> None: + type = "UserAssigned" + + def __init__( + self, + *, + user_assigned_identities: Optional[Dict[str, "UserAssignedIdentity"]] = None, + **kwargs + ): super(ManagedServiceIdentity, self).__init__(**kwargs) - self.type = type self.user_assigned_identities = user_assigned_identities -class ScriptConfigurationBase(Model): - """Common configuration settings for both Azure PowerShell and Azure CLI - scripts. - - 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 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: - list[~azure.mgmt.resource.deploymentscripts.v2019_10_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 after it reaches a terminal state. Resource - will be deleted when this duration expires. Duration is based on ISO 8601 - pattern (for example P7D means one week). - :type retention_interval: timedelta - :param timeout: Maximum allowed script execution time specified in ISO - 8601 format. Default value is PT1H - :type timeout: timedelta - """ - - _validation = { - 'script_content': {'max_length': 32000}, - 'retention_interval': {'required': True}, - } - - _attribute_map = { - 'primary_script_uri': {'key': 'primaryScriptUri', 'type': 'str'}, - 'supporting_script_uris': {'key': 'supportingScriptUris', 'type': '[str]'}, - 'script_content': {'key': 'scriptContent', 'type': 'str'}, - 'arguments': {'key': 'arguments', 'type': 'str'}, - 'environment_variables': {'key': 'environmentVariables', 'type': '[EnvironmentVariable]'}, - 'force_update_tag': {'key': 'forceUpdateTag', 'type': 'str'}, - 'retention_interval': {'key': 'retentionInterval', 'type': 'duration'}, - 'timeout': {'key': 'timeout', 'type': 'duration'}, - } - - def __init__(self, *, retention_interval, primary_script_uri: str=None, supporting_script_uris=None, script_content: str=None, arguments: str=None, environment_variables=None, force_update_tag: str=None, timeout=None, **kwargs) -> None: - super(ScriptConfigurationBase, self).__init__(**kwargs) - self.primary_script_uri = primary_script_uri - self.supporting_script_uris = supporting_script_uris - self.script_content = script_content - self.arguments = arguments - self.environment_variables = environment_variables - self.force_update_tag = force_update_tag - self.retention_interval = retention_interval - self.timeout = timeout - - class ScriptLog(AzureResourceBase): """Script execution log object. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: String Id used to locate any resource on Azure. :vartype id: str @@ -758,47 +1093,52 @@ class ScriptLog(AzureResourceBase): 'log': {'key': 'properties.log', 'type': 'str'}, } - def __init__(self, **kwargs) -> None: + def __init__( + self, + **kwargs + ): super(ScriptLog, self).__init__(**kwargs) self.log = None -class ScriptLogsList(Model): +class ScriptLogsList(msrest.serialization.Model): """Deployment script execution logs. :param value: Deployment scripts logs. - :type value: - list[~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.ScriptLog] + :type value: list[~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.ScriptLog] """ _attribute_map = { 'value': {'key': 'value', 'type': '[ScriptLog]'}, } - def __init__(self, *, value=None, **kwargs) -> None: + def __init__( + self, + *, + value: Optional[List["ScriptLog"]] = None, + **kwargs + ): super(ScriptLogsList, self).__init__(**kwargs) self.value = value -class ScriptStatus(Model): +class ScriptStatus(msrest.serialization.Model): """Generic object modeling results of script execution. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar container_instance_id: ACI resource Id. :vartype container_instance_id: str :ivar storage_account_id: Storage account resource Id. :vartype storage_account_id: str :ivar start_time: Start time of the script execution. - :vartype start_time: datetime + :vartype start_time: ~datetime.datetime :ivar end_time: End time of the script execution. - :vartype end_time: datetime + :vartype end_time: ~datetime.datetime :ivar expiration_time: Time the deployment script resource will expire. - :vartype expiration_time: datetime + :vartype expiration_time: ~datetime.datetime :param error: Error that is relayed from the script execution. - :type error: - ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.ErrorResponse + :type error: ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.ErrorResponse """ _validation = { @@ -818,7 +1158,12 @@ class ScriptStatus(Model): 'error': {'key': 'error', 'type': 'ErrorResponse'}, } - def __init__(self, *, error=None, **kwargs) -> None: + def __init__( + self, + *, + error: Optional["ErrorResponse"] = None, + **kwargs + ): super(ScriptStatus, self).__init__(**kwargs) self.container_instance_id = None self.storage_account_id = None @@ -828,27 +1173,51 @@ def __init__(self, *, error=None, **kwargs) -> None: self.error = error -class SystemData(Model): +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 + """ + + _attribute_map = { + 'storage_account_name': {'key': 'storageAccountName', 'type': 'str'}, + 'storage_account_key': {'key': 'storageAccountKey', 'type': 'str'}, + } + + def __init__( + self, + *, + storage_account_name: Optional[str] = None, + storage_account_key: Optional[str] = None, + **kwargs + ): + super(StorageAccountConfiguration, self).__init__(**kwargs) + self.storage_account_name = storage_account_name + self.storage_account_key = storage_account_key + + +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' + :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.deploymentscripts.v2019_10_preview.models.CreatedByType :param created_at: The timestamp of resource creation (UTC). - :type created_at: datetime + :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 values include: 'User', 'Application', - 'ManagedIdentity', 'Key' + :param 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 ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.CreatedByType - :param last_modified_at: The type of identity that last modified the - resource. - :type last_modified_at: datetime + :param last_modified_at: The type of identity that last modified the resource. + :type last_modified_at: ~datetime.datetime """ _attribute_map = { @@ -860,7 +1229,17 @@ class SystemData(Model): 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, } - def __init__(self, *, created_by: str=None, created_by_type=None, created_at=None, last_modified_by: str=None, last_modified_by_type=None, last_modified_at=None, **kwargs) -> None: + def __init__( + self, + *, + created_by: Optional[str] = None, + created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "CreatedByType"]] = None, + last_modified_at: Optional[datetime.datetime] = None, + **kwargs + ): super(SystemData, self).__init__(**kwargs) self.created_by = created_by self.created_by_type = created_by_type @@ -870,11 +1249,10 @@ def __init__(self, *, created_by: str=None, created_by_type=None, created_at=Non self.last_modified_at = last_modified_at -class UserAssignedIdentity(Model): +class UserAssignedIdentity(msrest.serialization.Model): """User-assigned managed identity. - :param principal_id: Azure Active Directory principal ID associated with - this identity. + :param principal_id: Azure Active Directory principal ID associated with this identity. :type principal_id: str :param client_id: Client App Id associated with this identity. :type client_id: str @@ -885,7 +1263,13 @@ class UserAssignedIdentity(Model): 'client_id': {'key': 'clientId', 'type': 'str'}, } - def __init__(self, *, principal_id: str=None, client_id: str=None, **kwargs) -> None: + def __init__( + self, + *, + principal_id: Optional[str] = None, + client_id: Optional[str] = None, + **kwargs + ): super(UserAssignedIdentity, self).__init__(**kwargs) self.principal_id = principal_id self.client_id = client_id diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_preview/models/_paged_models.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_preview/models/_paged_models.py deleted file mode 100644 index 7ff65ddb6503..000000000000 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_preview/models/_paged_models.py +++ /dev/null @@ -1,27 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.paging import Paged - - -class DeploymentScriptPaged(Paged): - """ - A paging container for iterating over a list of :class:`DeploymentScript ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[DeploymentScript]'} - } - - def __init__(self, *args, **kwargs): - - super(DeploymentScriptPaged, self).__init__(*args, **kwargs) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_preview/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_preview/operations/__init__.py index 3868bac365a6..6861ff42dee7 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_preview/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_preview/operations/__init__.py @@ -1,12 +1,9 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from ._deployment_scripts_operations import DeploymentScriptsOperations diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_preview/operations/_deployment_scripts_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_preview/operations/_deployment_scripts_operations.py index 50e329420559..f9b2df498b5f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_preview/operations/_deployment_scripts_operations.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_preview/operations/_deployment_scripts_operations.py @@ -1,600 +1,600 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrest.polling import LROPoller, NoPolling -from msrestazure.polling.arm_polling import ARMPolling +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class DeploymentScriptsOperations(object): """DeploymentScriptsOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: Client Api version. Constant value: "2019-10-01-preview". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-10-01-preview" - - self.config = config - + self._config = config def _create_initial( - self, resource_group_name, script_name, deployment_script, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + script_name, # type: str + deployment_script, # type: "models.DeploymentScript" + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentScript" + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentScript"] + error_map = {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") + # Construct URL - url = self.create.metadata['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'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._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) + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(deployment_script, 'DeploymentScript') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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]: - raise models.DeploymentScriptsErrorException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.DeploymentScriptsError, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentScript', response) + deserialized = self._deserialize('DeploymentScript', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('DeploymentScript', response) + deserialized = self._deserialize('DeploymentScript', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - - def create( - self, resource_group_name, script_name, deployment_script, custom_headers=None, raw=False, polling=True, **operation_config): + _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}'} # type: ignore + + def begin_create( + self, + resource_group_name, # type: str + script_name, # type: str + deployment_script, # type: "models.DeploymentScript" + **kwargs # type: Any + ): + # type: (...) -> LROPoller """Creates a deployment script. - :param resource_group_name: The name of the resource group. The name - is case insensitive. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :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_preview.models.DeploymentScript - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :type deployment_script: ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.DeploymentScript + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns DeploymentScript or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.DeploymentScript] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.DeploymentScript]] - :raises: - :class:`DeploymentScriptsErrorException` + :paramtype polling: bool or ~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 DeploymentScript + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.DeploymentScript] + :raises ~azure.core.exceptions.HttpResponseError: """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentScript"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._create_initial( resource_group_name=resource_group_name, script_name=script_name, deployment_script=deployment_script, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - deserialized = self._deserialize('DeploymentScript', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('DeploymentScript', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}'} + begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}'} # type: ignore def update( - self, resource_group_name, script_name, tags=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + script_name, # type: str + tags=None, # type: Optional[Dict[str, str]] + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentScript" """Updates deployment script tags with specified values. - :param resource_group_name: The name of the resource group. The name - is case insensitive. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param script_name: Name of the deployment script. :type script_name: str :param tags: Resource tags to be updated. :type tags: dict[str, str] - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentScript or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.DeploymentScript - or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`DeploymentScriptsErrorException` + :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_preview.models.DeploymentScript + :raises: ~azure.core.exceptions.HttpResponseError """ - deployment_script = None - if tags is not None: - deployment_script = models.DeploymentScriptUpdateParameter(tags=tags) + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentScript"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _deployment_script = models.DeploymentScriptUpdateParameter(tags=tags) + api_version = "2019-10-01-preview" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.update.metadata['url'] + url = self.update.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._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) + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - if deployment_script is not None: - body_content = self._serialize.body(deployment_script, 'DeploymentScriptUpdateParameter') + + # Construct and send request + body_content_kwargs = {} # type: Dict[str, Any] + if _deployment_script is not None: + body_content = 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) - # Construct and send request - request = self._client.patch(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.DeploymentScriptsErrorException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.DeploymentScriptsError, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentScript', response) + deserialized = self._deserialize('DeploymentScript', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}'} + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}'} # type: ignore def get( - self, resource_group_name, script_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + script_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentScript" """Gets a deployment script with a given name. - :param resource_group_name: The name of the resource group. The name - is case insensitive. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param script_name: Name of the deployment script. :type script_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentScript or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.DeploymentScript - or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`DeploymentScriptsErrorException` + :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_preview.models.DeploymentScript + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentScript"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01-preview" + # Construct URL - url = self.get.metadata['url'] + url = self.get.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._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) + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.DeploymentScriptsErrorException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.DeploymentScriptsError, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentScript', response) + deserialized = self._deserialize('DeploymentScript', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}'} # type: ignore def delete( - self, resource_group_name, script_name, custom_headers=None, raw=False, **operation_config): - """Deletes a deployment script. When operation completes, status code 200 - returned without content. - - :param resource_group_name: The name of the resource group. The name - is case insensitive. + self, + resource_group_name, # type: str + script_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """Deletes a deployment script. When operation completes, status code 200 returned without content. + + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param script_name: Name of the deployment script. :type script_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`DeploymentScriptsErrorException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01-preview" + # Construct URL - url = self.delete.metadata['url'] + url = self.delete.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._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) + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - raise models.DeploymentScriptsErrorException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.DeploymentScriptsError, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}'} + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}'} # type: ignore def list_by_subscription( - self, custom_headers=None, raw=False, **operation_config): + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.DeploymentScriptListResult"] """Lists all deployment scripts for a given subscription. - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of DeploymentScript - :rtype: - ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.DeploymentScriptPaged[~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.DeploymentScript] - :raises: - :class:`DeploymentScriptsErrorException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of DeploymentScriptListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.DeploymentScriptListResult] + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentScriptListResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01-preview" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_by_subscription.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentScriptListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.DeploymentScriptsErrorException(self._deserialize, response) + error = self._deserialize(models.DeploymentScriptsError, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.DeploymentScriptPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deploymentScripts'} + return ItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deploymentScripts'} # type: ignore def get_logs( - self, resource_group_name, script_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + script_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.ScriptLogsList" """Gets deployment script logs for a given deployment script name. - :param resource_group_name: The name of the resource group. The name - is case insensitive. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param script_name: Name of the deployment script. :type script_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: ScriptLogsList or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.ScriptLogsList - or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`DeploymentScriptsErrorException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ScriptLogsList or the result of cls(response) + :rtype: ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.ScriptLogsList + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ScriptLogsList"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01-preview" + # Construct URL - url = self.get_logs.metadata['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'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._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) + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.DeploymentScriptsErrorException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.DeploymentScriptsError, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('ScriptLogsList', response) + deserialized = self._deserialize('ScriptLogsList', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get_logs.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}/logs'} + get_logs.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}/logs'} # type: ignore def get_logs_default( - self, resource_group_name, script_name, tail=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + script_name, # type: str + tail=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> "models.ScriptLog" """Gets deployment script logs for a given deployment script name. - :param resource_group_name: The name of the resource group. The name - is case insensitive. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param script_name: Name of the deployment script. :type script_name: str - :param tail: The number of lines to show from the tail of the - deployment script log. Valid value is a positive number up to 1000. If - 'tail' is not provided, all available logs are shown up to container - instance log capacity of 4mb. + :param tail: The number of lines to show from the tail of the deployment script log. Valid + value is a positive number up to 1000. If 'tail' is not provided, all available logs are shown + up to container instance log capacity of 4mb. :type tail: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: ScriptLog or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.ScriptLog - or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`DeploymentScriptsErrorException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ScriptLog or the result of cls(response) + :rtype: ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.ScriptLog + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ScriptLog"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01-preview" + # Construct URL - url = self.get_logs_default.metadata['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'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._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) + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + 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 = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.DeploymentScriptsErrorException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.DeploymentScriptsError, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('ScriptLog', response) + deserialized = self._deserialize('ScriptLog', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get_logs_default.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}/logs/default'} + get_logs_default.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}/logs/default'} # type: ignore def list_by_resource_group( - self, resource_group_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.DeploymentScriptListResult"] """Lists deployments scripts. - :param resource_group_name: The name of the resource group. The name - is case insensitive. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of DeploymentScript - :rtype: - ~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.DeploymentScriptPaged[~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.DeploymentScript] - :raises: - :class:`DeploymentScriptsErrorException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of DeploymentScriptListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.deploymentscripts.v2019_10_preview.models.DeploymentScriptListResult] + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentScriptListResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01-preview" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_by_resource_group.metadata['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\._\(\)]+$') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentScriptListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.DeploymentScriptsErrorException(self._deserialize, response) - - return response + error = self._deserialize(models.DeploymentScriptsError, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.DeploymentScriptPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts'} + return ItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_preview/py.typed b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_preview/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_preview/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/__init__.py index 157f52c400a9..e352afa4db13 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/__init__.py @@ -1,19 +1,16 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._configuration import FeatureClientConfiguration from ._feature_client import FeatureClient -__all__ = ['FeatureClient', 'FeatureClientConfiguration'] - -from ..version import VERSION - -__version__ = VERSION +__all__ = ['FeatureClient'] +try: + from ._patch import patch_sdk + patch_sdk() +except ImportError: + pass 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 bc16306c5ed3..33cba4f7e65e 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 @@ -1,48 +1,69 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrestazure import AzureConfiguration -from ..version import VERSION +from typing import TYPE_CHECKING +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + + from azure.core.credentials import TokenCredential + +VERSION = "unknown" + +class FeatureClientConfiguration(Configuration): + """Configuration for FeatureClient. -class FeatureClientConfiguration(AzureConfiguration): - """Configuration for FeatureClient Note that all parameters used to create this instance are saved as instance attributes. - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` + :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 """ def __init__( - self, credentials, subscription_id, base_url=None): - - if credentials is None: - raise ValueError("Parameter 'credentials' must not be None.") + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + 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.") - if not base_url: - base_url = 'https://management.azure.com' + super(FeatureClientConfiguration, self).__init__(**kwargs) - super(FeatureClientConfiguration, self).__init__(base_url) - - # Starting Autorest.Python 4.0.64, make connection pool activated by default - self.keep_alive = True - - self.add_user_agent('azure-mgmt-resource/{}'.format(VERSION)) - self.add_user_agent('Azure-SDK-For-Python') - - self.credentials = credentials + self.credential = credential self.subscription_id = subscription_id + self.api_version = "2015-12-01" + self.credential_scopes = ['https://management.azure.com/.default'] + self.credential_scopes.extend(kwargs.pop('credential_scopes', [])) + kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + 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) 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 83dc0a5cdaf4..e352afa4db13 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 @@ -1,19 +1,16 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._configuration import FeatureClientConfiguration from ._feature_client import FeatureClient -__all__ = ['FeatureClient', 'FeatureClientConfiguration'] - -from .version import VERSION - -__version__ = VERSION +__all__ = ['FeatureClient'] +try: + from ._patch import patch_sdk + patch_sdk() +except ImportError: + pass 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 aa6a76b3eeb4..33cba4f7e65e 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 @@ -1,48 +1,69 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrestazure import AzureConfiguration -from .version import VERSION +from typing import TYPE_CHECKING +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + + from azure.core.credentials import TokenCredential + +VERSION = "unknown" + +class FeatureClientConfiguration(Configuration): + """Configuration for FeatureClient. -class FeatureClientConfiguration(AzureConfiguration): - """Configuration for FeatureClient Note that all parameters used to create this instance are saved as instance attributes. - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` + :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 """ def __init__( - self, credentials, subscription_id, base_url=None): - - if credentials is None: - raise ValueError("Parameter 'credentials' must not be None.") + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + 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.") - if not base_url: - base_url = 'https://management.azure.com' + super(FeatureClientConfiguration, self).__init__(**kwargs) - super(FeatureClientConfiguration, self).__init__(base_url) - - # Starting Autorest.Python 4.0.64, make connection pool activated by default - self.keep_alive = True - - self.add_user_agent('azure-mgmt-resource/{}'.format(VERSION)) - self.add_user_agent('Azure-SDK-For-Python') - - self.credentials = credentials + self.credential = credential self.subscription_id = subscription_id + self.api_version = "2015-12-01" + self.credential_scopes = ['https://management.azure.com/.default'] + self.credential_scopes.extend(kwargs.pop('credential_scopes', [])) + kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + 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) 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 2b18fd27d253..51ff5c5e487e 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 @@ -1,16 +1,19 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.service_client import SDKClient -from msrest import Serializer, Deserializer +from typing import TYPE_CHECKING + +from azure.mgmt.core import ARMPipelineClient +from msrest import Deserializer, Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional from ._configuration import FeatureClientConfiguration from .operations import FeatureClientOperationsMixin @@ -18,33 +21,48 @@ from . import models -class FeatureClient(FeatureClientOperationsMixin, SDKClient): +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 config: Configuration for client. - :vartype config: FeatureClientConfiguration - - :ivar features: Features operations + :ivar features: FeaturesOperations operations :vartype features: azure.mgmt.resource.features.v2015_12_01.operations.FeaturesOperations - - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` + :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. """ def __init__( - self, credentials, subscription_id, base_url=None): - - self.config = FeatureClientConfiguration(credentials, subscription_id, base_url) - super(FeatureClient, self).__init__(self.config.credentials, self.config) + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = 'https://management.azure.com' + self._config = FeatureClientConfiguration(credential, 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.api_version = '2015-12-01' self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self.features = FeaturesOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> FeatureClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) 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 new file mode 100644 index 000000000000..7e0dd195caf1 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/_metadata.json @@ -0,0 +1,66 @@ +{ + "chosen_version": "2015-12-01", + "total_api_version_list": ["2015-12-01"], + "client": { + "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." + }, + "global_parameters": { + "sync_method": { + "credential": { + "method_signature": "credential, # type: \"TokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials.TokenCredential", + "required": true + }, + "subscription_id": { + "method_signature": "subscription_id, # type: str", + "description": "The ID of the target subscription.", + "docstring_type": "str", + "required": true + } + }, + "async_method": { + "credential": { + "method_signature": "credential, # type: \"AsyncTokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + }, + "subscription_id": { + "method_signature": "subscription_id, # type: str", + "description": "The ID of the target subscription.", + "docstring_type": "str", + "required": true + } + }, + "constant": { + }, + "call": "credential, subscription_id" + }, + "config": { + "credential": true, + "credential_scopes": ["https://management.azure.com/.default"] + }, + "operation_groups": { + "features": "FeaturesOperations" + }, + "operation_mixins": { + "list_operations" : { + "sync": { + "operation_name": "list_operations", + "signature": "def list_operations(\n self,\n **kwargs # type: Any\n):\n" + }, + "async": { + "operation_name": "list_operations", + "signature": "def list_operations(\n self,\n **kwargs\n) -\u003e AsyncItemPaged[\"models.OperationListResult\"]:\n", + "coroutine": false + }, + "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: OperationListResult or the result of cls(response)\n:rtype: ~azure.mgmt.resource.features.v2015_12_01.models.OperationListResult\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"", + "call": "" + } + }, + "sync_imports": "from typing import TYPE_CHECKING\nimport warnings\n\nfrom azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error\nfrom azure.core.paging import ItemPaged\nfrom azure.core.pipeline import PipelineResponse\nfrom azure.core.pipeline.transport import HttpRequest, HttpResponse\nfrom azure.mgmt.core.exceptions import ARMErrorFormat\n\nif TYPE_CHECKING:\n # pylint: disable=unused-import,ungrouped-imports\n from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar", + "async_imports": "from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar\nimport warnings\n\nfrom azure.core.async_paging import AsyncItemPaged, AsyncList\nfrom azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error\nfrom azure.core.pipeline import PipelineResponse\nfrom azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest\nfrom azure.mgmt.core.exceptions import ARMErrorFormat" +} \ No newline at end of file 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 new file mode 100644 index 000000000000..3565af980429 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/aio/__init__.py @@ -0,0 +1,10 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._feature_client_async import FeatureClient +__all__ = ['FeatureClient'] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/aio/_configuration_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/aio/_configuration_async.py new file mode 100644 index 000000000000..4de89ddd22b8 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/aio/_configuration_async.py @@ -0,0 +1,65 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + +VERSION = "unknown" + +class FeatureClientConfiguration(Configuration): + """Configuration for FeatureClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :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 + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + 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 + self.api_version = "2015-12-01" + self.credential_scopes = ['https://management.azure.com/.default'] + self.credential_scopes.extend(kwargs.pop('credential_scopes', [])) + kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs: Any + ) -> None: + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + 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) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/aio/_feature_client_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/aio/_feature_client_async.py new file mode 100644 index 000000000000..81939253c98e --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/aio/_feature_client_async.py @@ -0,0 +1,60 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, Optional + +from azure.mgmt.core import AsyncARMPipelineClient +from msrest import Deserializer, Serializer + +from ._configuration_async import FeatureClientConfiguration +from .operations_async import FeatureClientOperationsMixin +from .operations_async 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. + + :ivar features: FeaturesOperations operations + :vartype features: azure.mgmt.resource.features.v2015_12_01.aio.operations_async.FeaturesOperations + :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. + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: Optional[str] = None, + **kwargs: 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) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + + self.features = FeaturesOperations( + self._client, self._config, self._serialize, self._deserialize) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "FeatureClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/aio/operations_async/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/aio/operations_async/__init__.py new file mode 100644 index 000000000000..d5ab49bfe7fd --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/aio/operations_async/__init__.py @@ -0,0 +1,15 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._feature_client_operations_async import FeatureClientOperationsMixin +from ._features_operations_async import FeaturesOperations + +__all__ = [ + 'FeatureClientOperationsMixin', + 'FeaturesOperations', +] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/aio/operations_async/_feature_client_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/aio/operations_async/_feature_client_operations_async.py new file mode 100644 index 000000000000..1d85e7943d69 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/aio/operations_async/_feature_client_operations_async.py @@ -0,0 +1,81 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import 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 ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class FeatureClientOperationsMixin: + + def list_operations( + self, + **kwargs + ) -> 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 OperationListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2015-12-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('OperationListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_operations.metadata = {'url': '/providers/Microsoft.Features/operations'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/aio/operations_async/_features_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/aio/operations_async/_features_operations_async.py new file mode 100644 index 000000000000..234db824482a --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/aio/operations_async/_features_operations_async.py @@ -0,0 +1,341 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import 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 ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class FeaturesOperations: + """FeaturesOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.features.v2015_12_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list_all( + self, + **kwargs + ) -> AsyncIterable["models.FeatureOperationsListResult"]: + """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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2015-12-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('FeatureOperationsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_all.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Features/features'} # type: ignore + + def list( + self, + resource_provider_namespace: str, + **kwargs + ) -> AsyncIterable["models.FeatureOperationsListResult"]: + """Gets all the preview features in a provider namespace that are available through AFEC for the subscription. + + :param resource_provider_namespace: The namespace of the resource provider for getting + 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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2015-12-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('FeatureOperationsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, 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 + + async def get( + self, + resource_provider_namespace: str, + feature_name: str, + **kwargs + ) -> "models.FeatureResult": + """Gets the preview feature with the specified name. + + :param resource_provider_namespace: The resource provider namespace for the feature. + :type resource_provider_namespace: str + :param feature_name: The name of the feature to get. + :type feature_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: FeatureResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.features.v2015_12_01.models.FeatureResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.FeatureResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2015-12-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('FeatureResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}/features/{featureName}'} # type: ignore + + async def register( + self, + resource_provider_namespace: str, + feature_name: str, + **kwargs + ) -> "models.FeatureResult": + """Registers the preview feature for the subscription. + + :param resource_provider_namespace: The namespace of the resource provider. + :type resource_provider_namespace: str + :param feature_name: The name of the feature to register. + :type feature_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: FeatureResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.features.v2015_12_01.models.FeatureResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.FeatureResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2015-12-01" + + # 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'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('FeatureResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + register.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}/features/{featureName}/register'} # type: ignore + + async def unregister( + self, + resource_provider_namespace: str, + feature_name: str, + **kwargs + ) -> "models.FeatureResult": + """Unregisters the preview feature for the subscription. + + :param resource_provider_namespace: The namespace of the resource provider. + :type resource_provider_namespace: str + :param feature_name: The name of the feature to unregister. + :type feature_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: FeatureResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.features.v2015_12_01.models.FeatureResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.FeatureResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2015-12-01" + + # 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'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('FeatureResult', pipeline_response) + + if cls: + 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/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/models/__init__.py index e952ff71fa61..64af179e29ee 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/models/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/models/__init__.py @@ -1,32 +1,31 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- try: + from ._models_py3 import FeatureOperationsListResult from ._models_py3 import FeatureProperties from ._models_py3 import FeatureResult from ._models_py3 import Operation from ._models_py3 import OperationDisplay + from ._models_py3 import OperationListResult except (SyntaxError, ImportError): - from ._models import FeatureProperties - from ._models import FeatureResult - from ._models import Operation - from ._models import OperationDisplay -from ._paged_models import FeatureResultPaged -from ._paged_models import OperationPaged + from ._models import FeatureOperationsListResult # type: ignore + from ._models import FeatureProperties # type: ignore + from ._models import FeatureResult # type: ignore + from ._models import Operation # type: ignore + from ._models import OperationDisplay # type: ignore + from ._models import OperationListResult # type: ignore __all__ = [ + 'FeatureOperationsListResult', 'FeatureProperties', 'FeatureResult', 'Operation', 'OperationDisplay', - 'OperationPaged', - 'FeatureResultPaged', + 'OperationListResult', ] 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 c931068653b7..f6b6170eb284 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 @@ -1,26 +1,38 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.serialization import Model +import msrest.serialization -class CloudError(Model): - """CloudError. +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 """ _attribute_map = { + 'value': {'key': 'value', 'type': '[FeatureResult]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, } + def __init__( + self, + **kwargs + ): + super(FeatureOperationsListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + -class FeatureProperties(Model): +class FeatureProperties(msrest.serialization.Model): """Information about feature. :param state: The registration state of the feature for the subscription. @@ -31,19 +43,21 @@ class FeatureProperties(Model): 'state': {'key': 'state', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(FeatureProperties, self).__init__(**kwargs) self.state = kwargs.get('state', None) -class FeatureResult(Model): +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 + :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. @@ -57,7 +71,10 @@ class FeatureResult(Model): 'type': {'key': 'type', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(FeatureResult, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.properties = kwargs.get('properties', None) @@ -65,14 +82,13 @@ def __init__(self, **kwargs): self.type = kwargs.get('type', None) -class Operation(Model): +class Operation(msrest.serialization.Model): """Microsoft.Features operation. - :param name: Operation name: {provider}/{resource}/{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 + :type display: ~azure.mgmt.resource.features.v2015_12_01.models.OperationDisplay """ _attribute_map = { @@ -80,19 +96,21 @@ class Operation(Model): 'display': {'key': 'display', 'type': 'OperationDisplay'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Operation, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.display = kwargs.get('display', None) -class OperationDisplay(Model): +class OperationDisplay(msrest.serialization.Model): """The object that represents the operation. - :param provider: Service provider: Microsoft.Features + :param provider: Service provider: Microsoft.Features. :type provider: str - :param resource: Resource on which the operation is performed: Profile, - endpoint, etc. + :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 @@ -104,8 +122,34 @@ class OperationDisplay(Model): 'operation': {'key': 'operation', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(OperationDisplay, self).__init__(**kwargs) self.provider = kwargs.get('provider', None) self.resource = kwargs.get('resource', None) self.operation = kwargs.get('operation', None) + + +class OperationListResult(msrest.serialization.Model): + """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 + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Operation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + 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 3d12ba008d25..f6eda01dda24 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 @@ -1,26 +1,43 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.serialization import Model +from typing import List, Optional +import msrest.serialization -class CloudError(Model): - """CloudError. + +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 """ _attribute_map = { + 'value': {'key': 'value', 'type': '[FeatureResult]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, } + def __init__( + self, + *, + value: Optional[List["FeatureResult"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(FeatureOperationsListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + -class FeatureProperties(Model): +class FeatureProperties(msrest.serialization.Model): """Information about feature. :param state: The registration state of the feature for the subscription. @@ -31,19 +48,23 @@ class FeatureProperties(Model): 'state': {'key': 'state', 'type': 'str'}, } - def __init__(self, *, state: str=None, **kwargs) -> None: + def __init__( + self, + *, + state: Optional[str] = None, + **kwargs + ): super(FeatureProperties, self).__init__(**kwargs) self.state = state -class FeatureResult(Model): +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 + :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. @@ -57,7 +78,15 @@ class FeatureResult(Model): 'type': {'key': 'type', 'type': 'str'}, } - def __init__(self, *, name: str=None, properties=None, id: str=None, type: str=None, **kwargs) -> None: + def __init__( + self, + *, + name: Optional[str] = None, + properties: Optional["FeatureProperties"] = None, + id: Optional[str] = None, + type: Optional[str] = None, + **kwargs + ): super(FeatureResult, self).__init__(**kwargs) self.name = name self.properties = properties @@ -65,14 +94,13 @@ def __init__(self, *, name: str=None, properties=None, id: str=None, type: str=N self.type = type -class Operation(Model): +class Operation(msrest.serialization.Model): """Microsoft.Features operation. - :param name: Operation name: {provider}/{resource}/{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 + :type display: ~azure.mgmt.resource.features.v2015_12_01.models.OperationDisplay """ _attribute_map = { @@ -80,19 +108,24 @@ class Operation(Model): 'display': {'key': 'display', 'type': 'OperationDisplay'}, } - def __init__(self, *, name: str=None, display=None, **kwargs) -> None: + def __init__( + self, + *, + name: Optional[str] = None, + display: Optional["OperationDisplay"] = None, + **kwargs + ): super(Operation, self).__init__(**kwargs) self.name = name self.display = display -class OperationDisplay(Model): +class OperationDisplay(msrest.serialization.Model): """The object that represents the operation. - :param provider: Service provider: Microsoft.Features + :param provider: Service provider: Microsoft.Features. :type provider: str - :param resource: Resource on which the operation is performed: Profile, - endpoint, etc. + :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 @@ -104,8 +137,41 @@ class OperationDisplay(Model): 'operation': {'key': 'operation', 'type': 'str'}, } - def __init__(self, *, provider: str=None, resource: str=None, operation: str=None, **kwargs) -> None: + def __init__( + self, + *, + provider: Optional[str] = None, + resource: Optional[str] = None, + operation: Optional[str] = None, + **kwargs + ): super(OperationDisplay, self).__init__(**kwargs) self.provider = provider self.resource = resource self.operation = operation + + +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 + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Operation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["Operation"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + 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/models/_paged_models.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/models/_paged_models.py deleted file mode 100644 index 7d57c51b86f3..000000000000 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/models/_paged_models.py +++ /dev/null @@ -1,40 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.paging import Paged - - -class OperationPaged(Paged): - """ - A paging container for iterating over a list of :class:`Operation ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[Operation]'} - } - - def __init__(self, *args, **kwargs): - - super(OperationPaged, self).__init__(*args, **kwargs) -class FeatureResultPaged(Paged): - """ - A paging container for iterating over a list of :class:`FeatureResult ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[FeatureResult]'} - } - - def __init__(self, *args, **kwargs): - - super(FeatureResultPaged, self).__init__(*args, **kwargs) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/operations/__init__.py index eca886af9bce..e5d7ba1b0157 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/operations/__init__.py @@ -1,18 +1,15 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._features_operations import FeaturesOperations from ._feature_client_operations import FeatureClientOperationsMixin +from ._features_operations import FeaturesOperations __all__ = [ - 'FeaturesOperations', 'FeatureClientOperationsMixin', + 'FeaturesOperations', ] 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 a504d7a43f18..008baafa141e 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 @@ -1,80 +1,86 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError from .. import models -import uuid +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class FeatureClientOperationsMixin(object): def list_operations( - self, custom_headers=None, raw=False, **operation_config): + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.OperationListResult"] """Lists all of the available Microsoft.Features REST API operations. - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of Operation - :rtype: - ~azure.mgmt.resource.features.v2015_12_01.models.OperationPaged[~azure.mgmt.resource.features.v2015_12_01.models.Operation] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of OperationListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2015-12-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_operations.metadata['url'] - + url = self.list_operations.metadata['url'] # type: ignore # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('OperationListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.OperationPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list_operations.metadata = {'url': '/providers/Microsoft.Features/operations'} + return ItemPaged( + get_next, extract_data + ) + list_operations.metadata = {'url': '/providers/Microsoft.Features/operations'} # type: ignore 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 f55b6eebeeea..340e23dc4203 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 @@ -1,364 +1,350 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class FeaturesOperations(object): """FeaturesOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.features.v2015_12_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for this operation. Constant value: "2015-12-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2015-12-01" - - self.config = config + self._config = config def list_all( - self, custom_headers=None, raw=False, **operation_config): - """Gets all the preview features that are available through AFEC for the - subscription. - - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of FeatureResult - :rtype: - ~azure.mgmt.resource.features.v2015_12_01.models.FeatureResultPaged[~azure.mgmt.resource.features.v2015_12_01.models.FeatureResult] - :raises: :class:`CloudError` + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.FeatureOperationsListResult"] + """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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2015-12-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_all.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('FeatureOperationsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.FeatureResultPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_all.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Features/features'} + return ItemPaged( + get_next, extract_data + ) + list_all.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Features/features'} # type: ignore def list( - self, resource_provider_namespace, custom_headers=None, raw=False, **operation_config): - """Gets all the preview features in a provider namespace that are - available through AFEC for the subscription. - - :param resource_provider_namespace: The namespace of the resource - provider for getting features. + self, + resource_provider_namespace, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.FeatureOperationsListResult"] + """Gets all the preview features in a provider namespace that are available through AFEC for the subscription. + + :param resource_provider_namespace: The namespace of the resource provider for getting + features. :type resource_provider_namespace: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of FeatureResult - :rtype: - ~azure.mgmt.resource.features.v2015_12_01.models.FeatureResultPaged[~azure.mgmt.resource.features.v2015_12_01.models.FeatureResult] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2015-12-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('FeatureOperationsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.FeatureResultPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}/features'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}/features'} # type: ignore def get( - self, resource_provider_namespace, feature_name, custom_headers=None, raw=False, **operation_config): + self, + resource_provider_namespace, # type: str + feature_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.FeatureResult" """Gets the preview feature with the specified name. - :param resource_provider_namespace: The resource provider namespace - for the feature. + :param resource_provider_namespace: The resource provider namespace for the feature. :type resource_provider_namespace: str :param feature_name: The name of the feature to get. :type feature_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: FeatureResult or ClientRawResponse if raw=true + :keyword callable cls: A custom type or function that will be passed the direct response + :return: FeatureResult or the result of cls(response) :rtype: ~azure.mgmt.resource.features.v2015_12_01.models.FeatureResult - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.FeatureResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2015-12-01" + # Construct URL - url = self.get.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('FeatureResult', response) + deserialized = self._deserialize('FeatureResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}/features/{featureName}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}/features/{featureName}'} # type: ignore def register( - self, resource_provider_namespace, feature_name, custom_headers=None, raw=False, **operation_config): + self, + resource_provider_namespace, # type: str + feature_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.FeatureResult" """Registers the preview feature for the subscription. - :param resource_provider_namespace: The namespace of the resource - provider. + :param resource_provider_namespace: The namespace of the resource provider. :type resource_provider_namespace: str :param feature_name: The name of the feature to register. :type feature_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: FeatureResult or ClientRawResponse if raw=true + :keyword callable cls: A custom type or function that will be passed the direct response + :return: FeatureResult or the result of cls(response) :rtype: ~azure.mgmt.resource.features.v2015_12_01.models.FeatureResult - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.FeatureResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2015-12-01" + # Construct URL - url = self.register.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('FeatureResult', response) + deserialized = self._deserialize('FeatureResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - register.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}/features/{featureName}/register'} + register.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}/features/{featureName}/register'} # type: ignore def unregister( - self, resource_provider_namespace, feature_name, custom_headers=None, raw=False, **operation_config): + self, + resource_provider_namespace, # type: str + feature_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.FeatureResult" """Unregisters the preview feature for the subscription. - :param resource_provider_namespace: The namespace of the resource - provider. + :param resource_provider_namespace: The namespace of the resource provider. :type resource_provider_namespace: str :param feature_name: The name of the feature to unregister. :type feature_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: FeatureResult or ClientRawResponse if raw=true + :keyword callable cls: A custom type or function that will be passed the direct response + :return: FeatureResult or the result of cls(response) :rtype: ~azure.mgmt.resource.features.v2015_12_01.models.FeatureResult - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.FeatureResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2015-12-01" + # Construct URL - url = self.unregister.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('FeatureResult', response) + deserialized = self._deserialize('FeatureResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - unregister.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/{resourceProviderNamespace}/features/{featureName}/unregister'} + 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/py.typed b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/__init__.py index 5161076429d6..134e378efb04 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/__init__.py @@ -1,19 +1,16 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._configuration import ManagementLinkClientConfiguration from ._management_link_client import ManagementLinkClient -__all__ = ['ManagementLinkClient', 'ManagementLinkClientConfiguration'] - -from ..version import VERSION - -__version__ = VERSION +__all__ = ['ManagementLinkClient'] +try: + from ._patch import patch_sdk + patch_sdk() +except ImportError: + pass 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 7ac9fd40fbdd..ce861e04154b 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 @@ -1,48 +1,69 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrestazure import AzureConfiguration -from ..version import VERSION +from typing import TYPE_CHECKING +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + + from azure.core.credentials import TokenCredential + +VERSION = "unknown" + +class ManagementLinkClientConfiguration(Configuration): + """Configuration for ManagementLinkClient. -class ManagementLinkClientConfiguration(AzureConfiguration): - """Configuration for ManagementLinkClient Note that all parameters used to create this instance are saved as instance attributes. - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` + :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 """ def __init__( - self, credentials, subscription_id, base_url=None): - - if credentials is None: - raise ValueError("Parameter 'credentials' must not be None.") + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + 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.") - if not base_url: - base_url = 'https://management.azure.com' + super(ManagementLinkClientConfiguration, self).__init__(**kwargs) - super(ManagementLinkClientConfiguration, self).__init__(base_url) - - # Starting Autorest.Python 4.0.64, make connection pool activated by default - self.keep_alive = True - - self.add_user_agent('azure-mgmt-resource/{}'.format(VERSION)) - self.add_user_agent('Azure-SDK-For-Python') - - self.credentials = credentials + self.credential = credential self.subscription_id = subscription_id + self.api_version = "2016-09-01" + self.credential_scopes = ['https://management.azure.com/.default'] + self.credential_scopes.extend(kwargs.pop('credential_scopes', [])) + kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + 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) 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 04aebfce159e..134e378efb04 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 @@ -1,19 +1,16 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._configuration import ManagementLinkClientConfiguration from ._management_link_client import ManagementLinkClient -__all__ = ['ManagementLinkClient', 'ManagementLinkClientConfiguration'] - -from .version import VERSION - -__version__ = VERSION +__all__ = ['ManagementLinkClient'] +try: + from ._patch import patch_sdk + patch_sdk() +except ImportError: + pass 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 ec99c613fdc2..ce861e04154b 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 @@ -1,48 +1,69 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrestazure import AzureConfiguration -from .version import VERSION +from typing import TYPE_CHECKING +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + + from azure.core.credentials import TokenCredential + +VERSION = "unknown" + +class ManagementLinkClientConfiguration(Configuration): + """Configuration for ManagementLinkClient. -class ManagementLinkClientConfiguration(AzureConfiguration): - """Configuration for ManagementLinkClient Note that all parameters used to create this instance are saved as instance attributes. - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` + :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 """ def __init__( - self, credentials, subscription_id, base_url=None): - - if credentials is None: - raise ValueError("Parameter 'credentials' must not be None.") + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + 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.") - if not base_url: - base_url = 'https://management.azure.com' + super(ManagementLinkClientConfiguration, self).__init__(**kwargs) - super(ManagementLinkClientConfiguration, self).__init__(base_url) - - # Starting Autorest.Python 4.0.64, make connection pool activated by default - self.keep_alive = True - - self.add_user_agent('azure-mgmt-resource/{}'.format(VERSION)) - self.add_user_agent('Azure-SDK-For-Python') - - self.credentials = credentials + self.credential = credential self.subscription_id = subscription_id + self.api_version = "2016-09-01" + self.credential_scopes = ['https://management.azure.com/.default'] + self.credential_scopes.extend(kwargs.pop('credential_scopes', [])) + kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + 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) 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 44e66a353ae6..38a5f6deda28 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 @@ -1,16 +1,19 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.service_client import SDKClient -from msrest import Serializer, Deserializer +from typing import TYPE_CHECKING + +from azure.mgmt.core import ARMPipelineClient +from msrest import Deserializer, Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional from ._configuration import ManagementLinkClientConfiguration from .operations import Operations @@ -18,37 +21,52 @@ from . import models -class ManagementLinkClient(SDKClient): +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. - :ivar config: Configuration for client. - :vartype config: ManagementLinkClientConfiguration - :ivar operations: Operations operations :vartype operations: azure.mgmt.resource.links.v2016_09_01.operations.Operations - :ivar resource_links: ResourceLinks operations + :ivar resource_links: ResourceLinksOperations operations :vartype resource_links: azure.mgmt.resource.links.v2016_09_01.operations.ResourceLinksOperations - - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` + :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. """ def __init__( - self, credentials, subscription_id, base_url=None): - - self.config = ManagementLinkClientConfiguration(credentials, subscription_id, base_url) - super(ManagementLinkClient, self).__init__(self.config.credentials, self.config) + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = 'https://management.azure.com' + self._config = ManagementLinkClientConfiguration(credential, 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.api_version = '2016-09-01' self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self.operations = Operations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.resource_links = ResourceLinksOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> ManagementLinkClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) 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 new file mode 100644 index 000000000000..4ab1a442a015 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/_metadata.json @@ -0,0 +1,54 @@ +{ + "chosen_version": "2016-09-01", + "total_api_version_list": ["2016-09-01"], + "client": { + "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." + }, + "global_parameters": { + "sync_method": { + "credential": { + "method_signature": "credential, # type: \"TokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials.TokenCredential", + "required": true + }, + "subscription_id": { + "method_signature": "subscription_id, # type: str", + "description": "The ID of the target subscription.", + "docstring_type": "str", + "required": true + } + }, + "async_method": { + "credential": { + "method_signature": "credential, # type: \"AsyncTokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + }, + "subscription_id": { + "method_signature": "subscription_id, # type: str", + "description": "The ID of the target subscription.", + "docstring_type": "str", + "required": true + } + }, + "constant": { + }, + "call": "credential, subscription_id" + }, + "config": { + "credential": true, + "credential_scopes": ["https://management.azure.com/.default"] + }, + "operation_groups": { + "operations": "Operations", + "resource_links": "ResourceLinksOperations" + }, + "operation_mixins": { + }, + "sync_imports": "None", + "async_imports": "None" +} \ No newline at end of file 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 new file mode 100644 index 000000000000..37e279161e27 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/aio/__init__.py @@ -0,0 +1,10 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._management_link_client_async import ManagementLinkClient +__all__ = ['ManagementLinkClient'] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/aio/_configuration_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/aio/_configuration_async.py new file mode 100644 index 000000000000..8166c561701a --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/aio/_configuration_async.py @@ -0,0 +1,65 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + +VERSION = "unknown" + +class ManagementLinkClientConfiguration(Configuration): + """Configuration for ManagementLinkClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :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 + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + 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 + self.api_version = "2016-09-01" + self.credential_scopes = ['https://management.azure.com/.default'] + self.credential_scopes.extend(kwargs.pop('credential_scopes', [])) + kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs: Any + ) -> None: + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + 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) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/aio/_management_link_client_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/aio/_management_link_client_async.py new file mode 100644 index 000000000000..18b325d61adb --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/aio/_management_link_client_async.py @@ -0,0 +1,64 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, Optional + +from azure.mgmt.core import AsyncARMPipelineClient +from msrest import Deserializer, Serializer + +from ._configuration_async import ManagementLinkClientConfiguration +from .operations_async import Operations +from .operations_async import ResourceLinksOperations +from .. import models + + +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. + + :ivar operations: Operations operations + :vartype operations: azure.mgmt.resource.links.v2016_09_01.aio.operations_async.Operations + :ivar resource_links: ResourceLinksOperations operations + :vartype resource_links: azure.mgmt.resource.links.v2016_09_01.aio.operations_async.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 + :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, + **kwargs: 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) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize) + self.resource_links = ResourceLinksOperations( + self._client, self._config, self._serialize, self._deserialize) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "ManagementLinkClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/aio/operations_async/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/aio/operations_async/__init__.py new file mode 100644 index 000000000000..c6afcb1deebe --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/aio/operations_async/__init__.py @@ -0,0 +1,15 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._operations_async import Operations +from ._resource_links_operations_async import ResourceLinksOperations + +__all__ = [ + 'Operations', + 'ResourceLinksOperations', +] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/aio/operations_async/_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/aio/operations_async/_operations_async.py new file mode 100644 index 000000000000..cfb68963bc37 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/aio/operations_async/_operations_async.py @@ -0,0 +1,101 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import 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 ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class Operations: + """Operations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.links.v2016_09_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + **kwargs + ) -> AsyncIterable["models.OperationListResult"]: + """Lists all of the available Microsoft.Resources REST API operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of OperationListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-09-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('OperationListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.Resources/operations'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/aio/operations_async/_resource_links_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/aio/operations_async/_resource_links_operations_async.py new file mode 100644 index 000000000000..600a86ac92d7 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/aio/operations_async/_resource_links_operations_async.py @@ -0,0 +1,357 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import 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 ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ResourceLinksOperations: + """ResourceLinksOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.links.v2016_09_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def delete( + self, + link_id: str, + **kwargs + ) -> None: + """Deletes a resource link with the specified ID. + + :param link_id: The fully qualified ID of the resource link. Use the format, + /subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/{provider- + namespace}/{resource-type}/{resource-name}/Microsoft.Resources/links/{link-name}. For example, + /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup/Microsoft.Web/sites/mySite/Microsoft.Resources/links/myLink. + :type link_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/{linkId}'} # type: ignore + + async def create_or_update( + self, + link_id: str, + properties: Optional["models.ResourceLinkProperties"] = None, + **kwargs + ) -> "models.ResourceLink": + """Creates or updates a resource link between the specified resources. + + :param link_id: The fully qualified ID of the resource link. Use the format, + /subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/{provider- + namespace}/{resource-type}/{resource-name}/Microsoft.Resources/links/{link-name}. For example, + /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup/Microsoft.Web/sites/mySite/Microsoft.Resources/links/myLink. + :type link_id: str + :param properties: Properties for resource link. + :type properties: ~azure.mgmt.resource.links.v2016_09_01.models.ResourceLinkProperties + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceLink or the result of cls(response) + :rtype: ~azure.mgmt.resource.links.v2016_09_01.models.ResourceLink + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceLink"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.ResourceLink(properties=properties) + api_version = "2016-09-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ResourceLink', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ResourceLink', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update.metadata = {'url': '/{linkId}'} # type: ignore + + async def get( + self, + link_id: str, + **kwargs + ) -> "models.ResourceLink": + """Gets a resource link with the specified ID. + + :param link_id: The fully qualified Id of the resource link. For example, + /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup/Microsoft.Web/sites/mySite/Microsoft.Resources/links/myLink. + :type link_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceLink or the result of cls(response) + :rtype: ~azure.mgmt.resource.links.v2016_09_01.models.ResourceLink + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceLink"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-09-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ResourceLink', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/{linkId}'} # type: ignore + + def list_at_subscription( + self, + filter: Optional[str] = None, + **kwargs + ) -> AsyncIterable["models.ResourceLinkResult"]: + """Gets all the linked resources for the subscription. + + :param filter: The filter to apply on the list resource links operation. The supported filter + for list resource links is targetId. For example, $filter=targetId eq {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 ResourceLinkResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-09-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ResourceLinkResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_at_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/links'} # type: ignore + + def list_at_source_scope( + self, + scope: str, + filter: Optional[str] = "atScope()", + **kwargs + ) -> AsyncIterable["models.ResourceLinkResult"]: + """Gets a list of resource links at and below the specified source scope. + + :param scope: The fully qualified ID of the scope for getting the resource links. For example, + to list resource links at and under a resource group, set the scope to + /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(). + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of ResourceLinkResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-09-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ResourceLinkResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_at_source_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/links'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/models/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/models/__init__.py index 03f0bacde7b3..e223127905f4 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/models/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/models/__init__.py @@ -1,39 +1,34 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- try: from ._models_py3 import Operation from ._models_py3 import OperationDisplay + from ._models_py3 import OperationListResult from ._models_py3 import ResourceLink from ._models_py3 import ResourceLinkFilter from ._models_py3 import ResourceLinkProperties + from ._models_py3 import ResourceLinkResult except (SyntaxError, ImportError): - from ._models import Operation - from ._models import OperationDisplay - from ._models import ResourceLink - from ._models import ResourceLinkFilter - from ._models import ResourceLinkProperties -from ._paged_models import OperationPaged -from ._paged_models import ResourceLinkPaged -from ._management_link_client_enums import ( - Filter, -) + from ._models import Operation # type: ignore + from ._models import OperationDisplay # type: ignore + from ._models import OperationListResult # type: ignore + from ._models import ResourceLink # type: ignore + from ._models import ResourceLinkFilter # type: ignore + from ._models import ResourceLinkProperties # type: ignore + from ._models import ResourceLinkResult # type: ignore __all__ = [ 'Operation', 'OperationDisplay', + 'OperationListResult', 'ResourceLink', 'ResourceLinkFilter', 'ResourceLinkProperties', - 'OperationPaged', - 'ResourceLinkPaged', - 'Filter', + 'ResourceLinkResult', ] 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 8ff2fec82f8a..e89350ddcb21 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 @@ -1,33 +1,21 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.serialization import Model +import msrest.serialization -class CloudError(Model): - """CloudError. - """ - - _attribute_map = { - } - - -class Operation(Model): +class Operation(msrest.serialization.Model): """Microsoft.Resources operation. - :param name: Operation name: {provider}/{resource}/{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 + :type display: ~azure.mgmt.resource.links.v2016_09_01.models.OperationDisplay """ _attribute_map = { @@ -35,19 +23,21 @@ class Operation(Model): 'display': {'key': 'display', 'type': 'OperationDisplay'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Operation, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.display = kwargs.get('display', None) -class OperationDisplay(Model): +class OperationDisplay(msrest.serialization.Model): """The object that represents the operation. - :param provider: Service provider: Microsoft.Resources + :param provider: Service provider: Microsoft.Resources. :type provider: str - :param resource: Resource on which the operation is performed: Profile, - endpoint, etc. + :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 @@ -62,7 +52,10 @@ class OperationDisplay(Model): 'description': {'key': 'description', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(OperationDisplay, self).__init__(**kwargs) self.provider = kwargs.get('provider', None) self.resource = kwargs.get('resource', None) @@ -70,11 +63,33 @@ def __init__(self, **kwargs): self.description = kwargs.get('description', None) -class ResourceLink(Model): +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 + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Operation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(OperationListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class ResourceLink(msrest.serialization.Model): """The resource link. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The fully qualified ID of the resource link. :vartype id: str @@ -83,8 +98,7 @@ class ResourceLink(Model): :ivar type: The resource link object. :vartype type: object :param properties: Properties for resource link. - :type properties: - ~azure.mgmt.resource.links.v2016_09_01.models.ResourceLinkProperties + :type properties: ~azure.mgmt.resource.links.v2016_09_01.models.ResourceLinkProperties """ _validation = { @@ -100,7 +114,10 @@ class ResourceLink(Model): 'properties': {'key': 'properties', 'type': 'ResourceLinkProperties'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ResourceLink, self).__init__(**kwargs) self.id = None self.name = None @@ -108,7 +125,7 @@ def __init__(self, **kwargs): self.properties = kwargs.get('properties', None) -class ResourceLinkFilter(Model): +class ResourceLinkFilter(msrest.serialization.Model): """Resource link filter. All required parameters must be populated in order to send to Azure. @@ -125,24 +142,24 @@ class ResourceLinkFilter(Model): 'target_id': {'key': 'targetId', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ResourceLinkFilter, self).__init__(**kwargs) - self.target_id = kwargs.get('target_id', None) + self.target_id = kwargs['target_id'] -class ResourceLinkProperties(Model): +class ResourceLinkProperties(msrest.serialization.Model): """The resource link properties. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar source_id: The fully qualified ID of the source resource in the - link. + :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. + :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 @@ -159,8 +176,43 @@ class ResourceLinkProperties(Model): 'notes': {'key': 'notes', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ResourceLinkProperties, self).__init__(**kwargs) self.source_id = None - self.target_id = kwargs.get('target_id', None) + self.target_id = kwargs['target_id'] self.notes = kwargs.get('notes', None) + + +class ResourceLinkResult(msrest.serialization.Model): + """List of resource links. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :param value: Required. An array of resource links. + :type 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 + """ + + _validation = { + 'value': {'required': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ResourceLink]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + 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 c5cbd11d2a54..eebb8c9808c1 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 @@ -1,33 +1,23 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.serialization import Model +from typing import List, Optional +import msrest.serialization -class CloudError(Model): - """CloudError. - """ - - _attribute_map = { - } - -class Operation(Model): +class Operation(msrest.serialization.Model): """Microsoft.Resources operation. - :param name: Operation name: {provider}/{resource}/{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 + :type display: ~azure.mgmt.resource.links.v2016_09_01.models.OperationDisplay """ _attribute_map = { @@ -35,19 +25,24 @@ class Operation(Model): 'display': {'key': 'display', 'type': 'OperationDisplay'}, } - def __init__(self, *, name: str=None, display=None, **kwargs) -> None: + def __init__( + self, + *, + name: Optional[str] = None, + display: Optional["OperationDisplay"] = None, + **kwargs + ): super(Operation, self).__init__(**kwargs) self.name = name self.display = display -class OperationDisplay(Model): +class OperationDisplay(msrest.serialization.Model): """The object that represents the operation. - :param provider: Service provider: Microsoft.Resources + :param provider: Service provider: Microsoft.Resources. :type provider: str - :param resource: Resource on which the operation is performed: Profile, - endpoint, etc. + :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 @@ -62,7 +57,15 @@ class OperationDisplay(Model): 'description': {'key': 'description', 'type': 'str'}, } - def __init__(self, *, provider: str=None, resource: str=None, operation: str=None, description: str=None, **kwargs) -> None: + def __init__( + self, + *, + provider: Optional[str] = None, + resource: Optional[str] = None, + operation: Optional[str] = None, + description: Optional[str] = None, + **kwargs + ): super(OperationDisplay, self).__init__(**kwargs) self.provider = provider self.resource = resource @@ -70,11 +73,36 @@ def __init__(self, *, provider: str=None, resource: str=None, operation: str=Non self.description = description -class ResourceLink(Model): +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 + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Operation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["Operation"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(OperationListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ResourceLink(msrest.serialization.Model): """The resource link. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The fully qualified ID of the resource link. :vartype id: str @@ -83,8 +111,7 @@ class ResourceLink(Model): :ivar type: The resource link object. :vartype type: object :param properties: Properties for resource link. - :type properties: - ~azure.mgmt.resource.links.v2016_09_01.models.ResourceLinkProperties + :type properties: ~azure.mgmt.resource.links.v2016_09_01.models.ResourceLinkProperties """ _validation = { @@ -100,7 +127,12 @@ class ResourceLink(Model): 'properties': {'key': 'properties', 'type': 'ResourceLinkProperties'}, } - def __init__(self, *, properties=None, **kwargs) -> None: + def __init__( + self, + *, + properties: Optional["ResourceLinkProperties"] = None, + **kwargs + ): super(ResourceLink, self).__init__(**kwargs) self.id = None self.name = None @@ -108,7 +140,7 @@ def __init__(self, *, properties=None, **kwargs) -> None: self.properties = properties -class ResourceLinkFilter(Model): +class ResourceLinkFilter(msrest.serialization.Model): """Resource link filter. All required parameters must be populated in order to send to Azure. @@ -125,24 +157,26 @@ class ResourceLinkFilter(Model): 'target_id': {'key': 'targetId', 'type': 'str'}, } - def __init__(self, *, target_id: str, **kwargs) -> None: + def __init__( + self, + *, + target_id: str, + **kwargs + ): super(ResourceLinkFilter, self).__init__(**kwargs) self.target_id = target_id -class ResourceLinkProperties(Model): +class ResourceLinkProperties(msrest.serialization.Model): """The resource link properties. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar source_id: The fully qualified ID of the source resource in the - link. + :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. + :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 @@ -159,8 +193,48 @@ class ResourceLinkProperties(Model): 'notes': {'key': 'notes', 'type': 'str'}, } - def __init__(self, *, target_id: str, notes: str=None, **kwargs) -> None: + def __init__( + self, + *, + target_id: str, + notes: Optional[str] = None, + **kwargs + ): super(ResourceLinkProperties, self).__init__(**kwargs) self.source_id = None self.target_id = target_id self.notes = notes + + +class ResourceLinkResult(msrest.serialization.Model): + """List of resource links. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :param value: Required. An array of resource links. + :type 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 + """ + + _validation = { + 'value': {'required': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ResourceLink]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: List["ResourceLink"], + **kwargs + ): + 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/models/_paged_models.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/models/_paged_models.py deleted file mode 100644 index c62f909a4076..000000000000 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/models/_paged_models.py +++ /dev/null @@ -1,40 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.paging import Paged - - -class OperationPaged(Paged): - """ - A paging container for iterating over a list of :class:`Operation ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[Operation]'} - } - - def __init__(self, *args, **kwargs): - - super(OperationPaged, self).__init__(*args, **kwargs) -class ResourceLinkPaged(Paged): - """ - A paging container for iterating over a list of :class:`ResourceLink ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[ResourceLink]'} - } - - def __init__(self, *args, **kwargs): - - super(ResourceLinkPaged, self).__init__(*args, **kwargs) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/operations/__init__.py index a7653aaee4f2..1e95e47b05fe 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/operations/__init__.py @@ -1,12 +1,9 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from ._operations import Operations 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 793e617c3524..40c7015a5a7b 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 @@ -1,102 +1,106 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class Operations(object): """Operations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.links.v2016_09_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for the operation. Constant value: "2016-09-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2016-09-01" - - self.config = config + self._config = config def list( - self, custom_headers=None, raw=False, **operation_config): + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.OperationListResult"] """Lists all of the available Microsoft.Resources REST API operations. - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of Operation - :rtype: - ~azure.mgmt.resource.links.v2016_09_01.models.OperationPaged[~azure.mgmt.resource.links.v2016_09_01.models.Operation] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of OperationListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-09-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['url'] - + url = self.list.metadata['url'] # type: ignore # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('OperationListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.OperationPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list.metadata = {'url': '/providers/Microsoft.Resources/operations'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.Resources/operations'} # type: ignore 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 dedc38985a1b..5b7cbd75c919 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 @@ -1,373 +1,366 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class ResourceLinksOperations(object): """ResourceLinksOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.links.v2016_09_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for the operation. Constant value: "2016-09-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2016-09-01" - - self.config = config + self._config = config def delete( - self, link_id, custom_headers=None, raw=False, **operation_config): + self, + link_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Deletes a resource link with the specified ID. - :param link_id: The fully qualified ID of the resource link. Use the - format, - /subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/{provider-namespace}/{resource-type}/{resource-name}/Microsoft.Resources/links/{link-name}. - For example, - /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup/Microsoft.Web/sites/mySite/Microsoft.Resources/links/myLink + :param link_id: The fully qualified ID of the resource link. Use the format, + /subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/{provider- + namespace}/{resource-type}/{resource-name}/Microsoft.Resources/links/{link-name}. For example, + /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup/Microsoft.Web/sites/mySite/Microsoft.Resources/links/myLink. :type link_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-09-01" + # Construct URL - url = self.delete.metadata['url'] + url = self.delete.metadata['url'] # type: ignore path_format_arguments = { - 'linkId': self._serialize.url("link_id", link_id, 'str', skip_quote=True) + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete.metadata = {'url': '/{linkId}'} + delete.metadata = {'url': '/{linkId}'} # type: ignore def create_or_update( - self, link_id, properties=None, custom_headers=None, raw=False, **operation_config): + self, + link_id, # type: str + properties=None, # type: Optional["models.ResourceLinkProperties"] + **kwargs # type: Any + ): + # type: (...) -> "models.ResourceLink" """Creates or updates a resource link between the specified resources. - :param link_id: The fully qualified ID of the resource link. Use the - format, - /subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/{provider-namespace}/{resource-type}/{resource-name}/Microsoft.Resources/links/{link-name}. - For example, - /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup/Microsoft.Web/sites/mySite/Microsoft.Resources/links/myLink + :param link_id: The fully qualified ID of the resource link. Use the format, + /subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/{provider- + namespace}/{resource-type}/{resource-name}/Microsoft.Resources/links/{link-name}. For example, + /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup/Microsoft.Web/sites/mySite/Microsoft.Resources/links/myLink. :type link_id: str :param properties: Properties for resource link. - :type properties: - ~azure.mgmt.resource.links.v2016_09_01.models.ResourceLinkProperties - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: ResourceLink or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.resource.links.v2016_09_01.models.ResourceLink or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :type properties: ~azure.mgmt.resource.links.v2016_09_01.models.ResourceLinkProperties + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceLink or the result of cls(response) + :rtype: ~azure.mgmt.resource.links.v2016_09_01.models.ResourceLink + :raises: ~azure.core.exceptions.HttpResponseError """ - parameters = models.ResourceLink(properties=properties) + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceLink"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.ResourceLink(properties=properties) + api_version = "2016-09-01" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.create_or_update.metadata['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) + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'ResourceLink') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 201]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ResourceLink', response) + deserialized = self._deserialize('ResourceLink', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('ResourceLink', response) + deserialized = self._deserialize('ResourceLink', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/{linkId}'} + create_or_update.metadata = {'url': '/{linkId}'} # type: ignore def get( - self, link_id, custom_headers=None, raw=False, **operation_config): + self, + link_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.ResourceLink" """Gets a resource link with the specified ID. - :param link_id: The fully qualified Id of the resource link. For - example, - /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup/Microsoft.Web/sites/mySite/Microsoft.Resources/links/myLink + :param link_id: The fully qualified Id of the resource link. For example, + /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup/Microsoft.Web/sites/mySite/Microsoft.Resources/links/myLink. :type link_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: ResourceLink or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.resource.links.v2016_09_01.models.ResourceLink or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceLink or the result of cls(response) + :rtype: ~azure.mgmt.resource.links.v2016_09_01.models.ResourceLink + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceLink"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-09-01" + # Construct URL - url = self.get.metadata['url'] + url = self.get.metadata['url'] # type: ignore path_format_arguments = { - 'linkId': self._serialize.url("link_id", link_id, 'str', skip_quote=True) + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('ResourceLink', response) + deserialized = self._deserialize('ResourceLink', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/{linkId}'} + get.metadata = {'url': '/{linkId}'} # type: ignore def list_at_subscription( - self, filter=None, custom_headers=None, raw=False, **operation_config): + self, + filter=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.ResourceLinkResult"] """Gets all the linked resources for the subscription. - :param filter: The filter to apply on the list resource links - operation. The supported filter for list resource links is targetId. - For example, $filter=targetId eq {value} + :param filter: The filter to apply on the list resource links operation. The supported filter + for list resource links is targetId. For example, $filter=targetId eq {value}. :type filter: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of ResourceLink - :rtype: - ~azure.mgmt.resource.links.v2016_09_01.models.ResourceLinkPaged[~azure.mgmt.resource.links.v2016_09_01.models.ResourceLink] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of ResourceLinkResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-09-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_at_subscription.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('ResourceLinkResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.ResourceLinkPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list_at_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/links'} + return ItemPaged( + get_next, extract_data + ) + list_at_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/links'} # type: ignore def list_at_source_scope( - self, scope, filter=None, custom_headers=None, raw=False, **operation_config): + self, + scope, # type: str + filter="atScope()", # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.ResourceLinkResult"] """Gets a list of resource links at and below the specified source scope. - :param scope: The fully qualified ID of the scope for getting the - resource links. For example, to list resource links at and under a - resource group, set the scope to - /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myGroup. + :param scope: The fully qualified ID of the scope for getting the resource links. For example, + to list resource links at and under a resource group, set the scope to + /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(). + :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(). :type filter: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of ResourceLink - :rtype: - ~azure.mgmt.resource.links.v2016_09_01.models.ResourceLinkPaged[~azure.mgmt.resource.links.v2016_09_01.models.ResourceLink] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of ResourceLinkResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-09-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_at_source_scope.metadata['url'] + url = self.list_at_source_scope.metadata['url'] # type: ignore path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True) + 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('ResourceLinkResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.ResourceLinkPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list_at_source_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/links'} + return ItemPaged( + get_next, extract_data + ) + list_at_source_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/links'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/py.typed b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/__init__.py index 5378dfa2cef6..fd369b92f054 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/__init__.py @@ -1,19 +1,16 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._configuration import ManagementLockClientConfiguration from ._management_lock_client import ManagementLockClient -__all__ = ['ManagementLockClient', 'ManagementLockClientConfiguration'] - -from ..version import VERSION - -__version__ = VERSION +__all__ = ['ManagementLockClient'] +try: + from ._patch import patch_sdk + patch_sdk() +except ImportError: + pass 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 d074a79033bd..52955a0a8ae9 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 @@ -1,48 +1,69 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrestazure import AzureConfiguration -from ..version import VERSION +from typing import TYPE_CHECKING +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + + from azure.core.credentials import TokenCredential + +VERSION = "unknown" + +class ManagementLockClientConfiguration(Configuration): + """Configuration for ManagementLockClient. -class ManagementLockClientConfiguration(AzureConfiguration): - """Configuration for ManagementLockClient Note that all parameters used to create this instance are saved as instance attributes. - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` + :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 """ def __init__( - self, credentials, subscription_id, base_url=None): - - if credentials is None: - raise ValueError("Parameter 'credentials' must not be None.") + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + 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.") - if not base_url: - base_url = 'https://management.azure.com' + super(ManagementLockClientConfiguration, self).__init__(**kwargs) - super(ManagementLockClientConfiguration, self).__init__(base_url) - - # Starting Autorest.Python 4.0.64, make connection pool activated by default - self.keep_alive = True - - self.add_user_agent('azure-mgmt-resource/{}'.format(VERSION)) - self.add_user_agent('Azure-SDK-For-Python') - - self.credentials = credentials + self.credential = credential self.subscription_id = subscription_id + self.api_version = "2016-09-01" + self.credential_scopes = ['https://management.azure.com/.default'] + self.credential_scopes.extend(kwargs.pop('credential_scopes', [])) + kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + 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) 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 8ca04c22123b..fd369b92f054 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 @@ -1,19 +1,16 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._configuration import ManagementLockClientConfiguration from ._management_lock_client import ManagementLockClient -__all__ = ['ManagementLockClient', 'ManagementLockClientConfiguration'] - -from .version import VERSION - -__version__ = VERSION +__all__ = ['ManagementLockClient'] +try: + from ._patch import patch_sdk + patch_sdk() +except ImportError: + pass 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 c3b09e729386..b68640f96441 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 @@ -1,48 +1,69 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrestazure import AzureConfiguration -from .version import VERSION +from typing import TYPE_CHECKING +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + + from azure.core.credentials import TokenCredential + +VERSION = "unknown" + +class ManagementLockClientConfiguration(Configuration): + """Configuration for ManagementLockClient. -class ManagementLockClientConfiguration(AzureConfiguration): - """Configuration for ManagementLockClient Note that all parameters used to create this instance are saved as instance attributes. - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` + :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 """ def __init__( - self, credentials, subscription_id, base_url=None): - - if credentials is None: - raise ValueError("Parameter 'credentials' must not be None.") + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + 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.") - if not base_url: - base_url = 'https://management.azure.com' + super(ManagementLockClientConfiguration, self).__init__(**kwargs) - super(ManagementLockClientConfiguration, self).__init__(base_url) - - # Starting Autorest.Python 4.0.64, make connection pool activated by default - self.keep_alive = True - - self.add_user_agent('azure-mgmt-resource/{}'.format(VERSION)) - self.add_user_agent('Azure-SDK-For-Python') - - self.credentials = credentials + self.credential = credential self.subscription_id = subscription_id + self.api_version = "2015-01-01" + self.credential_scopes = ['https://management.azure.com/.default'] + self.credential_scopes.extend(kwargs.pop('credential_scopes', [])) + kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + 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) 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 5ae586075e2e..a9a910500851 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 @@ -1,49 +1,67 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.service_client import SDKClient -from msrest import Serializer, Deserializer +from typing import TYPE_CHECKING + +from azure.mgmt.core import ARMPipelineClient +from msrest import Deserializer, Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional from ._configuration import ManagementLockClientConfiguration from .operations import ManagementLocksOperations from . import models -class ManagementLockClient(SDKClient): - """ManagementLockClient +class ManagementLockClient(object): + """ManagementLockClient. - :ivar config: Configuration for client. - :vartype config: ManagementLockClientConfiguration - - :ivar management_locks: ManagementLocks operations + :ivar management_locks: ManagementLocksOperations operations :vartype management_locks: azure.mgmt.resource.locks.v2015_01_01.operations.ManagementLocksOperations - - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` + :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. """ def __init__( - self, credentials, subscription_id, base_url=None): - - self.config = ManagementLockClientConfiguration(credentials, subscription_id, base_url) - super(ManagementLockClient, self).__init__(self.config.credentials, self.config) + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = 'https://management.azure.com' + self._config = ManagementLockClientConfiguration(credential, 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.api_version = '2015-01-01' self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self.management_locks = ManagementLocksOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> ManagementLockClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) 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 new file mode 100644 index 000000000000..dd149c317458 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/_metadata.json @@ -0,0 +1,53 @@ +{ + "chosen_version": "2015-01-01", + "total_api_version_list": ["2015-01-01"], + "client": { + "name": "ManagementLockClient", + "filename": "_management_lock_client", + "description": "ManagementLockClient." + }, + "global_parameters": { + "sync_method": { + "credential": { + "method_signature": "credential, # type: \"TokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials.TokenCredential", + "required": true + }, + "subscription_id": { + "method_signature": "subscription_id, # type: str", + "description": "The ID of the target subscription.", + "docstring_type": "str", + "required": true + } + }, + "async_method": { + "credential": { + "method_signature": "credential, # type: \"AsyncTokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + }, + "subscription_id": { + "method_signature": "subscription_id, # type: str", + "description": "The ID of the target subscription.", + "docstring_type": "str", + "required": true + } + }, + "constant": { + }, + "call": "credential, subscription_id" + }, + "config": { + "credential": true, + "credential_scopes": ["https://management.azure.com/.default"] + }, + "operation_groups": { + "management_locks": "ManagementLocksOperations" + }, + "operation_mixins": { + }, + "sync_imports": "None", + "async_imports": "None" +} \ No newline at end of file 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 new file mode 100644 index 000000000000..339f5c15f4fc --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/aio/__init__.py @@ -0,0 +1,10 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._management_lock_client_async import ManagementLockClient +__all__ = ['ManagementLockClient'] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/aio/_configuration_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/aio/_configuration_async.py new file mode 100644 index 000000000000..a272c8011c16 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/aio/_configuration_async.py @@ -0,0 +1,65 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + +VERSION = "unknown" + +class ManagementLockClientConfiguration(Configuration): + """Configuration for ManagementLockClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :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 + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + 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 + self.api_version = "2015-01-01" + self.credential_scopes = ['https://management.azure.com/.default'] + self.credential_scopes.extend(kwargs.pop('credential_scopes', [])) + kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs: Any + ) -> None: + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + 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) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/aio/_management_lock_client_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/aio/_management_lock_client_async.py new file mode 100644 index 000000000000..acad163bd83d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/aio/_management_lock_client_async.py @@ -0,0 +1,59 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, Optional + +from azure.mgmt.core import AsyncARMPipelineClient +from msrest import Deserializer, Serializer + +from ._configuration_async import ManagementLockClientConfiguration +from .operations_async import ManagementLocksOperations +from .. import models + + +class ManagementLockClient(object): + """ManagementLockClient. + + :ivar management_locks: ManagementLocksOperations operations + :vartype management_locks: azure.mgmt.resource.locks.v2015_01_01.aio.operations_async.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 + :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, + **kwargs: 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) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + + self.management_locks = ManagementLocksOperations( + self._client, self._config, self._serialize, self._deserialize) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "ManagementLockClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/aio/operations_async/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/aio/operations_async/__init__.py new file mode 100644 index 000000000000..0e57446c8686 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/aio/operations_async/__init__.py @@ -0,0 +1,13 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._management_locks_operations_async import ManagementLocksOperations + +__all__ = [ + 'ManagementLocksOperations', +] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/aio/operations_async/_management_locks_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/aio/operations_async/_management_locks_operations_async.py new file mode 100644 index 000000000000..a79e809f418a --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/aio/operations_async/_management_locks_operations_async.py @@ -0,0 +1,768 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import 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 ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ManagementLocksOperations: + """ManagementLocksOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.locks.v2015_01_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def create_or_update_at_resource_group_level( + self, + resource_group_name: str, + lock_name: str, + parameters: "models.ManagementLockObject", + **kwargs + ) -> "models.ManagementLockObject": + """Create or update a management lock at the resource group level. + + :param resource_group_name: The resource group name. + :type resource_group_name: str + :param lock_name: The lock name. + :type lock_name: str + :param parameters: The management lock parameters. + :type parameters: ~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockObject + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagementLockObject or the result of cls(response) + :rtype: ~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockObject + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ManagementLockObject"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2015-01-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ManagementLockObject', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ManagementLockObject', pipeline_response) + + if cls: + 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 + + async def delete_at_resource_group_level( + self, + resource_group_name: str, + lock_name: str, + **kwargs + ) -> None: + """Deletes the management lock of a resource group. + + :param resource_group_name: The resource group name. + :type resource_group_name: str + :param lock_name: The name of lock. + :type lock_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete_at_resource_group_level.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks/{lockName}'} # type: ignore + + async def get_at_resource_group_level( + self, + resource_group_name: str, + lock_name: str, + **kwargs + ) -> "models.ManagementLockObject": + """Gets a management lock at the resource group level. + + :param resource_group_name: The resource group name. + :type resource_group_name: str + :param lock_name: The lock name. + :type lock_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagementLockObject or the result of cls(response) + :rtype: ~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockObject + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ManagementLockObject"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2015-01-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ManagementLockObject', pipeline_response) + + if cls: + 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 + + async def create_or_update_at_resource_level( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + lock_name: str, + parameters: "models.ManagementLockObject", + **kwargs + ) -> "models.ManagementLockObject": + """Create or update a management lock at the resource level or any level below resource. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param resource_provider_namespace: Resource identity. + :type resource_provider_namespace: str + :param parent_resource_path: Resource identity. + :type parent_resource_path: str + :param resource_type: Resource identity. + :type resource_type: str + :param resource_name: Resource identity. + :type resource_name: str + :param lock_name: The name of lock. + :type lock_name: str + :param parameters: Create or update management lock parameters. + :type parameters: ~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockObject + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagementLockObject or the result of cls(response) + :rtype: ~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockObject + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ManagementLockObject"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2015-01-01" + content_type = kwargs.pop("content_type", "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'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ManagementLockObject', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ManagementLockObject', pipeline_response) + + if cls: + 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 + + async def delete_at_resource_level( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + lock_name: str, + **kwargs + ) -> None: + """Deletes the management lock of a resource or any level below resource. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param resource_provider_namespace: Resource identity. + :type resource_provider_namespace: str + :param parent_resource_path: Resource identity. + :type parent_resource_path: str + :param resource_type: Resource identity. + :type resource_type: str + :param resource_name: Resource identity. + :type resource_name: str + :param lock_name: The name of lock. + :type lock_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete_at_resource_level.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks/{lockName}'} # type: ignore + + async def create_or_update_at_subscription_level( + self, + lock_name: str, + parameters: "models.ManagementLockObject", + **kwargs + ) -> "models.ManagementLockObject": + """Create or update a management lock at the subscription level. + + :param lock_name: The name of lock. + :type lock_name: str + :param parameters: The management lock parameters. + :type parameters: ~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockObject + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagementLockObject or the result of cls(response) + :rtype: ~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockObject + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ManagementLockObject"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2015-01-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ManagementLockObject', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ManagementLockObject', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update_at_subscription_level.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks/{lockName}'} # type: ignore + + async def delete_at_subscription_level( + self, + lock_name: str, + **kwargs + ) -> None: + """Deletes the management lock of a subscription. + + :param lock_name: The name of lock. + :type lock_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete_at_subscription_level.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks/{lockName}'} # type: ignore + + async def get( + self, + lock_name: str, + **kwargs + ) -> "models.ManagementLockObject": + """Gets the management lock of a scope. + + :param lock_name: Name of the management lock. + :type lock_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagementLockObject or the result of cls(response) + :rtype: ~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockObject + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ManagementLockObject"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2015-01-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ManagementLockObject', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks/{lockName}'} # type: ignore + + def list_at_resource_group_level( + self, + resource_group_name: str, + filter: Optional[str] = None, + **kwargs + ) -> AsyncIterable["models.ManagementLockListResult"]: + """Gets all the management locks of a resource group. + + :param resource_group_name: Resource group name. + :type resource_group_name: str + :param filter: The filter to apply on the operation. + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2015-01-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ManagementLockListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + 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 + + def list_at_resource_level( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + filter: Optional[str] = None, + **kwargs + ) -> AsyncIterable["models.ManagementLockListResult"]: + """Gets all the management locks of a resource or any level below resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param resource_provider_namespace: Resource identity. + :type resource_provider_namespace: str + :param parent_resource_path: Resource identity. + :type parent_resource_path: str + :param resource_type: Resource identity. + :type resource_type: str + :param resource_name: Resource identity. + :type resource_name: str + :param filter: The filter to apply on the operation. + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2015-01-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ManagementLockListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + 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 + + def list_at_subscription_level( + self, + filter: Optional[str] = None, + **kwargs + ) -> AsyncIterable["models.ManagementLockListResult"]: + """Gets all the management locks of a subscription. + + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2015-01-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ManagementLockListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_at_subscription_level.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/models/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/models/__init__.py index d76ef58de059..334bcad5b6d2 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/models/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/models/__init__.py @@ -1,25 +1,24 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- try: + from ._models_py3 import ManagementLockListResult from ._models_py3 import ManagementLockObject except (SyntaxError, ImportError): - from ._models import ManagementLockObject -from ._paged_models import ManagementLockObjectPaged + from ._models import ManagementLockListResult # type: ignore + from ._models import ManagementLockObject # type: ignore + from ._management_lock_client_enums import ( LockLevel, ) __all__ = [ + 'ManagementLockListResult', 'ManagementLockObject', - 'ManagementLockObjectPaged', 'LockLevel', ] 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 296c12a6a3e3..3b1be07cd442 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 @@ -1,18 +1,16 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from enum import Enum - class LockLevel(str, Enum): + """The lock level of the management lock. + """ not_specified = "NotSpecified" can_not_delete = "CanNotDelete" 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 f5995cc826f5..4c621de1cf85 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 @@ -1,43 +1,53 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.serialization import Model +import msrest.serialization -class CloudError(Model): - """CloudError. +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 """ _attribute_map = { + 'value': {'key': 'value', 'type': '[ManagementLockObject]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, } + def __init__( + self, + **kwargs + ): + super(ManagementLockListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + -class ManagementLockObject(Model): +class ManagementLockObject(msrest.serialization.Model): """Management lock information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :param 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 :ivar id: The Id of the lock. :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", + "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 """ _validation = { @@ -46,17 +56,20 @@ class ManagementLockObject(Model): } _attribute_map = { - 'level': {'key': 'properties.level', 'type': 'str'}, - 'notes': {'key': 'properties.notes', 'type': 'str'}, 'id': {'key': 'id', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, + 'level': {'key': 'properties.level', 'type': 'str'}, + 'notes': {'key': 'properties.notes', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ManagementLockObject, self).__init__(**kwargs) - self.level = kwargs.get('level', None) - self.notes = kwargs.get('notes', None) self.id = None self.type = None self.name = kwargs.get('name', None) + self.level = kwargs.get('level', None) + self.notes = kwargs.get('notes', 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 f57e8ed7b8c2..08cb43d07716 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 @@ -1,43 +1,60 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.serialization import Model +from typing import List, Optional, Union +import msrest.serialization -class CloudError(Model): - """CloudError. +from ._management_lock_client_enums import * + + +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 """ _attribute_map = { + 'value': {'key': 'value', 'type': '[ManagementLockObject]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, } + def __init__( + self, + *, + value: Optional[List["ManagementLockObject"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(ManagementLockListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + -class ManagementLockObject(Model): +class ManagementLockObject(msrest.serialization.Model): """Management lock information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :param 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 :ivar id: The Id of the lock. :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", + "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 """ _validation = { @@ -46,17 +63,24 @@ class ManagementLockObject(Model): } _attribute_map = { - 'level': {'key': 'properties.level', 'type': 'str'}, - 'notes': {'key': 'properties.notes', 'type': 'str'}, 'id': {'key': 'id', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, + 'level': {'key': 'properties.level', 'type': 'str'}, + 'notes': {'key': 'properties.notes', 'type': 'str'}, } - def __init__(self, *, level=None, notes: str=None, name: str=None, **kwargs) -> None: + def __init__( + self, + *, + name: Optional[str] = None, + level: Optional[Union[str, "LockLevel"]] = None, + notes: Optional[str] = None, + **kwargs + ): super(ManagementLockObject, self).__init__(**kwargs) - self.level = level - self.notes = notes self.id = None self.type = None self.name = name + self.level = level + self.notes = notes diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/models/_paged_models.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/models/_paged_models.py deleted file mode 100644 index e8d1073f92f8..000000000000 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/models/_paged_models.py +++ /dev/null @@ -1,27 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.paging import Paged - - -class ManagementLockObjectPaged(Paged): - """ - A paging container for iterating over a list of :class:`ManagementLockObject ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[ManagementLockObject]'} - } - - def __init__(self, *args, **kwargs): - - super(ManagementLockObjectPaged, self).__init__(*args, **kwargs) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/operations/__init__.py index 17e19bf55118..5e1428bdc61f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/operations/__init__.py @@ -1,12 +1,9 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from ._management_locks_operations import ManagementLocksOperations 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 e7e6241ecf38..0f6e7bafa980 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 @@ -1,46 +1,58 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class ManagementLocksOperations(object): """ManagementLocksOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.locks.v2015_01_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for the operation. Constant value: "2015-01-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2015-01-01" - - self.config = config + self._config = config def create_or_update_at_resource_group_level( - self, resource_group_name, lock_name, parameters, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + lock_name, # type: str + parameters, # type: "models.ManagementLockObject" + **kwargs # type: Any + ): + # type: (...) -> "models.ManagementLockObject" """Create or update a management lock at the resource group level. :param resource_group_name: The resource group name. @@ -48,187 +60,185 @@ def create_or_update_at_resource_group_level( :param lock_name: The lock name. :type lock_name: str :param parameters: The management lock parameters. - :type parameters: - ~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockObject - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: ManagementLockObject or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockObject or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :type parameters: ~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockObject + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagementLockObject or the result of cls(response) + :rtype: ~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockObject + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ManagementLockObject"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2015-01-01" + content_type = kwargs.pop("content_type", "application/json") + # Construct URL - url = self.create_or_update_at_resource_group_level.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'ManagementLockObject') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 201]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ManagementLockObject', response) + deserialized = self._deserialize('ManagementLockObject', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('ManagementLockObject', response) + deserialized = self._deserialize('ManagementLockObject', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + 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}'} + create_or_update_at_resource_group_level.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks/{lockName}'} # type: ignore def delete_at_resource_group_level( - self, resource_group_name, lock_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + lock_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Deletes the management lock of a resource group. :param resource_group_name: The resource group name. :type resource_group_name: str :param lock_name: The name of lock. :type lock_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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'] + 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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete_at_resource_group_level.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks/{lockName}'} + delete_at_resource_group_level.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks/{lockName}'} # type: ignore def get_at_resource_group_level( - self, resource_group_name, lock_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + lock_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.ManagementLockObject" """Gets a management lock at the resource group level. :param resource_group_name: The resource group name. :type resource_group_name: str :param lock_name: The lock name. :type lock_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: ManagementLockObject or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockObject or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagementLockObject or the result of cls(response) + :rtype: ~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockObject + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ManagementLockObject"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2015-01-01" + # Construct URL - url = self.get_at_resource_group_level.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('ManagementLockObject', response) + deserialized = self._deserialize('ManagementLockObject', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get_at_resource_group_level.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks/{lockName}'} + get_at_resource_group_level.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks/{lockName}'} # type: ignore def create_or_update_at_resource_level( - self, resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, lock_name, parameters, custom_headers=None, raw=False, **operation_config): - """Create or update a management lock at the resource level or any level - below resource. + self, + 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 + parameters, # type: "models.ManagementLockObject" + **kwargs # type: Any + ): + # type: (...) -> "models.ManagementLockObject" + """Create or update a management lock at the resource level or any level below resource. :param resource_group_name: The name of the resource group. :type resource_group_name: str @@ -243,21 +253,20 @@ def create_or_update_at_resource_level( :param lock_name: The name of lock. :type lock_name: str :param parameters: Create or update management lock parameters. - :type parameters: - ~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockObject - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: ManagementLockObject or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockObject or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :type parameters: ~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockObject + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagementLockObject or the result of cls(response) + :rtype: ~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockObject + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ManagementLockObject"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2015-01-01" + content_type = kwargs.pop("content_type", "application/json") + # Construct URL - url = self.create_or_update_at_resource_level.metadata['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'), @@ -265,52 +274,56 @@ def create_or_update_at_resource_level( '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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'ManagementLockObject') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 201]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ManagementLockObject', response) + deserialized = self._deserialize('ManagementLockObject', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('ManagementLockObject', response) + deserialized = self._deserialize('ManagementLockObject', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + 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}'} + create_or_update_at_resource_level.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks/{lockName}'} # type: ignore def delete_at_resource_level( - self, resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, lock_name, custom_headers=None, raw=False, **operation_config): + self, + 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 + **kwargs # type: Any + ): + # type: (...) -> None """Deletes the management lock of a resource or any level below resource. :param resource_group_name: The name of the resource group. @@ -325,17 +338,18 @@ def delete_at_resource_level( :type resource_name: str :param lock_name: The name of lock. :type lock_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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'] + 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'), @@ -343,294 +357,287 @@ def delete_at_resource_level( '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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete_at_resource_level.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks/{lockName}'} + if cls: + return cls(pipeline_response, None, {}) + + delete_at_resource_level.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks/{lockName}'} # type: ignore def create_or_update_at_subscription_level( - self, lock_name, parameters, custom_headers=None, raw=False, **operation_config): + self, + lock_name, # type: str + parameters, # type: "models.ManagementLockObject" + **kwargs # type: Any + ): + # type: (...) -> "models.ManagementLockObject" """Create or update a management lock at the subscription level. :param lock_name: The name of lock. :type lock_name: str :param parameters: The management lock parameters. - :type parameters: - ~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockObject - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: ManagementLockObject or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockObject or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :type parameters: ~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockObject + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagementLockObject or the result of cls(response) + :rtype: ~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockObject + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ManagementLockObject"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2015-01-01" + content_type = kwargs.pop("content_type", "application/json") + # Construct URL - url = self.create_or_update_at_subscription_level.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'ManagementLockObject') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 201]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ManagementLockObject', response) + deserialized = self._deserialize('ManagementLockObject', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('ManagementLockObject', response) + deserialized = self._deserialize('ManagementLockObject', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_at_subscription_level.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks/{lockName}'} + create_or_update_at_subscription_level.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks/{lockName}'} # type: ignore def delete_at_subscription_level( - self, lock_name, custom_headers=None, raw=False, **operation_config): + self, + lock_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Deletes the management lock of a subscription. :param lock_name: The name of lock. :type lock_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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'] + 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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete_at_subscription_level.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks/{lockName}'} + delete_at_subscription_level.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks/{lockName}'} # type: ignore def get( - self, lock_name, custom_headers=None, raw=False, **operation_config): + self, + lock_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.ManagementLockObject" """Gets the management lock of a scope. :param lock_name: Name of the management lock. :type lock_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: ManagementLockObject or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockObject or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagementLockObject or the result of cls(response) + :rtype: ~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockObject + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ManagementLockObject"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2015-01-01" + # Construct URL - url = self.get.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('ManagementLockObject', response) + deserialized = self._deserialize('ManagementLockObject', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks/{lockName}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks/{lockName}'} # type: ignore def list_at_resource_group_level( - self, resource_group_name, filter=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + filter=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.ManagementLockListResult"] """Gets all the management locks of a resource group. :param resource_group_name: Resource group name. :type resource_group_name: str :param filter: The filter to apply on the operation. :type filter: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of ManagementLockObject - :rtype: - ~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockObjectPaged[~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockObject] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2015-01-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_at_resource_group_level.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('ManagementLockListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.ManagementLockObjectPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_at_resource_group_level.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks'} + return ItemPaged( + get_next, extract_data + ) + list_at_resource_group_level.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks'} # type: ignore def list_at_resource_level( - self, resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, filter=None, custom_headers=None, raw=False, **operation_config): - """Gets all the management locks of a resource or any level below - resource. - - :param resource_group_name: The name of the resource group. The name - is case insensitive. + self, + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + filter=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.ManagementLockListResult"] + """Gets all the management locks of a resource or any level below resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param resource_provider_namespace: Resource identity. :type resource_provider_namespace: str @@ -642,141 +649,135 @@ def list_at_resource_level( :type resource_name: str :param filter: The filter to apply on the operation. :type filter: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of ManagementLockObject - :rtype: - ~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockObjectPaged[~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockObject] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2015-01-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_at_resource_level.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('ManagementLockListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.ManagementLockObjectPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list_at_resource_level.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks'} + 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 def list_at_subscription_level( - self, filter=None, custom_headers=None, raw=False, **operation_config): + self, + filter=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.ManagementLockListResult"] """Gets all the management locks of a subscription. :param filter: The filter to apply on the operation. :type filter: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of ManagementLockObject - :rtype: - ~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockObjectPaged[~azure.mgmt.resource.locks.v2015_01_01.models.ManagementLockObject] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2015-01-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_at_subscription_level.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('ManagementLockListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.ManagementLockObjectPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list_at_subscription_level.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks'} + return ItemPaged( + get_next, extract_data + ) + list_at_subscription_level.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/py.typed b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file 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 8ca04c22123b..fd369b92f054 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 @@ -1,19 +1,16 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._configuration import ManagementLockClientConfiguration from ._management_lock_client import ManagementLockClient -__all__ = ['ManagementLockClient', 'ManagementLockClientConfiguration'] - -from .version import VERSION - -__version__ = VERSION +__all__ = ['ManagementLockClient'] +try: + from ._patch import patch_sdk + patch_sdk() +except ImportError: + pass 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 c3b09e729386..52955a0a8ae9 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 @@ -1,48 +1,69 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrestazure import AzureConfiguration -from .version import VERSION +from typing import TYPE_CHECKING +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + + from azure.core.credentials import TokenCredential + +VERSION = "unknown" + +class ManagementLockClientConfiguration(Configuration): + """Configuration for ManagementLockClient. -class ManagementLockClientConfiguration(AzureConfiguration): - """Configuration for ManagementLockClient Note that all parameters used to create this instance are saved as instance attributes. - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` + :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 """ def __init__( - self, credentials, subscription_id, base_url=None): - - if credentials is None: - raise ValueError("Parameter 'credentials' must not be None.") + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + 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.") - if not base_url: - base_url = 'https://management.azure.com' + super(ManagementLockClientConfiguration, self).__init__(**kwargs) - super(ManagementLockClientConfiguration, self).__init__(base_url) - - # Starting Autorest.Python 4.0.64, make connection pool activated by default - self.keep_alive = True - - self.add_user_agent('azure-mgmt-resource/{}'.format(VERSION)) - self.add_user_agent('Azure-SDK-For-Python') - - self.credentials = credentials + self.credential = credential self.subscription_id = subscription_id + self.api_version = "2016-09-01" + self.credential_scopes = ['https://management.azure.com/.default'] + self.credential_scopes.extend(kwargs.pop('credential_scopes', [])) + kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + 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) 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 60842d7ec0ba..217f2ded956e 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 @@ -1,54 +1,72 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.service_client import SDKClient -from msrest import Serializer, Deserializer +from typing import TYPE_CHECKING + +from azure.mgmt.core import ARMPipelineClient +from msrest import Deserializer, Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional from ._configuration import ManagementLockClientConfiguration -from .operations import AuthorizationOperations +from .operations import AuthorizationOperationsOperations from .operations import ManagementLocksOperations from . import models -class ManagementLockClient(SDKClient): +class ManagementLockClient(object): """Azure resources can be locked to prevent other users in your organization from deleting or modifying resources. - :ivar config: Configuration for client. - :vartype config: ManagementLockClientConfiguration - - :ivar authorization_operations: AuthorizationOperations operations - :vartype authorization_operations: azure.mgmt.resource.locks.v2016_09_01.operations.AuthorizationOperations - :ivar management_locks: ManagementLocks operations + :ivar authorization_operations: AuthorizationOperationsOperations operations + :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 - - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` + :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. """ def __init__( - self, credentials, subscription_id, base_url=None): - - self.config = ManagementLockClientConfiguration(credentials, subscription_id, base_url) - super(ManagementLockClient, self).__init__(self.config.credentials, self.config) + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = 'https://management.azure.com' + self._config = ManagementLockClientConfiguration(credential, 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.api_version = '2016-09-01' self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) - self.authorization_operations = AuthorizationOperations( - 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) + self._client, self._config, self._serialize, self._deserialize) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> ManagementLockClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) 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 new file mode 100644 index 000000000000..db182c55c889 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/_metadata.json @@ -0,0 +1,54 @@ +{ + "chosen_version": "2016-09-01", + "total_api_version_list": ["2016-09-01"], + "client": { + "name": "ManagementLockClient", + "filename": "_management_lock_client", + "description": "Azure resources can be locked to prevent other users in your organization from deleting or modifying resources." + }, + "global_parameters": { + "sync_method": { + "credential": { + "method_signature": "credential, # type: \"TokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials.TokenCredential", + "required": true + }, + "subscription_id": { + "method_signature": "subscription_id, # type: str", + "description": "The ID of the target subscription.", + "docstring_type": "str", + "required": true + } + }, + "async_method": { + "credential": { + "method_signature": "credential, # type: \"AsyncTokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + }, + "subscription_id": { + "method_signature": "subscription_id, # type: str", + "description": "The ID of the target subscription.", + "docstring_type": "str", + "required": true + } + }, + "constant": { + }, + "call": "credential, subscription_id" + }, + "config": { + "credential": true, + "credential_scopes": ["https://management.azure.com/.default"] + }, + "operation_groups": { + "authorization_operations": "AuthorizationOperationsOperations", + "management_locks": "ManagementLocksOperations" + }, + "operation_mixins": { + }, + "sync_imports": "None", + "async_imports": "None" +} \ No newline at end of file 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 new file mode 100644 index 000000000000..339f5c15f4fc --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/aio/__init__.py @@ -0,0 +1,10 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._management_lock_client_async import ManagementLockClient +__all__ = ['ManagementLockClient'] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/aio/_configuration_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/aio/_configuration_async.py new file mode 100644 index 000000000000..0c4568df4329 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/aio/_configuration_async.py @@ -0,0 +1,65 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + +VERSION = "unknown" + +class ManagementLockClientConfiguration(Configuration): + """Configuration for ManagementLockClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :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 + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + 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 + self.api_version = "2016-09-01" + self.credential_scopes = ['https://management.azure.com/.default'] + self.credential_scopes.extend(kwargs.pop('credential_scopes', [])) + kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs: Any + ) -> None: + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + 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) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/aio/_management_lock_client_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/aio/_management_lock_client_async.py new file mode 100644 index 000000000000..a5a09a7dc96b --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/aio/_management_lock_client_async.py @@ -0,0 +1,64 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, Optional + +from azure.mgmt.core import AsyncARMPipelineClient +from msrest import Deserializer, Serializer + +from ._configuration_async import ManagementLockClientConfiguration +from .operations_async import AuthorizationOperationsOperations +from .operations_async import ManagementLocksOperations +from .. import models + + +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.aio.operations_async.AuthorizationOperationsOperations + :ivar management_locks: ManagementLocksOperations operations + :vartype management_locks: azure.mgmt.resource.locks.v2016_09_01.aio.operations_async.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 + :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, + **kwargs: 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) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + + self.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 close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "ManagementLockClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/aio/operations_async/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/aio/operations_async/__init__.py new file mode 100644 index 000000000000..713d2aa2b59e --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/aio/operations_async/__init__.py @@ -0,0 +1,15 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._authorization_operations_operations_async import AuthorizationOperationsOperations +from ._management_locks_operations_async import ManagementLocksOperations + +__all__ = [ + 'AuthorizationOperationsOperations', + 'ManagementLocksOperations', +] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/aio/operations_async/_authorization_operations_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/aio/operations_async/_authorization_operations_operations_async.py new file mode 100644 index 000000000000..29d19b10bf00 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/aio/operations_async/_authorization_operations_operations_async.py @@ -0,0 +1,101 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import 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 ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class AuthorizationOperationsOperations: + """AuthorizationOperationsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.locks.v2016_09_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + **kwargs + ) -> AsyncIterable["models.OperationListResult"]: + """Lists all of the available Microsoft.Authorization REST API operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of OperationListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-09-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('OperationListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.Authorization/operations'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/aio/operations_async/_management_locks_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/aio/operations_async/_management_locks_operations_async.py new file mode 100644 index 000000000000..1ab5cb6658e6 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/aio/operations_async/_management_locks_operations_async.py @@ -0,0 +1,1113 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import 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 ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ManagementLocksOperations: + """ManagementLocksOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.locks.v2016_09_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def create_or_update_at_resource_group_level( + self, + resource_group_name: str, + lock_name: str, + parameters: "models.ManagementLockObject", + **kwargs + ) -> "models.ManagementLockObject": + """When you apply a lock at a parent scope, all child resources inherit the same lock. To create management locks, you must have access to Microsoft.Authorization/\ * or Microsoft.Authorization/locks/* actions. Of the built-in roles, only Owner and User Access Administrator are granted those actions. + + Creates or updates a management lock at the resource group level. + + :param resource_group_name: The name of the resource group to lock. + :type resource_group_name: str + :param lock_name: The lock name. The lock name can be a maximum of 260 characters. It cannot + contain <, > %, &, :, \, ?, /, or any control characters. + :type lock_name: str + :param parameters: The management lock parameters. + :type parameters: ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagementLockObject or the result of cls(response) + :rtype: ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ManagementLockObject"] + error_map = {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.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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ManagementLockObject', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ManagementLockObject', pipeline_response) + + if cls: + 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 + + async def delete_at_resource_group_level( + self, + resource_group_name: str, + lock_name: str, + **kwargs + ) -> None: + """To delete management locks, you must have access to Microsoft.Authorization/\ * or Microsoft.Authorization/locks/* actions. Of the built-in roles, only Owner and User Access Administrator are granted those actions. + + Deletes a management lock at the resource group level. + + :param resource_group_name: The name of the resource group containing the lock. + :type resource_group_name: str + :param lock_name: The name of lock to delete. + :type lock_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete_at_resource_group_level.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks/{lockName}'} # type: ignore + + async def get_at_resource_group_level( + self, + resource_group_name: str, + lock_name: str, + **kwargs + ) -> "models.ManagementLockObject": + """Gets a management lock at the resource group level. + + :param resource_group_name: The name of the locked resource group. + :type resource_group_name: str + :param lock_name: The name of the lock to get. + :type lock_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagementLockObject or the result of cls(response) + :rtype: ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ManagementLockObject"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-09-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ManagementLockObject', pipeline_response) + + if cls: + 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 + + async def create_or_update_by_scope( + self, + scope: str, + lock_name: str, + parameters: "models.ManagementLockObject", + **kwargs + ) -> "models.ManagementLockObject": + """Create or update a management lock by scope. + + :param scope: The scope for the lock. When providing a scope for the assignment, use + '/subscriptions/{subscriptionId}' for subscriptions, + '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}' for resource groups, and + '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePathIfPresent}/{resourceType}/{resourceName}' + for resources. + :type scope: str + :param lock_name: The name of lock. + :type lock_name: str + :param parameters: Create or update management lock parameters. + :type parameters: ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagementLockObject or the result of cls(response) + :rtype: ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ManagementLockObject"] + error_map = {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.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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ManagementLockObject', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ManagementLockObject', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update_by_scope.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/locks/{lockName}'} # type: ignore + + async def delete_by_scope( + self, + scope: str, + lock_name: str, + **kwargs + ) -> None: + """Delete a management lock by scope. + + :param scope: The scope for the lock. + :type scope: str + :param lock_name: The name of lock. + :type lock_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete_by_scope.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/locks/{lockName}'} # type: ignore + + async def get_by_scope( + self, + scope: str, + lock_name: str, + **kwargs + ) -> "models.ManagementLockObject": + """Get a management lock by scope. + + :param scope: The scope for the lock. + :type scope: str + :param lock_name: The name of lock. + :type lock_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagementLockObject or the result of cls(response) + :rtype: ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ManagementLockObject"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-09-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ManagementLockObject', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_by_scope.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/locks/{lockName}'} # type: ignore + + async def create_or_update_at_resource_level( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + lock_name: str, + parameters: "models.ManagementLockObject", + **kwargs + ) -> "models.ManagementLockObject": + """When you apply a lock at a parent scope, all child resources inherit the same lock. To create management locks, you must have access to Microsoft.Authorization/\ * or Microsoft.Authorization/locks/* actions. Of the built-in roles, only Owner and User Access Administrator are granted those actions. + + Creates or updates a management lock at the resource level or any level below the resource. + + :param resource_group_name: The name of the resource group containing the resource to lock. + :type resource_group_name: str + :param resource_provider_namespace: The resource provider namespace of the resource to lock. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to lock. + :type resource_type: str + :param resource_name: The name of the resource to lock. + :type resource_name: str + :param lock_name: The name of lock. The lock name can be a maximum of 260 characters. It cannot + contain <, > %, &, :, \, ?, /, or any control characters. + :type lock_name: str + :param parameters: Parameters for creating or updating a management lock. + :type parameters: ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagementLockObject or the result of cls(response) + :rtype: ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ManagementLockObject"] + error_map = {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.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'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ManagementLockObject', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ManagementLockObject', pipeline_response) + + if cls: + 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 + + async def delete_at_resource_level( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + lock_name: str, + **kwargs + ) -> None: + """To delete management locks, you must have access to Microsoft.Authorization/\ * or Microsoft.Authorization/locks/* actions. Of the built-in roles, only Owner and User Access Administrator are granted those actions. + + Deletes the management lock of a resource or any level below the resource. + + :param resource_group_name: The name of the resource group containing the resource with the + lock to delete. + :type resource_group_name: str + :param resource_provider_namespace: The resource provider namespace of the resource with the + lock to delete. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. + :type parent_resource_path: str + :param resource_type: The resource type of the resource with the lock to delete. + :type resource_type: str + :param resource_name: The name of the resource with the lock to delete. + :type resource_name: str + :param lock_name: The name of the lock to delete. + :type lock_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete_at_resource_level.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks/{lockName}'} # type: ignore + + async def get_at_resource_level( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + lock_name: str, + **kwargs + ) -> "models.ManagementLockObject": + """Get the management lock of a resource or any level below resource. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. + :type resource_provider_namespace: str + :param parent_resource_path: An extra path parameter needed in some services, like SQL + Databases. + :type parent_resource_path: str + :param resource_type: The type of the resource. + :type resource_type: str + :param resource_name: The name of the resource. + :type resource_name: str + :param lock_name: The name of lock. + :type lock_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagementLockObject or the result of cls(response) + :rtype: ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ManagementLockObject"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-09-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ManagementLockObject', pipeline_response) + + if cls: + 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 + + async def create_or_update_at_subscription_level( + self, + lock_name: str, + parameters: "models.ManagementLockObject", + **kwargs + ) -> "models.ManagementLockObject": + """When you apply a lock at a parent scope, all child resources inherit the same lock. To create management locks, you must have access to Microsoft.Authorization/\ * or Microsoft.Authorization/locks/* actions. Of the built-in roles, only Owner and User Access Administrator are granted those actions. + + Creates or updates a management lock at the subscription level. + + :param lock_name: The name of lock. The lock name can be a maximum of 260 characters. It cannot + contain <, > %, &, :, \, ?, /, or any control characters. + :type lock_name: str + :param parameters: The management lock parameters. + :type parameters: ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagementLockObject or the result of cls(response) + :rtype: ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ManagementLockObject"] + error_map = {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.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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ManagementLockObject', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ManagementLockObject', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update_at_subscription_level.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks/{lockName}'} # type: ignore + + async def delete_at_subscription_level( + self, + lock_name: str, + **kwargs + ) -> None: + """To delete management locks, you must have access to Microsoft.Authorization/\ * or Microsoft.Authorization/locks/* actions. Of the built-in roles, only Owner and User Access Administrator are granted those actions. + + Deletes the management lock at the subscription level. + + :param lock_name: The name of lock to delete. + :type lock_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete_at_subscription_level.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks/{lockName}'} # type: ignore + + async def get_at_subscription_level( + self, + lock_name: str, + **kwargs + ) -> "models.ManagementLockObject": + """Gets a management lock at the subscription level. + + :param lock_name: The name of the lock to get. + :type lock_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagementLockObject or the result of cls(response) + :rtype: ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ManagementLockObject"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-09-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ManagementLockObject', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_at_subscription_level.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks/{lockName}'} # type: ignore + + def list_at_resource_group_level( + self, + resource_group_name: str, + filter: Optional[str] = None, + **kwargs + ) -> AsyncIterable["models.ManagementLockListResult"]: + """Gets all the management locks for a resource group. + + :param resource_group_name: The name of the resource group containing the locks to get. + :type resource_group_name: str + :param filter: The filter to apply on the operation. + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-09-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ManagementLockListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + 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 + + def list_at_resource_level( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + filter: Optional[str] = None, + **kwargs + ) -> AsyncIterable["models.ManagementLockListResult"]: + """Gets all the management locks for a resource or any level below resource. + + :param resource_group_name: The name of the resource group containing the locked resource. The + name is case insensitive. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. + :type parent_resource_path: str + :param resource_type: The resource type of the locked resource. + :type resource_type: str + :param resource_name: The name of the locked resource. + :type resource_name: str + :param filter: The filter to apply on the operation. + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-09-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ManagementLockListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + 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 + + def list_at_subscription_level( + self, + filter: Optional[str] = None, + **kwargs + ) -> AsyncIterable["models.ManagementLockListResult"]: + """Gets all the management locks for a subscription. + + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-09-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ManagementLockListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_at_subscription_level.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks'} # type: ignore + + def list_by_scope( + self, + scope: str, + filter: Optional[str] = None, + **kwargs + ) -> AsyncIterable["models.ManagementLockListResult"]: + """Gets all the management locks for a scope. + + :param scope: The scope for the lock. When providing a scope for the assignment, use + '/subscriptions/{subscriptionId}' for subscriptions, + '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}' for resource groups, and + '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePathIfPresent}/{resourceType}/{resourceName}' + for resources. + :type scope: str + :param filter: The filter to apply on the operation. + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-09-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ManagementLockListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_scope.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/locks'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/models/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/models/__init__.py index 496faee140a6..3b51e2bf1eec 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/models/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/models/__init__.py @@ -1,36 +1,36 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- try: + from ._models_py3 import ManagementLockListResult from ._models_py3 import ManagementLockObject from ._models_py3 import ManagementLockOwner from ._models_py3 import Operation from ._models_py3 import OperationDisplay + from ._models_py3 import OperationListResult except (SyntaxError, ImportError): - from ._models import ManagementLockObject - from ._models import ManagementLockOwner - from ._models import Operation - from ._models import OperationDisplay -from ._paged_models import ManagementLockObjectPaged -from ._paged_models import OperationPaged + from ._models import ManagementLockListResult # type: ignore + from ._models import ManagementLockObject # type: ignore + from ._models import ManagementLockOwner # type: ignore + from ._models import Operation # type: ignore + from ._models import OperationDisplay # type: ignore + from ._models import OperationListResult # type: ignore + from ._management_lock_client_enums import ( LockLevel, ) __all__ = [ + 'ManagementLockListResult', 'ManagementLockObject', 'ManagementLockOwner', 'Operation', 'OperationDisplay', - 'OperationPaged', - 'ManagementLockObjectPaged', + 'OperationListResult', 'LockLevel', ] 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 296c12a6a3e3..09944d0f1ac9 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 @@ -1,18 +1,18 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from enum import Enum - class LockLevel(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. + """ not_specified = "NotSpecified" can_not_delete = "CanNotDelete" 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 cd74807963c5..a34b7d07ec8a 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 @@ -1,81 +1,91 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.serialization import Model +import msrest.serialization -class CloudError(Model): - """CloudError. +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 """ _attribute_map = { + 'value': {'key': 'value', 'type': '[ManagementLockObject]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, } + def __init__( + self, + **kwargs + ): + super(ManagementLockListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + -class ManagementLockObject(Model): +class ManagementLockObject(msrest.serialization.Model): """The lock information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :param 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] :ivar id: The resource ID of the lock. :vartype id: str :ivar type: The resource type of the lock - Microsoft.Authorization/locks. :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, + 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] """ _validation = { - 'level': {'required': True}, 'id': {'readonly': True}, 'type': {'readonly': True}, 'name': {'readonly': True}, + 'level': {'required': True}, } _attribute_map = { - 'level': {'key': 'properties.level', 'type': 'str'}, - 'notes': {'key': 'properties.notes', 'type': 'str'}, - 'owners': {'key': 'properties.owners', 'type': '[ManagementLockOwner]'}, 'id': {'key': 'id', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, + 'level': {'key': 'properties.level', 'type': 'str'}, + 'notes': {'key': 'properties.notes', 'type': 'str'}, + 'owners': {'key': 'properties.owners', 'type': '[ManagementLockOwner]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ManagementLockObject, self).__init__(**kwargs) - self.level = kwargs.get('level', None) - self.notes = kwargs.get('notes', None) - self.owners = kwargs.get('owners', None) self.id = None self.type = None self.name = None + self.level = kwargs['level'] + self.notes = kwargs.get('notes', None) + self.owners = kwargs.get('owners', None) -class ManagementLockOwner(Model): +class ManagementLockOwner(msrest.serialization.Model): """Lock owner properties. :param application_id: The application ID of the lock owner. @@ -86,19 +96,21 @@ class ManagementLockOwner(Model): 'application_id': {'key': 'applicationId', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ManagementLockOwner, self).__init__(**kwargs) self.application_id = kwargs.get('application_id', None) -class Operation(Model): +class Operation(msrest.serialization.Model): """Microsoft.Authorization operation. - :param name: Operation name: {provider}/{resource}/{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 + :type display: ~azure.mgmt.resource.locks.v2016_09_01.models.OperationDisplay """ _attribute_map = { @@ -106,19 +118,21 @@ class Operation(Model): 'display': {'key': 'display', 'type': 'OperationDisplay'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Operation, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.display = kwargs.get('display', None) -class OperationDisplay(Model): +class OperationDisplay(msrest.serialization.Model): """The object that represents the operation. - :param provider: Service provider: Microsoft.Authorization + :param provider: Service provider: Microsoft.Authorization. :type provider: str - :param resource: Resource on which the operation is performed: Profile, - endpoint, etc. + :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 @@ -130,8 +144,34 @@ class OperationDisplay(Model): 'operation': {'key': 'operation', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(OperationDisplay, self).__init__(**kwargs) self.provider = kwargs.get('provider', None) self.resource = kwargs.get('resource', None) self.operation = kwargs.get('operation', None) + + +class OperationListResult(msrest.serialization.Model): + """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 + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Operation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + 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 f7f689344886..1f84c9c1b759 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 @@ -1,81 +1,102 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.serialization import Model +from typing import List, Optional, Union +import msrest.serialization -class CloudError(Model): - """CloudError. +from ._management_lock_client_enums import * + + +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 """ _attribute_map = { + 'value': {'key': 'value', 'type': '[ManagementLockObject]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, } + def __init__( + self, + *, + value: Optional[List["ManagementLockObject"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(ManagementLockListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + -class ManagementLockObject(Model): +class ManagementLockObject(msrest.serialization.Model): """The lock information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :param 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] :ivar id: The resource ID of the lock. :vartype id: str :ivar type: The resource type of the lock - Microsoft.Authorization/locks. :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, + 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] """ _validation = { - 'level': {'required': True}, 'id': {'readonly': True}, 'type': {'readonly': True}, 'name': {'readonly': True}, + 'level': {'required': True}, } _attribute_map = { - 'level': {'key': 'properties.level', 'type': 'str'}, - 'notes': {'key': 'properties.notes', 'type': 'str'}, - 'owners': {'key': 'properties.owners', 'type': '[ManagementLockOwner]'}, 'id': {'key': 'id', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, + 'level': {'key': 'properties.level', 'type': 'str'}, + 'notes': {'key': 'properties.notes', 'type': 'str'}, + 'owners': {'key': 'properties.owners', 'type': '[ManagementLockOwner]'}, } - def __init__(self, *, level, notes: str=None, owners=None, **kwargs) -> None: + def __init__( + self, + *, + level: Union[str, "LockLevel"], + notes: Optional[str] = None, + owners: Optional[List["ManagementLockOwner"]] = None, + **kwargs + ): super(ManagementLockObject, self).__init__(**kwargs) - self.level = level - self.notes = notes - self.owners = owners self.id = None self.type = None self.name = None + self.level = level + self.notes = notes + self.owners = owners -class ManagementLockOwner(Model): +class ManagementLockOwner(msrest.serialization.Model): """Lock owner properties. :param application_id: The application ID of the lock owner. @@ -86,19 +107,23 @@ class ManagementLockOwner(Model): 'application_id': {'key': 'applicationId', 'type': 'str'}, } - def __init__(self, *, application_id: str=None, **kwargs) -> None: + def __init__( + self, + *, + application_id: Optional[str] = None, + **kwargs + ): super(ManagementLockOwner, self).__init__(**kwargs) self.application_id = application_id -class Operation(Model): +class Operation(msrest.serialization.Model): """Microsoft.Authorization operation. - :param name: Operation name: {provider}/{resource}/{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 + :type display: ~azure.mgmt.resource.locks.v2016_09_01.models.OperationDisplay """ _attribute_map = { @@ -106,19 +131,24 @@ class Operation(Model): 'display': {'key': 'display', 'type': 'OperationDisplay'}, } - def __init__(self, *, name: str=None, display=None, **kwargs) -> None: + def __init__( + self, + *, + name: Optional[str] = None, + display: Optional["OperationDisplay"] = None, + **kwargs + ): super(Operation, self).__init__(**kwargs) self.name = name self.display = display -class OperationDisplay(Model): +class OperationDisplay(msrest.serialization.Model): """The object that represents the operation. - :param provider: Service provider: Microsoft.Authorization + :param provider: Service provider: Microsoft.Authorization. :type provider: str - :param resource: Resource on which the operation is performed: Profile, - endpoint, etc. + :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 @@ -130,8 +160,41 @@ class OperationDisplay(Model): 'operation': {'key': 'operation', 'type': 'str'}, } - def __init__(self, *, provider: str=None, resource: str=None, operation: str=None, **kwargs) -> None: + def __init__( + self, + *, + provider: Optional[str] = None, + resource: Optional[str] = None, + operation: Optional[str] = None, + **kwargs + ): super(OperationDisplay, self).__init__(**kwargs) self.provider = provider self.resource = resource self.operation = operation + + +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 + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Operation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["Operation"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + 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/models/_paged_models.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/models/_paged_models.py deleted file mode 100644 index 0ff404120735..000000000000 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/models/_paged_models.py +++ /dev/null @@ -1,40 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.paging import Paged - - -class OperationPaged(Paged): - """ - A paging container for iterating over a list of :class:`Operation ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[Operation]'} - } - - def __init__(self, *args, **kwargs): - - super(OperationPaged, self).__init__(*args, **kwargs) -class ManagementLockObjectPaged(Paged): - """ - A paging container for iterating over a list of :class:`ManagementLockObject ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[ManagementLockObject]'} - } - - def __init__(self, *args, **kwargs): - - super(ManagementLockObjectPaged, self).__init__(*args, **kwargs) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/operations/__init__.py index 8eee96a3fccb..24ef6d198da3 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/operations/__init__.py @@ -1,18 +1,15 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._authorization_operations import AuthorizationOperations +from ._authorization_operations_operations import AuthorizationOperationsOperations from ._management_locks_operations import ManagementLocksOperations __all__ = [ - 'AuthorizationOperations', + 'AuthorizationOperationsOperations', 'ManagementLocksOperations', ] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/operations/_authorization_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/operations/_authorization_operations.py deleted file mode 100644 index 126ed6ebc01a..000000000000 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/operations/_authorization_operations.py +++ /dev/null @@ -1,102 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError - -from .. import models - - -class AuthorizationOperations(object): - """AuthorizationOperations operations. - - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. - - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for the operation. Constant value: "2016-09-01". - """ - - models = models - - def __init__(self, client, config, serializer, deserializer): - - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self.api_version = "2016-09-01" - - self.config = config - - def list( - self, custom_headers=None, raw=False, **operation_config): - """Lists all of the available Microsoft.Authorization REST API operations. - - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of Operation - :rtype: - ~azure.mgmt.resource.locks.v2016_09_01.models.OperationPaged[~azure.mgmt.resource.locks.v2016_09_01.models.Operation] - :raises: :class:`CloudError` - """ - def prepare_request(next_link=None): - if not next_link: - # Construct URL - url = self.list.metadata['url'] - - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - else: - url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) - return request - - def internal_paging(next_link=None): - request = prepare_request(next_link) - - response = self._client.send(request, stream=False, **operation_config) - - if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response - - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.OperationPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list.metadata = {'url': '/providers/Microsoft.Authorization/operations'} 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 new file mode 100644 index 000000000000..49e66f80a9d1 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/operations/_authorization_operations_operations.py @@ -0,0 +1,106 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class AuthorizationOperationsOperations(object): + """AuthorizationOperationsOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.locks.v2016_09_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.OperationListResult"] + """Lists all of the available Microsoft.Authorization REST API operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of OperationListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-09-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('OperationListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.Authorization/operations'} # type: ignore 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 9b2aba989d1d..19ccac10d55e 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 @@ -1,448 +1,437 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class ManagementLocksOperations(object): """ManagementLocksOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.locks.v2016_09_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for the operation. Constant value: "2016-09-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2016-09-01" - - self.config = config + self._config = config def create_or_update_at_resource_group_level( - self, resource_group_name, lock_name, parameters, custom_headers=None, raw=False, **operation_config): - """Creates or updates a management lock at the resource group level. + self, + resource_group_name, # type: str + lock_name, # type: str + parameters, # type: "models.ManagementLockObject" + **kwargs # type: Any + ): + # type: (...) -> "models.ManagementLockObject" + """When you apply a lock at a parent scope, all child resources inherit the same lock. To create management locks, you must have access to Microsoft.Authorization/\ * or Microsoft.Authorization/locks/* actions. Of the built-in roles, only Owner and User Access Administrator are granted those actions. - When you apply a lock at a parent scope, all child resources inherit - the same lock. To create management locks, you must have access to - Microsoft.Authorization/* or Microsoft.Authorization/locks/* actions. - Of the built-in roles, only Owner and User Access Administrator are - granted those actions. + Creates or updates a management lock at the resource group level. :param resource_group_name: The name of the resource group to lock. :type resource_group_name: str - :param lock_name: The lock name. The lock name can be a maximum of 260 - characters. It cannot contain <, > %, &, :, \\, ?, /, or any control - characters. + :param lock_name: The lock name. The lock name can be a maximum of 260 characters. It cannot + contain <, > %, &, :, \, ?, /, or any control characters. :type lock_name: str :param parameters: The management lock parameters. - :type parameters: - ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: ManagementLockObject or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :type parameters: ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagementLockObject or the result of cls(response) + :rtype: ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ManagementLockObject"] + error_map = {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.create_or_update_at_resource_group_level.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'ManagementLockObject') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 201]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ManagementLockObject', response) + deserialized = self._deserialize('ManagementLockObject', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('ManagementLockObject', response) + deserialized = self._deserialize('ManagementLockObject', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + 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}'} + create_or_update_at_resource_group_level.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks/{lockName}'} # type: ignore def delete_at_resource_group_level( - self, resource_group_name, lock_name, custom_headers=None, raw=False, **operation_config): - """Deletes a management lock at the resource group level. + self, + resource_group_name, # type: str + lock_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """To delete management locks, you must have access to Microsoft.Authorization/\ * or Microsoft.Authorization/locks/* actions. Of the built-in roles, only Owner and User Access Administrator are granted those actions. - To delete management locks, you must have access to - Microsoft.Authorization/* or Microsoft.Authorization/locks/* actions. - Of the built-in roles, only Owner and User Access Administrator are - granted those actions. + Deletes a management lock at the resource group level. - :param resource_group_name: The name of the resource group containing - the lock. + :param resource_group_name: The name of the resource group containing the lock. :type resource_group_name: str :param lock_name: The name of lock to delete. :type lock_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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'] + 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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete_at_resource_group_level.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks/{lockName}'} + delete_at_resource_group_level.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks/{lockName}'} # type: ignore def get_at_resource_group_level( - self, resource_group_name, lock_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + lock_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.ManagementLockObject" """Gets a management lock at the resource group level. :param resource_group_name: The name of the locked resource group. :type resource_group_name: str :param lock_name: The name of the lock to get. :type lock_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: ManagementLockObject or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagementLockObject or the result of cls(response) + :rtype: ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ManagementLockObject"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-09-01" + # Construct URL - url = self.get_at_resource_group_level.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('ManagementLockObject', response) + deserialized = self._deserialize('ManagementLockObject', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get_at_resource_group_level.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks/{lockName}'} + get_at_resource_group_level.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks/{lockName}'} # type: ignore def create_or_update_by_scope( - self, scope, lock_name, parameters, custom_headers=None, raw=False, **operation_config): + self, + scope, # type: str + lock_name, # type: str + parameters, # type: "models.ManagementLockObject" + **kwargs # type: Any + ): + # type: (...) -> "models.ManagementLockObject" """Create or update a management lock by scope. - :param scope: The scope for the lock. When providing a scope for the - assignment, use '/subscriptions/{subscriptionId}' for subscriptions, - '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}' - for resource groups, and + :param scope: The scope for the lock. When providing a scope for the assignment, use + '/subscriptions/{subscriptionId}' for subscriptions, + '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}' for resource groups, and '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePathIfPresent}/{resourceType}/{resourceName}' for resources. :type scope: str :param lock_name: The name of lock. :type lock_name: str :param parameters: Create or update management lock parameters. - :type parameters: - ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: ManagementLockObject or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :type parameters: ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagementLockObject or the result of cls(response) + :rtype: ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ManagementLockObject"] + error_map = {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.create_or_update_by_scope.metadata['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') + 'lockName': self._serialize.url("lock_name", lock_name, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'ManagementLockObject') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 201]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ManagementLockObject', response) + deserialized = self._deserialize('ManagementLockObject', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('ManagementLockObject', response) + deserialized = self._deserialize('ManagementLockObject', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_by_scope.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/locks/{lockName}'} + create_or_update_by_scope.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/locks/{lockName}'} # type: ignore def delete_by_scope( - self, scope, lock_name, custom_headers=None, raw=False, **operation_config): + self, + scope, # type: str + lock_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Delete a management lock by scope. :param scope: The scope for the lock. :type scope: str :param lock_name: The name of lock. :type lock_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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'] + 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') + 'lockName': self._serialize.url("lock_name", lock_name, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete_by_scope.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/locks/{lockName}'} + delete_by_scope.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/locks/{lockName}'} # type: ignore def get_by_scope( - self, scope, lock_name, custom_headers=None, raw=False, **operation_config): + self, + scope, # type: str + lock_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.ManagementLockObject" """Get a management lock by scope. :param scope: The scope for the lock. :type scope: str :param lock_name: The name of lock. :type lock_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: ManagementLockObject or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagementLockObject or the result of cls(response) + :rtype: ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ManagementLockObject"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-09-01" + # Construct URL - url = self.get_by_scope.metadata['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') + 'lockName': self._serialize.url("lock_name", lock_name, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('ManagementLockObject', response) + deserialized = self._deserialize('ManagementLockObject', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get_by_scope.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/locks/{lockName}'} + get_by_scope.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/locks/{lockName}'} # type: ignore def create_or_update_at_resource_level( - self, resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, lock_name, parameters, custom_headers=None, raw=False, **operation_config): - """Creates or updates a management lock at the resource level or any level - below the resource. - - When you apply a lock at a parent scope, all child resources inherit - the same lock. To create management locks, you must have access to - Microsoft.Authorization/* or Microsoft.Authorization/locks/* actions. - Of the built-in roles, only Owner and User Access Administrator are - granted those actions. - - :param resource_group_name: The name of the resource group containing - the resource to lock. + self, + 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 + parameters, # type: "models.ManagementLockObject" + **kwargs # type: Any + ): + # type: (...) -> "models.ManagementLockObject" + """When you apply a lock at a parent scope, all child resources inherit the same lock. To create management locks, you must have access to Microsoft.Authorization/\ * or Microsoft.Authorization/locks/* actions. Of the built-in roles, only Owner and User Access Administrator are granted those actions. + + Creates or updates a management lock at the resource level or any level below the resource. + + :param resource_group_name: The name of the resource group containing the resource to lock. :type resource_group_name: str - :param resource_provider_namespace: The resource provider namespace of - the resource to lock. + :param resource_provider_namespace: The resource provider namespace of the resource to lock. :type resource_provider_namespace: str :param parent_resource_path: The parent resource identity. :type parent_resource_path: str @@ -450,27 +439,24 @@ def create_or_update_at_resource_level( :type resource_type: str :param resource_name: The name of the resource to lock. :type resource_name: str - :param lock_name: The name of lock. The lock name can be a maximum of - 260 characters. It cannot contain <, > %, &, :, \\, ?, /, or any - control characters. + :param lock_name: The name of lock. The lock name can be a maximum of 260 characters. It cannot + contain <, > %, &, :, \, ?, /, or any control characters. :type lock_name: str - :param parameters: Parameters for creating or updating a management - lock. - :type parameters: - ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: ManagementLockObject or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :param parameters: Parameters for creating or updating a management lock. + :type parameters: ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagementLockObject or the result of cls(response) + :rtype: ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ManagementLockObject"] + error_map = {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.create_or_update_at_resource_level.metadata['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'), @@ -478,87 +464,86 @@ def create_or_update_at_resource_level( '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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'ManagementLockObject') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 201]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ManagementLockObject', response) + deserialized = self._deserialize('ManagementLockObject', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('ManagementLockObject', response) + deserialized = self._deserialize('ManagementLockObject', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + 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}'} + create_or_update_at_resource_level.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks/{lockName}'} # type: ignore def delete_at_resource_level( - self, resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, lock_name, custom_headers=None, raw=False, **operation_config): - """Deletes the management lock of a resource or any level below the - resource. - - To delete management locks, you must have access to - Microsoft.Authorization/* or Microsoft.Authorization/locks/* actions. - Of the built-in roles, only Owner and User Access Administrator are - granted those actions. - - :param resource_group_name: The name of the resource group containing - the resource with the lock to delete. + self, + 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 + **kwargs # type: Any + ): + # type: (...) -> None + """To delete management locks, you must have access to Microsoft.Authorization/\ * or Microsoft.Authorization/locks/* actions. Of the built-in roles, only Owner and User Access Administrator are granted those actions. + + Deletes the management lock of a resource or any level below the resource. + + :param resource_group_name: The name of the resource group containing the resource with the + lock to delete. :type resource_group_name: str - :param resource_provider_namespace: The resource provider namespace of - the resource with the lock to delete. + :param resource_provider_namespace: The resource provider namespace of the resource with the + lock to delete. :type resource_provider_namespace: str :param parent_resource_path: The parent resource identity. :type parent_resource_path: str - :param resource_type: The resource type of the resource with the lock - to delete. + :param resource_type: The resource type of the resource with the lock to delete. :type resource_type: str - :param resource_name: The name of the resource with the lock to - delete. + :param resource_name: The name of the resource with the lock to delete. :type resource_name: str :param lock_name: The name of the lock to delete. :type lock_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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'] + 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'), @@ -566,48 +551,50 @@ def delete_at_resource_level( '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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete_at_resource_level.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks/{lockName}'} + if cls: + return cls(pipeline_response, None, {}) + + delete_at_resource_level.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks/{lockName}'} # type: ignore def get_at_resource_level( - self, resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, lock_name, custom_headers=None, raw=False, **operation_config): + self, + 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 + **kwargs # type: Any + ): + # type: (...) -> "models.ManagementLockObject" """Get the management lock of a resource or any level below resource. :param resource_group_name: The name of the resource group. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource - provider. + :param resource_provider_namespace: The namespace of the resource provider. :type resource_provider_namespace: str - :param parent_resource_path: An extra path parameter needed in some - services, like SQL Databases. + :param parent_resource_path: An extra path parameter needed in some services, like SQL + Databases. :type parent_resource_path: str :param resource_type: The type of the resource. :type resource_type: str @@ -615,19 +602,18 @@ def get_at_resource_level( :type resource_name: str :param lock_name: The name of lock. :type lock_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: ManagementLockObject or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagementLockObject or the result of cls(response) + :rtype: ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ManagementLockObject"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-09-01" + # Construct URL - url = self.get_at_resource_level.metadata['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'), @@ -635,318 +621,299 @@ def get_at_resource_level( '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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('ManagementLockObject', response) + deserialized = self._deserialize('ManagementLockObject', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + 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}'} + get_at_resource_level.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks/{lockName}'} # type: ignore def create_or_update_at_subscription_level( - self, lock_name, parameters, custom_headers=None, raw=False, **operation_config): - """Creates or updates a management lock at the subscription level. - - When you apply a lock at a parent scope, all child resources inherit - the same lock. To create management locks, you must have access to - Microsoft.Authorization/* or Microsoft.Authorization/locks/* actions. - Of the built-in roles, only Owner and User Access Administrator are - granted those actions. - - :param lock_name: The name of lock. The lock name can be a maximum of - 260 characters. It cannot contain <, > %, &, :, \\, ?, /, or any - control characters. + self, + lock_name, # type: str + parameters, # type: "models.ManagementLockObject" + **kwargs # type: Any + ): + # type: (...) -> "models.ManagementLockObject" + """When you apply a lock at a parent scope, all child resources inherit the same lock. To create management locks, you must have access to Microsoft.Authorization/\ * or Microsoft.Authorization/locks/* actions. Of the built-in roles, only Owner and User Access Administrator are granted those actions. + + Creates or updates a management lock at the subscription level. + + :param lock_name: The name of lock. The lock name can be a maximum of 260 characters. It cannot + contain <, > %, &, :, \, ?, /, or any control characters. :type lock_name: str :param parameters: The management lock parameters. - :type parameters: - ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: ManagementLockObject or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :type parameters: ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagementLockObject or the result of cls(response) + :rtype: ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ManagementLockObject"] + error_map = {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.create_or_update_at_subscription_level.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'ManagementLockObject') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 201]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ManagementLockObject', response) + deserialized = self._deserialize('ManagementLockObject', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('ManagementLockObject', response) + deserialized = self._deserialize('ManagementLockObject', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_at_subscription_level.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks/{lockName}'} + create_or_update_at_subscription_level.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks/{lockName}'} # type: ignore def delete_at_subscription_level( - self, lock_name, custom_headers=None, raw=False, **operation_config): - """Deletes the management lock at the subscription level. + self, + lock_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """To delete management locks, you must have access to Microsoft.Authorization/\ * or Microsoft.Authorization/locks/* actions. Of the built-in roles, only Owner and User Access Administrator are granted those actions. - To delete management locks, you must have access to - Microsoft.Authorization/* or Microsoft.Authorization/locks/* actions. - Of the built-in roles, only Owner and User Access Administrator are - granted those actions. + Deletes the management lock at the subscription level. :param lock_name: The name of lock to delete. :type lock_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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'] + 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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete_at_subscription_level.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks/{lockName}'} + delete_at_subscription_level.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks/{lockName}'} # type: ignore def get_at_subscription_level( - self, lock_name, custom_headers=None, raw=False, **operation_config): + self, + lock_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.ManagementLockObject" """Gets a management lock at the subscription level. :param lock_name: The name of the lock to get. :type lock_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: ManagementLockObject or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagementLockObject or the result of cls(response) + :rtype: ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ManagementLockObject"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-09-01" + # Construct URL - url = self.get_at_subscription_level.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('ManagementLockObject', response) + deserialized = self._deserialize('ManagementLockObject', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get_at_subscription_level.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks/{lockName}'} + get_at_subscription_level.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks/{lockName}'} # type: ignore def list_at_resource_group_level( - self, resource_group_name, filter=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + filter=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.ManagementLockListResult"] """Gets all the management locks for a resource group. - :param resource_group_name: The name of the resource group containing - the locks to get. + :param resource_group_name: The name of the resource group containing the locks to get. :type resource_group_name: str :param filter: The filter to apply on the operation. :type filter: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of ManagementLockObject - :rtype: - ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObjectPaged[~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-09-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_at_resource_group_level.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('ManagementLockListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.ManagementLockObjectPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_at_resource_group_level.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks'} + return ItemPaged( + get_next, extract_data + ) + list_at_resource_group_level.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks'} # type: ignore def list_at_resource_level( - self, resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, filter=None, custom_headers=None, raw=False, **operation_config): - """Gets all the management locks for a resource or any level below - resource. - - :param resource_group_name: The name of the resource group containing - the locked resource. The name is case insensitive. + self, + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + filter=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.ManagementLockListResult"] + """Gets all the management locks for a resource or any level below resource. + + :param resource_group_name: The name of the resource group containing the locked resource. The + name is case insensitive. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource - provider. + :param resource_provider_namespace: The namespace of the resource provider. :type resource_provider_namespace: str :param parent_resource_path: The parent resource identity. :type parent_resource_path: str @@ -956,218 +923,211 @@ def list_at_resource_level( :type resource_name: str :param filter: The filter to apply on the operation. :type filter: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of ManagementLockObject - :rtype: - ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObjectPaged[~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-09-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_at_resource_level.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('ManagementLockListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.ManagementLockObjectPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_at_resource_level.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks'} + 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 def list_at_subscription_level( - self, filter=None, custom_headers=None, raw=False, **operation_config): + self, + filter=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.ManagementLockListResult"] """Gets all the management locks for a subscription. :param filter: The filter to apply on the operation. :type filter: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of ManagementLockObject - :rtype: - ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObjectPaged[~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-09-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_at_subscription_level.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('ManagementLockListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.ManagementLockObjectPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list_at_subscription_level.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks'} + return ItemPaged( + get_next, extract_data + ) + list_at_subscription_level.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks'} # type: ignore def list_by_scope( - self, scope, filter=None, custom_headers=None, raw=False, **operation_config): + self, + scope, # type: str + filter=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.ManagementLockListResult"] """Gets all the management locks for a scope. - :param scope: The scope for the lock. When providing a scope for the - assignment, use '/subscriptions/{subscriptionId}' for subscriptions, - '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}' - for resource groups, and - '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePathIfPresent}/{resourceType}/{resourceName}' - for resources. + :param scope: The scope for the lock. When providing a scope for the assignment, use + '/subscriptions/{subscriptionId}' for subscriptions, + '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}' for resource groups, and + '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePathIfPresent}/{resourceType}/{resourceName}' + for resources. :type scope: str :param filter: The filter to apply on the operation. :type filter: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of ManagementLockObject - :rtype: - ~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObjectPaged[~azure.mgmt.resource.locks.v2016_09_01.models.ManagementLockObject] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-09-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_by_scope.metadata['url'] + url = self.list_by_scope.metadata['url'] # type: ignore path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str') + 'scope': self._serialize.url("scope", scope, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('ManagementLockListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.ManagementLockObjectPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_by_scope.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/locks'} + return ItemPaged( + get_next, extract_data + ) + list_by_scope.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/locks'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/py.typed b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file 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 deleted file mode 100644 index e63d4addb017..000000000000 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2016_09_01/version.py +++ /dev/null @@ -1,13 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -VERSION = "2016-09-01" - 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 4e3a0e21fa28..6f3a03e8a8ee 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 @@ -1,19 +1,16 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._configuration import ApplicationClientConfiguration from ._application_client import ApplicationClient -__all__ = ['ApplicationClient', 'ApplicationClientConfiguration'] - -from .version import VERSION - -__version__ = VERSION +__all__ = ['ApplicationClient'] +try: + from ._patch import patch_sdk + patch_sdk() +except ImportError: + pass 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 c1761c597cd7..f7841fdbd80e 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 @@ -1,16 +1,19 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.service_client import SDKClient -from msrest import Serializer, Deserializer +from typing import TYPE_CHECKING + +from azure.mgmt.core import ARMPipelineClient +from msrest import Deserializer, Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional from ._configuration import ApplicationClientConfiguration from .operations import ApplicationsOperations @@ -18,37 +21,52 @@ from . import models -class ApplicationClient(SDKClient): - """ARM applications +class ApplicationClient(object): + """ARM applications. - :ivar config: Configuration for client. - :vartype config: ApplicationClientConfiguration - - :ivar applications: Applications operations + :ivar applications: ApplicationsOperations operations :vartype applications: azure.mgmt.resource.managedapplications.operations.ApplicationsOperations - :ivar application_definitions: ApplicationDefinitions operations + :ivar application_definitions: ApplicationDefinitionsOperations operations :vartype application_definitions: azure.mgmt.resource.managedapplications.operations.ApplicationDefinitionsOperations - - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` + :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. """ def __init__( - self, credentials, subscription_id, base_url=None): - - self.config = ApplicationClientConfiguration(credentials, subscription_id, base_url) - super(ApplicationClient, self).__init__(self.config.credentials, self.config) + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = 'https://management.azure.com' + self._config = ApplicationClientConfiguration(credential, 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.api_version = '2018-06-01' self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self.applications = ApplicationsOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.application_definitions = ApplicationDefinitionsOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> ApplicationClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) 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 426157c31d5e..65d8d2510172 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 @@ -1,48 +1,69 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrestazure import AzureConfiguration -from .version import VERSION +from typing import TYPE_CHECKING +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + + from azure.core.credentials import TokenCredential + +VERSION = "unknown" + +class ApplicationClientConfiguration(Configuration): + """Configuration for ApplicationClient. -class ApplicationClientConfiguration(AzureConfiguration): - """Configuration for ApplicationClient Note that all parameters used to create this instance are saved as instance attributes. - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` + :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 """ def __init__( - self, credentials, subscription_id, base_url=None): - - if credentials is None: - raise ValueError("Parameter 'credentials' must not be None.") + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + 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.") - if not base_url: - base_url = 'https://management.azure.com' + super(ApplicationClientConfiguration, self).__init__(**kwargs) - super(ApplicationClientConfiguration, self).__init__(base_url) - - # Starting Autorest.Python 4.0.64, make connection pool activated by default - self.keep_alive = True - - self.add_user_agent('azure-mgmt-resource/{}'.format(VERSION)) - self.add_user_agent('Azure-SDK-For-Python') - - self.credentials = credentials + self.credential = credential self.subscription_id = subscription_id + self.api_version = "2018-06-01" + self.credential_scopes = ['https://management.azure.com/.default'] + self.credential_scopes.extend(kwargs.pop('credential_scopes', [])) + kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + 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) 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 new file mode 100644 index 000000000000..f2494f96bbb6 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/_metadata.json @@ -0,0 +1,54 @@ +{ + "chosen_version": "2018-06-01", + "total_api_version_list": ["2018-06-01"], + "client": { + "name": "ApplicationClient", + "filename": "_application_client", + "description": "ARM applications." + }, + "global_parameters": { + "sync_method": { + "credential": { + "method_signature": "credential, # type: \"TokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials.TokenCredential", + "required": true + }, + "subscription_id": { + "method_signature": "subscription_id, # type: str", + "description": "The ID of the target subscription.", + "docstring_type": "str", + "required": true + } + }, + "async_method": { + "credential": { + "method_signature": "credential, # type: \"AsyncTokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + }, + "subscription_id": { + "method_signature": "subscription_id, # type: str", + "description": "The ID of the target subscription.", + "docstring_type": "str", + "required": true + } + }, + "constant": { + }, + "call": "credential, subscription_id" + }, + "config": { + "credential": true, + "credential_scopes": ["https://management.azure.com/.default"] + }, + "operation_groups": { + "applications": "ApplicationsOperations", + "application_definitions": "ApplicationDefinitionsOperations" + }, + "operation_mixins": { + }, + "sync_imports": "None", + "async_imports": "None" +} \ No newline at end of file diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/models/_management_link_client_enums.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/aio/__init__.py similarity index 74% rename from sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/models/_management_link_client_enums.py rename to sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/aio/__init__.py index 79b4af6dde2e..3b3d07792169 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/models/_management_link_client_enums.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/aio/__init__.py @@ -1,17 +1,10 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum - - -class Filter(str, Enum): - - at_scope = "atScope()" +from ._application_client_async import ApplicationClient +__all__ = ['ApplicationClient'] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/aio/_application_client_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/aio/_application_client_async.py new file mode 100644 index 000000000000..8585e7c81622 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/aio/_application_client_async.py @@ -0,0 +1,64 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, Optional + +from azure.mgmt.core import AsyncARMPipelineClient +from msrest import Deserializer, Serializer + +from ._configuration_async import ApplicationClientConfiguration +from .operations_async import ApplicationsOperations +from .operations_async import ApplicationDefinitionsOperations +from .. import models + + +class ApplicationClient(object): + """ARM applications. + + :ivar applications: ApplicationsOperations operations + :vartype applications: azure.mgmt.resource.managedapplications.aio.operations_async.ApplicationsOperations + :ivar application_definitions: ApplicationDefinitionsOperations operations + :vartype application_definitions: azure.mgmt.resource.managedapplications.aio.operations_async.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. + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: Optional[str] = None, + **kwargs: Any + ) -> None: + if not base_url: + base_url = 'https://management.azure.com' + self._config = ApplicationClientConfiguration(credential, subscription_id, **kwargs) + self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + + self.applications = ApplicationsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.application_definitions = ApplicationDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "ApplicationClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/aio/_configuration_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/aio/_configuration_async.py new file mode 100644 index 000000000000..9e211698af16 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/aio/_configuration_async.py @@ -0,0 +1,65 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + +VERSION = "unknown" + +class ApplicationClientConfiguration(Configuration): + """Configuration for ApplicationClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :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 + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + 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 + self.api_version = "2018-06-01" + self.credential_scopes = ['https://management.azure.com/.default'] + self.credential_scopes.extend(kwargs.pop('credential_scopes', [])) + kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs: Any + ) -> None: + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + 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) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/aio/operations_async/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/aio/operations_async/__init__.py new file mode 100644 index 000000000000..4b744d522ac8 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/aio/operations_async/__init__.py @@ -0,0 +1,15 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._applications_operations_async import ApplicationsOperations +from ._application_definitions_operations_async import ApplicationDefinitionsOperations + +__all__ = [ + 'ApplicationsOperations', + 'ApplicationDefinitionsOperations', +] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/aio/operations_async/_application_definitions_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/aio/operations_async/_application_definitions_operations_async.py new file mode 100644 index 000000000000..840a3c626689 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/aio/operations_async/_application_definitions_operations_async.py @@ -0,0 +1,612 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.polling import AsyncNoPolling, AsyncPollingMethod, async_poller +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ApplicationDefinitionsOperations: + """ApplicationDefinitionsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.managedapplications.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def get( + self, + resource_group_name: str, + application_definition_name: str, + **kwargs + ) -> "models.ApplicationDefinition": + """Gets the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.managedapplications.models.ApplicationDefinition or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ApplicationDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-06-01" + + # Construct URL + url = self.get.metadata['url'] # type: 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'] = 'application/json' + + # Construct and send request + request = 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + 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, + application_definition_name: str, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-06-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\._\(\)]+$'), + '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] + + # Construct and send request + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, 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 + + async def delete( + self, + resource_group_name: str, + application_definition_name: str, + **kwargs + ) -> None: + """Deletes the managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition to delete. + :type application_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}'} # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + application_definition_name: str, + parameters: "models.ApplicationDefinition", + **kwargs + ) -> "models.ApplicationDefinition": + cls = kwargs.pop('cls', None) # type: ClsType["models.ApplicationDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-06-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}'} # type: ignore + + async def create_or_update( + self, + resource_group_name: str, + application_definition_name: str, + parameters: "models.ApplicationDefinition", + **kwargs + ) -> "models.ApplicationDefinition": + """Creates a new managed application definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_definition_name: The name of the managed application definition. + :type application_definition_name: str + :param parameters: Parameters supplied to the create or update an managed application + definition. + :type parameters: ~azure.mgmt.resource.managedapplications.models.ApplicationDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: ApplicationDefinition + :rtype: ~azure.mgmt.resource.managedapplications.models.ApplicationDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.ApplicationDefinition"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + application_definition_name=application_definition_name, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}'} # type: ignore + + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs + ) -> AsyncIterable["models.ApplicationDefinitionListResult"]: + """Lists the managed application definitions in a 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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-06-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ApplicationDefinitionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + 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 + + async def get_by_id( + self, + application_definition_id: str, + **kwargs + ) -> "models.ApplicationDefinition": + """Gets the managed application definition. + + :param application_definition_id: The fully qualified ID of the managed application definition, + including the managed application name and the managed application definition resource type. + Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/Microsoft.Solutions/applicationDefinitions/{applicationDefinition-name}. + :type application_definition_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.managedapplications.models.ApplicationDefinition or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ApplicationDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-06-01" + + # Construct URL + url = self.get_by_id.metadata['url'] # type: ignore + path_format_arguments = { + 'applicationDefinitionId': self._serialize.url("application_definition_id", application_definition_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'] = 'application/json' + + # Construct and send request + request = 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_by_id.metadata = {'url': '/{applicationDefinitionId}'} # type: ignore + + async def _delete_by_id_initial( + self, + application_definition_id: str, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-06-01" + + # Construct URL + url = self._delete_by_id_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'applicationDefinitionId': self._serialize.url("application_definition_id", application_definition_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] + + # Construct and send request + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_by_id_initial.metadata = {'url': '/{applicationDefinitionId}'} # type: ignore + + async def delete_by_id( + self, + application_definition_id: str, + **kwargs + ) -> None: + """Deletes the managed application definition. + + :param application_definition_id: The fully qualified ID of the managed application definition, + including the managed application name and the managed application definition resource type. + Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/Microsoft.Solutions/applicationDefinitions/{applicationDefinition-name}. + :type application_definition_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._delete_by_id_initial( + application_definition_id=application_definition_id, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + delete_by_id.metadata = {'url': '/{applicationDefinitionId}'} # type: ignore + + async def _create_or_update_by_id_initial( + self, + application_definition_id: str, + parameters: "models.ApplicationDefinition", + **kwargs + ) -> "models.ApplicationDefinition": + cls = kwargs.pop('cls', None) # type: ClsType["models.ApplicationDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-06-01" + content_type = kwargs.pop("content_type", "application/json") + + # Construct URL + url = self._create_or_update_by_id_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'applicationDefinitionId': self._serialize.url("application_definition_id", application_definition_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['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_by_id_initial.metadata = {'url': '/{applicationDefinitionId}'} # type: ignore + + async def create_or_update_by_id( + self, + application_definition_id: str, + parameters: "models.ApplicationDefinition", + **kwargs + ) -> "models.ApplicationDefinition": + """Creates a new managed application definition. + + :param application_definition_id: The fully qualified ID of the managed application definition, + including the managed application name and the managed application definition resource type. + Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/Microsoft.Solutions/applicationDefinitions/{applicationDefinition-name}. + :type application_definition_id: str + :param parameters: Parameters supplied to the create or update a managed application + definition. + :type parameters: ~azure.mgmt.resource.managedapplications.models.ApplicationDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: ApplicationDefinition + :rtype: ~azure.mgmt.resource.managedapplications.models.ApplicationDefinition + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.ApplicationDefinition"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._create_or_update_by_id_initial( + application_definition_id=application_definition_id, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + create_or_update_by_id.metadata = {'url': '/{applicationDefinitionId}'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/aio/operations_async/_applications_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/aio/operations_async/_applications_operations_async.py new file mode 100644 index 000000000000..e1405423c0d7 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/aio/operations_async/_applications_operations_async.py @@ -0,0 +1,810 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.polling import AsyncNoPolling, AsyncPollingMethod, async_poller +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ApplicationsOperations: + """ApplicationsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.managedapplications.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def get( + self, + resource_group_name: str, + application_name: str, + **kwargs + ) -> "models.Application": + """Gets the managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Application or the result of cls(response) + :rtype: ~azure.mgmt.resource.managedapplications.models.Application or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Application"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-06-01" + + # Construct URL + url = self.get.metadata['url'] # type: 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'] = 'application/json' + + # Construct and send request + request = 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('Application', pipeline_response) + + if cls: + 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, + application_name: str, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-06-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\._\(\)]+$'), + '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] + + # Construct and send request + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, 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 + + async def delete( + self, + resource_group_name: str, + application_name: str, + **kwargs + ) -> None: + """Deletes the managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + application_name=application_name, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}'} # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + application_name: str, + parameters: "models.Application", + **kwargs + ) -> "models.Application": + cls = kwargs.pop('cls', None) # type: ClsType["models.Application"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-06-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('Application', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('Application', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}'} # type: ignore + + async def create_or_update( + self, + resource_group_name: str, + application_name: str, + parameters: "models.Application", + **kwargs + ) -> "models.Application": + """Creates a new managed application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :param parameters: Parameters supplied to the create or update a managed application. + :type parameters: ~azure.mgmt.resource.managedapplications.models.Application + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: Application + :rtype: ~azure.mgmt.resource.managedapplications.models.Application + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.Application"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + application_name=application_name, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('Application', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}'} # type: ignore + + async def update( + self, + resource_group_name: str, + application_name: str, + parameters: Optional["models.Application"] = None, + **kwargs + ) -> "models.Application": + """Updates an existing managed application. The only value that can be updated via PATCH currently is the tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param application_name: The name of the managed application. + :type application_name: str + :param parameters: Parameters supplied to update an existing managed application. + :type parameters: ~azure.mgmt.resource.managedapplications.models.Application + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Application or the result of cls(response) + :rtype: ~azure.mgmt.resource.managedapplications.models.Application + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Application"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-06-01" + content_type = kwargs.pop("content_type", "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'] = 'application/json' + + # Construct and send request + body_content_kwargs = {} # type: Dict[str, Any] + if parameters is not None: + body_content = 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) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Application', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}'} # type: ignore + + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs + ) -> AsyncIterable["models.ApplicationListResult"]: + """Gets all the applications within a 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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-06-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ApplicationListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + 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 + + def list_by_subscription( + self, + **kwargs + ) -> AsyncIterable["models.ApplicationListResult"]: + """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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-06-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ApplicationListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + 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 + + async def get_by_id( + self, + application_id: str, + **kwargs + ) -> "models.Application": + """Gets the managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group- + name}/Microsoft.Solutions/applications/{application-name}. + :type application_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Application or the result of cls(response) + :rtype: ~azure.mgmt.resource.managedapplications.models.Application or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Application"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-06-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('Application', pipeline_response) + + if cls: + 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, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-06-01" + + # 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] + + # Construct and send request + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_by_id_initial.metadata = {'url': '/{applicationId}'} # type: ignore + + async def delete_by_id( + self, + application_id: str, + **kwargs + ) -> None: + """Deletes the managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group- + name}/Microsoft.Solutions/applications/{application-name}. + :type application_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._delete_by_id_initial( + application_id=application_id, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + delete_by_id.metadata = {'url': '/{applicationId}'} # type: ignore + + async def _create_or_update_by_id_initial( + self, + application_id: str, + parameters: "models.Application", + **kwargs + ) -> "models.Application": + cls = kwargs.pop('cls', None) # type: ClsType["models.Application"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-06-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('Application', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('Application', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_by_id_initial.metadata = {'url': '/{applicationId}'} # type: ignore + + async def create_or_update_by_id( + self, + application_id: str, + parameters: "models.Application", + **kwargs + ) -> "models.Application": + """Creates a new managed application. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group- + name}/Microsoft.Solutions/applications/{application-name}. + :type application_id: str + :param parameters: Parameters supplied to the create or update a managed application. + :type parameters: ~azure.mgmt.resource.managedapplications.models.Application + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: Application + :rtype: ~azure.mgmt.resource.managedapplications.models.Application + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.Application"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._create_or_update_by_id_initial( + application_id=application_id, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('Application', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + create_or_update_by_id.metadata = {'url': '/{applicationId}'} # type: ignore + + async def update_by_id( + self, + application_id: str, + parameters: Optional["models.Application"] = None, + **kwargs + ) -> "models.Application": + """Updates an existing managed application. The only value that can be updated via PATCH currently is the tags. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group- + name}/Microsoft.Solutions/applications/{application-name}. + :type application_id: str + :param parameters: Parameters supplied to update an existing managed application. + :type parameters: ~azure.mgmt.resource.managedapplications.models.Application + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Application or the result of cls(response) + :rtype: ~azure.mgmt.resource.managedapplications.models.Application + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Application"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-06-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + body_content_kwargs = {} # type: Dict[str, Any] + if parameters is not None: + body_content = 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) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Application', pipeline_response) + + if cls: + 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/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/models/__init__.py index fe77a86199f0..b2c0a87c88db 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/models/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/models/__init__.py @@ -1,21 +1,20 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- try: from ._models_py3 import Application from ._models_py3 import ApplicationArtifact from ._models_py3 import ApplicationDefinition + from ._models_py3 import ApplicationDefinitionListResult + from ._models_py3 import ApplicationListResult from ._models_py3 import ApplicationPatchable from ._models_py3 import ApplicationProviderAuthorization - from ._models_py3 import ErrorResponse, ErrorResponseException + from ._models_py3 import ErrorResponse from ._models_py3 import GenericResource from ._models_py3 import Identity from ._models_py3 import Plan @@ -23,44 +22,43 @@ from ._models_py3 import Resource from ._models_py3 import Sku except (SyntaxError, ImportError): - from ._models import Application - from ._models import ApplicationArtifact - from ._models import ApplicationDefinition - from ._models import ApplicationPatchable - from ._models import ApplicationProviderAuthorization - from ._models import ErrorResponse, ErrorResponseException - from ._models import GenericResource - from ._models import Identity - from ._models import Plan - from ._models import PlanPatchable - from ._models import Resource - from ._models import Sku -from ._paged_models import ApplicationDefinitionPaged -from ._paged_models import ApplicationPaged + from ._models import Application # type: ignore + from ._models import ApplicationArtifact # type: ignore + from ._models import ApplicationDefinition # type: ignore + from ._models import ApplicationDefinitionListResult # type: ignore + from ._models import ApplicationListResult # type: ignore + from ._models import ApplicationPatchable # type: ignore + from ._models import ApplicationProviderAuthorization # type: ignore + from ._models import ErrorResponse # type: ignore + from ._models import GenericResource # type: ignore + from ._models import Identity # type: ignore + from ._models import Plan # type: ignore + from ._models import PlanPatchable # type: ignore + from ._models import Resource # type: ignore + from ._models import Sku # type: ignore + from ._application_client_enums import ( - ProvisioningState, - ApplicationLockLevel, ApplicationArtifactType, - ResourceIdentityType, + ApplicationLockLevel, + ProvisioningState, ) __all__ = [ 'Application', 'ApplicationArtifact', 'ApplicationDefinition', + 'ApplicationDefinitionListResult', + 'ApplicationListResult', 'ApplicationPatchable', 'ApplicationProviderAuthorization', - 'ErrorResponse', 'ErrorResponseException', + 'ErrorResponse', 'GenericResource', 'Identity', 'Plan', 'PlanPatchable', 'Resource', 'Sku', - 'ApplicationPaged', - 'ApplicationDefinitionPaged', - 'ProvisioningState', - 'ApplicationLockLevel', 'ApplicationArtifactType', - 'ResourceIdentityType', + 'ApplicationLockLevel', + 'ProvisioningState', ] 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 3f80fb3f4566..2523f08a0d84 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 @@ -1,18 +1,31 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from enum import Enum +class ApplicationArtifactType(str, Enum): + """The managed application artifact type. + """ + + template = "Template" + custom = "Custom" + +class ApplicationLockLevel(str, Enum): + """The managed application lock level. + """ + + can_not_delete = "CanNotDelete" + read_only = "ReadOnly" + none = "None" class ProvisioningState(str, Enum): + """Provisioning status of the managed application. + """ accepted = "Accepted" running = "Running" @@ -25,21 +38,3 @@ class ProvisioningState(str, Enum): failed = "Failed" succeeded = "Succeeded" updating = "Updating" - - -class ApplicationLockLevel(str, Enum): - - can_not_delete = "CanNotDelete" - read_only = "ReadOnly" - none = "None" - - -class ApplicationArtifactType(str, Enum): - - template = "Template" - custom = "Custom" - - -class ResourceIdentityType(str, Enum): - - system_assigned = "SystemAssigned" 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 3572d2988276..0e8ea174e497 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 @@ -1,33 +1,29 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.serialization import Model -from msrest.exceptions import HttpOperationError +from azure.core.exceptions import HttpResponseError +import msrest.serialization -class Resource(Model): +class Resource(msrest.serialization.Model): """Resource information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID + :ivar id: Resource ID. :vartype id: str - :ivar name: Resource name + :ivar name: Resource name. :vartype name: str - :ivar type: Resource type + :ivar type: Resource type. :vartype type: str - :param location: Resource location + :param location: Resource location. :type location: str - :param tags: Resource tags + :param tags: A set of tags. Resource tags. :type tags: dict[str, str] """ @@ -45,7 +41,10 @@ class Resource(Model): 'tags': {'key': 'tags', 'type': '{str}'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -57,18 +56,17 @@ def __init__(self, **kwargs): class GenericResource(Resource): """Resource information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID + :ivar id: Resource ID. :vartype id: str - :ivar name: Resource name + :ivar name: Resource name. :vartype name: str - :ivar type: Resource type + :ivar type: Resource type. :vartype type: str - :param location: Resource location + :param location: Resource location. :type location: str - :param tags: Resource tags + :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 @@ -95,7 +93,10 @@ class GenericResource(Resource): 'identity': {'key': 'identity', 'type': 'Identity'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(GenericResource, self).__init__(**kwargs) self.managed_by = kwargs.get('managed_by', None) self.sku = kwargs.get('sku', None) @@ -105,20 +106,19 @@ def __init__(self, **kwargs): class Application(GenericResource): """Information about managed application. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar id: Resource ID + :ivar id: Resource ID. :vartype id: str - :ivar name: Resource name + :ivar name: Resource name. :vartype name: str - :ivar type: Resource type + :ivar type: Resource type. :vartype type: str - :param location: Resource location + :param location: Resource location. :type location: str - :param tags: Resource tags + :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 @@ -126,38 +126,36 @@ class Application(GenericResource): :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 + 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. + :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 be a JObject or a well formed JSON string. + :param parameters: Name and value pairs that define the managed application parameters. It can + be a JObject or a well formed JSON string. :type parameters: object - :ivar outputs: Name and value pairs that define the managed application - outputs. + :ivar outputs: Name and value pairs that define the managed application outputs. :vartype outputs: object - :ivar provisioning_state: The managed application provisioning state. - Possible values include: 'Accepted', 'Running', 'Ready', 'Creating', - 'Created', 'Deleting', 'Deleted', 'Canceled', 'Failed', 'Succeeded', - 'Updating' + :ivar provisioning_state: The managed application provisioning state. Possible values include: + "Accepted", "Running", "Ready", "Creating", "Created", "Deleting", "Deleted", "Canceled", + "Failed", "Succeeded", "Updating". :vartype provisioning_state: str or ~azure.mgmt.resource.managedapplications.models.ProvisioningState - :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 ServiceCatalog. - :type kind: str """ _validation = { 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, + 'kind': {'required': True, 'pattern': r'^[-\w\._,\(\)]+$'}, 'managed_resource_group_id': {'required': True}, 'outputs': {'readonly': True}, 'provisioning_state': {'readonly': True}, - 'kind': {'required': True, 'pattern': r'^[-\w\._,\(\)]+$'}, } _attribute_map = { @@ -169,46 +167,51 @@ class Application(GenericResource): 'managed_by': {'key': 'managedBy', 'type': 'str'}, 'sku': {'key': 'sku', 'type': 'Sku'}, 'identity': {'key': 'identity', 'type': 'Identity'}, + 'plan': {'key': 'plan', 'type': 'Plan'}, + 'kind': {'key': 'kind', 'type': 'str'}, 'managed_resource_group_id': {'key': 'properties.managedResourceGroupId', 'type': 'str'}, 'application_definition_id': {'key': 'properties.applicationDefinitionId', 'type': 'str'}, 'parameters': {'key': 'properties.parameters', 'type': 'object'}, 'outputs': {'key': 'properties.outputs', 'type': 'object'}, 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'plan': {'key': 'plan', 'type': 'Plan'}, - 'kind': {'key': 'kind', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Application, self).__init__(**kwargs) - self.managed_resource_group_id = kwargs.get('managed_resource_group_id', None) + self.plan = kwargs.get('plan', None) + self.kind = kwargs['kind'] + self.managed_resource_group_id = kwargs['managed_resource_group_id'] self.application_definition_id = kwargs.get('application_definition_id', None) self.parameters = kwargs.get('parameters', None) self.outputs = None self.provisioning_state = None - self.plan = kwargs.get('plan', None) - self.kind = kwargs.get('kind', None) -class ApplicationArtifact(Model): +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', 'Custom' - :type type: str or - ~azure.mgmt.resource.managedapplications.models.ApplicationArtifactType + :param type: The managed application artifact type. Possible values include: "Template", + "Custom". + :type type: str or ~azure.mgmt.resource.managedapplications.models.ApplicationArtifactType """ _attribute_map = { 'name': {'key': 'name', 'type': 'str'}, 'uri': {'key': 'uri', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'ApplicationArtifactType'}, + 'type': {'key': 'type', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ApplicationArtifact, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.uri = kwargs.get('uri', None) @@ -218,20 +221,19 @@ def __init__(self, **kwargs): class ApplicationDefinition(GenericResource): """Information about managed application definition. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar id: Resource ID + :ivar id: Resource ID. :vartype id: str - :ivar name: Resource name + :ivar name: Resource name. :vartype name: str - :ivar type: Resource type + :ivar type: Resource type. :vartype type: str - :param location: Resource location + :param location: Resource location. :type location: str - :param tags: Resource tags + :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 @@ -239,36 +241,29 @@ class ApplicationDefinition(GenericResource): :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: 'CanNotDelete', 'ReadOnly', 'None' - :type lock_level: str or - ~azure.mgmt.resource.managedapplications.models.ApplicationLockLevel + :param 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. + :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. + :param authorizations: Required. The managed application provider authorizations. :type 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 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 + :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 can be a JObject or well-formed JSON string. + :param 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: object - :param 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. + :param 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: object """ @@ -289,7 +284,7 @@ class ApplicationDefinition(GenericResource): 'managed_by': {'key': 'managedBy', 'type': 'str'}, 'sku': {'key': 'sku', 'type': 'Sku'}, 'identity': {'key': 'identity', 'type': 'Identity'}, - 'lock_level': {'key': 'properties.lockLevel', 'type': 'ApplicationLockLevel'}, + 'lock_level': {'key': 'properties.lockLevel', 'type': 'str'}, 'display_name': {'key': 'properties.displayName', 'type': 'str'}, 'is_enabled': {'key': 'properties.isEnabled', 'type': 'str'}, 'authorizations': {'key': 'properties.authorizations', 'type': '[ApplicationProviderAuthorization]'}, @@ -300,12 +295,15 @@ class ApplicationDefinition(GenericResource): 'create_ui_definition': {'key': 'properties.createUiDefinition', 'type': 'object'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ApplicationDefinition, self).__init__(**kwargs) - self.lock_level = kwargs.get('lock_level', None) + self.lock_level = kwargs['lock_level'] self.display_name = kwargs.get('display_name', None) self.is_enabled = kwargs.get('is_enabled', None) - self.authorizations = kwargs.get('authorizations', None) + self.authorizations = kwargs['authorizations'] self.artifacts = kwargs.get('artifacts', None) self.description = kwargs.get('description', None) self.package_file_uri = kwargs.get('package_file_uri', None) @@ -313,21 +311,66 @@ def __init__(self, **kwargs): self.create_ui_definition = kwargs.get('create_ui_definition', None) +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 + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ApplicationDefinition]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ApplicationDefinitionListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +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 + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Application]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ApplicationListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + class ApplicationPatchable(GenericResource): """Information about managed application. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID + :ivar id: Resource ID. :vartype id: str - :ivar name: Resource name + :ivar name: Resource name. :vartype name: str - :ivar type: Resource type + :ivar type: Resource type. :vartype type: str - :param location: Resource location + :param location: Resource location. :type location: str - :param tags: Resource tags + :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 @@ -335,37 +378,35 @@ class ApplicationPatchable(GenericResource): :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 + 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. + :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 be a JObject or a well formed JSON string. + :param parameters: Name and value pairs that define the managed application parameters. It can + be a JObject or a well formed JSON string. :type parameters: object - :ivar outputs: Name and value pairs that define the managed application - outputs. + :ivar outputs: Name and value pairs that define the managed application outputs. :vartype outputs: object - :ivar provisioning_state: The managed application provisioning state. - Possible values include: 'Accepted', 'Running', 'Ready', 'Creating', - 'Created', 'Deleting', 'Deleted', 'Canceled', 'Failed', 'Succeeded', - 'Updating' + :ivar provisioning_state: The managed application provisioning state. Possible values include: + "Accepted", "Running", "Ready", "Creating", "Created", "Deleting", "Deleted", "Canceled", + "Failed", "Succeeded", "Updating". :vartype provisioning_state: str or ~azure.mgmt.resource.managedapplications.models.ProvisioningState - :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 ServiceCatalog. - :type kind: str """ _validation = { 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, + 'kind': {'pattern': r'^[-\w\._,\(\)]+$'}, 'outputs': {'readonly': True}, 'provisioning_state': {'readonly': True}, - 'kind': {'pattern': r'^[-\w\._,\(\)]+$'}, } _attribute_map = { @@ -377,39 +418,40 @@ class ApplicationPatchable(GenericResource): 'managed_by': {'key': 'managedBy', 'type': 'str'}, 'sku': {'key': 'sku', 'type': 'Sku'}, 'identity': {'key': 'identity', 'type': 'Identity'}, + 'plan': {'key': 'plan', 'type': 'PlanPatchable'}, + 'kind': {'key': 'kind', 'type': 'str'}, 'managed_resource_group_id': {'key': 'properties.managedResourceGroupId', 'type': 'str'}, 'application_definition_id': {'key': 'properties.applicationDefinitionId', 'type': 'str'}, 'parameters': {'key': 'properties.parameters', 'type': 'object'}, 'outputs': {'key': 'properties.outputs', 'type': 'object'}, 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'plan': {'key': 'plan', 'type': 'PlanPatchable'}, - 'kind': {'key': 'kind', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ApplicationPatchable, self).__init__(**kwargs) + self.plan = kwargs.get('plan', None) + self.kind = kwargs.get('kind', None) self.managed_resource_group_id = kwargs.get('managed_resource_group_id', None) self.application_definition_id = kwargs.get('application_definition_id', None) self.parameters = kwargs.get('parameters', None) self.outputs = None self.provisioning_state = None - self.plan = kwargs.get('plan', None) - self.kind = kwargs.get('kind', None) -class ApplicationProviderAuthorization(Model): +class ApplicationProviderAuthorization(msrest.serialization.Model): """The managed application provider authorization. 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 the provider will use to call ARM to manage the - managed application resources. + :param 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 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. + :param 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 """ @@ -423,23 +465,17 @@ class ApplicationProviderAuthorization(Model): 'role_definition_id': {'key': 'roleDefinitionId', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ApplicationProviderAuthorization, self).__init__(**kwargs) - self.principal_id = kwargs.get('principal_id', None) - self.role_definition_id = kwargs.get('role_definition_id', None) + self.principal_id = kwargs['principal_id'] + self.role_definition_id = kwargs['role_definition_id'] -class CloudError(Model): - """CloudError. - """ - - _attribute_map = { - } - - -class ErrorResponse(Model): - """Error response indicates managed application is not able to process the - incoming request. The reason is provided in the error message. +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 @@ -455,59 +491,53 @@ class ErrorResponse(Model): 'error_message': {'key': 'errorMessage', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ErrorResponse, self).__init__(**kwargs) self.http_status = kwargs.get('http_status', None) self.error_code = kwargs.get('error_code', None) self.error_message = kwargs.get('error_message', None) -class ErrorResponseException(HttpOperationError): - """Server responsed with exception of type: 'ErrorResponse'. - - :param deserialize: A deserializer - :param response: Server response to be deserialized. - """ - - def __init__(self, deserialize, response, *args): - - super(ErrorResponseException, self).__init__(deserialize, response, 'ErrorResponse', *args) - - -class Identity(Model): +class Identity(msrest.serialization.Model): """Identity for the resource. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar principal_id: The principal ID of resource identity. :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :param type: The identity type. Possible values include: 'SystemAssigned' - :type type: str or - ~azure.mgmt.resource.managedapplications.models.ResourceIdentityType + :ivar type: The identity type. Default value: "SystemAssigned". + :vartype type: str """ _validation = { 'principal_id': {'readonly': True}, 'tenant_id': {'readonly': True}, + 'type': {'constant': True}, } _attribute_map = { 'principal_id': {'key': 'principalId', 'type': 'str'}, 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'ResourceIdentityType'}, + 'type': {'key': 'type', 'type': 'str'}, } - def __init__(self, **kwargs): + type = "SystemAssigned" + + def __init__( + self, + **kwargs + ): super(Identity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None - self.type = kwargs.get('type', None) -class Plan(Model): +class Plan(msrest.serialization.Model): """Plan for the managed application. All required parameters must be populated in order to send to Azure. @@ -539,16 +569,19 @@ class Plan(Model): 'version': {'key': 'version', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Plan, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.publisher = kwargs.get('publisher', None) - self.product = kwargs.get('product', None) + self.name = kwargs['name'] + self.publisher = kwargs['publisher'] + self.product = kwargs['product'] self.promotion_code = kwargs.get('promotion_code', None) - self.version = kwargs.get('version', None) + self.version = kwargs['version'] -class PlanPatchable(Model): +class PlanPatchable(msrest.serialization.Model): """Plan for the managed application. :param name: The plan name. @@ -571,7 +604,10 @@ class PlanPatchable(Model): 'version': {'key': 'version', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(PlanPatchable, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.publisher = kwargs.get('publisher', None) @@ -580,7 +616,7 @@ def __init__(self, **kwargs): self.version = kwargs.get('version', None) -class Sku(Model): +class Sku(msrest.serialization.Model): """SKU for the resource. All required parameters must be populated in order to send to Azure. @@ -612,9 +648,12 @@ class Sku(Model): 'capacity': {'key': 'capacity', 'type': 'int'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Sku, self).__init__(**kwargs) - self.name = kwargs.get('name', None) + self.name = kwargs['name'] self.tier = kwargs.get('tier', None) self.size = kwargs.get('size', None) self.family = kwargs.get('family', 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 af550cd14d37..3c2d2df62ec6 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 @@ -1,33 +1,33 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.serialization import Model -from msrest.exceptions import HttpOperationError +from typing import Dict, List, Optional, Union +from azure.core.exceptions import HttpResponseError +import msrest.serialization -class Resource(Model): +from ._application_client_enums import * + + +class Resource(msrest.serialization.Model): """Resource information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID + :ivar id: Resource ID. :vartype id: str - :ivar name: Resource name + :ivar name: Resource name. :vartype name: str - :ivar type: Resource type + :ivar type: Resource type. :vartype type: str - :param location: Resource location + :param location: Resource location. :type location: str - :param tags: Resource tags + :param tags: A set of tags. Resource tags. :type tags: dict[str, str] """ @@ -45,7 +45,13 @@ class Resource(Model): 'tags': {'key': 'tags', 'type': '{str}'}, } - def __init__(self, *, location: str=None, tags=None, **kwargs) -> None: + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -57,18 +63,17 @@ def __init__(self, *, location: str=None, tags=None, **kwargs) -> None: class GenericResource(Resource): """Resource information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID + :ivar id: Resource ID. :vartype id: str - :ivar name: Resource name + :ivar name: Resource name. :vartype name: str - :ivar type: Resource type + :ivar type: Resource type. :vartype type: str - :param location: Resource location + :param location: Resource location. :type location: str - :param tags: Resource tags + :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 @@ -95,7 +100,16 @@ class GenericResource(Resource): 'identity': {'key': 'identity', 'type': 'Identity'}, } - def __init__(self, *, location: str=None, tags=None, managed_by: str=None, sku=None, identity=None, **kwargs) -> None: + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + managed_by: Optional[str] = None, + sku: Optional["Sku"] = None, + identity: Optional["Identity"] = None, + **kwargs + ): super(GenericResource, self).__init__(location=location, tags=tags, **kwargs) self.managed_by = managed_by self.sku = sku @@ -105,20 +119,19 @@ def __init__(self, *, location: str=None, tags=None, managed_by: str=None, sku=N class Application(GenericResource): """Information about managed application. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar id: Resource ID + :ivar id: Resource ID. :vartype id: str - :ivar name: Resource name + :ivar name: Resource name. :vartype name: str - :ivar type: Resource type + :ivar type: Resource type. :vartype type: str - :param location: Resource location + :param location: Resource location. :type location: str - :param tags: Resource tags + :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 @@ -126,38 +139,36 @@ class Application(GenericResource): :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 + 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. + :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 be a JObject or a well formed JSON string. + :param parameters: Name and value pairs that define the managed application parameters. It can + be a JObject or a well formed JSON string. :type parameters: object - :ivar outputs: Name and value pairs that define the managed application - outputs. + :ivar outputs: Name and value pairs that define the managed application outputs. :vartype outputs: object - :ivar provisioning_state: The managed application provisioning state. - Possible values include: 'Accepted', 'Running', 'Ready', 'Creating', - 'Created', 'Deleting', 'Deleted', 'Canceled', 'Failed', 'Succeeded', - 'Updating' + :ivar provisioning_state: The managed application provisioning state. Possible values include: + "Accepted", "Running", "Ready", "Creating", "Created", "Deleting", "Deleted", "Canceled", + "Failed", "Succeeded", "Updating". :vartype provisioning_state: str or ~azure.mgmt.resource.managedapplications.models.ProvisioningState - :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 ServiceCatalog. - :type kind: str """ _validation = { 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, + 'kind': {'required': True, 'pattern': r'^[-\w\._,\(\)]+$'}, 'managed_resource_group_id': {'required': True}, 'outputs': {'readonly': True}, 'provisioning_state': {'readonly': True}, - 'kind': {'required': True, 'pattern': r'^[-\w\._,\(\)]+$'}, } _attribute_map = { @@ -169,46 +180,66 @@ class Application(GenericResource): 'managed_by': {'key': 'managedBy', 'type': 'str'}, 'sku': {'key': 'sku', 'type': 'Sku'}, 'identity': {'key': 'identity', 'type': 'Identity'}, + 'plan': {'key': 'plan', 'type': 'Plan'}, + 'kind': {'key': 'kind', 'type': 'str'}, 'managed_resource_group_id': {'key': 'properties.managedResourceGroupId', 'type': 'str'}, 'application_definition_id': {'key': 'properties.applicationDefinitionId', 'type': 'str'}, 'parameters': {'key': 'properties.parameters', 'type': 'object'}, 'outputs': {'key': 'properties.outputs', 'type': 'object'}, 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'plan': {'key': 'plan', 'type': 'Plan'}, - 'kind': {'key': 'kind', 'type': 'str'}, } - def __init__(self, *, managed_resource_group_id: str, kind: str, location: str=None, tags=None, managed_by: str=None, sku=None, identity=None, application_definition_id: str=None, parameters=None, plan=None, **kwargs) -> None: + def __init__( + self, + *, + kind: str, + managed_resource_group_id: str, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + managed_by: Optional[str] = None, + sku: Optional["Sku"] = None, + identity: Optional["Identity"] = None, + plan: Optional["Plan"] = None, + application_definition_id: Optional[str] = None, + parameters: Optional[object] = None, + **kwargs + ): super(Application, self).__init__(location=location, tags=tags, managed_by=managed_by, sku=sku, identity=identity, **kwargs) + self.plan = plan + self.kind = kind self.managed_resource_group_id = managed_resource_group_id self.application_definition_id = application_definition_id self.parameters = parameters self.outputs = None self.provisioning_state = None - self.plan = plan - self.kind = kind -class ApplicationArtifact(Model): +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', 'Custom' - :type type: str or - ~azure.mgmt.resource.managedapplications.models.ApplicationArtifactType + :param type: The managed application artifact type. Possible values include: "Template", + "Custom". + :type type: str or ~azure.mgmt.resource.managedapplications.models.ApplicationArtifactType """ _attribute_map = { 'name': {'key': 'name', 'type': 'str'}, 'uri': {'key': 'uri', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'ApplicationArtifactType'}, + 'type': {'key': 'type', 'type': 'str'}, } - def __init__(self, *, name: str=None, uri: str=None, type=None, **kwargs) -> None: + def __init__( + self, + *, + name: Optional[str] = None, + uri: Optional[str] = None, + type: Optional[Union[str, "ApplicationArtifactType"]] = None, + **kwargs + ): super(ApplicationArtifact, self).__init__(**kwargs) self.name = name self.uri = uri @@ -218,20 +249,19 @@ def __init__(self, *, name: str=None, uri: str=None, type=None, **kwargs) -> Non class ApplicationDefinition(GenericResource): """Information about managed application definition. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar id: Resource ID + :ivar id: Resource ID. :vartype id: str - :ivar name: Resource name + :ivar name: Resource name. :vartype name: str - :ivar type: Resource type + :ivar type: Resource type. :vartype type: str - :param location: Resource location + :param location: Resource location. :type location: str - :param tags: Resource tags + :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 @@ -239,36 +269,29 @@ class ApplicationDefinition(GenericResource): :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: 'CanNotDelete', 'ReadOnly', 'None' - :type lock_level: str or - ~azure.mgmt.resource.managedapplications.models.ApplicationLockLevel + :param 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. + :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. + :param authorizations: Required. The managed application provider authorizations. :type 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 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 + :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 can be a JObject or well-formed JSON string. + :param 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: object - :param 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. + :param 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: object """ @@ -289,7 +312,7 @@ class ApplicationDefinition(GenericResource): 'managed_by': {'key': 'managedBy', 'type': 'str'}, 'sku': {'key': 'sku', 'type': 'Sku'}, 'identity': {'key': 'identity', 'type': 'Identity'}, - 'lock_level': {'key': 'properties.lockLevel', 'type': 'ApplicationLockLevel'}, + 'lock_level': {'key': 'properties.lockLevel', 'type': 'str'}, 'display_name': {'key': 'properties.displayName', 'type': 'str'}, 'is_enabled': {'key': 'properties.isEnabled', 'type': 'str'}, 'authorizations': {'key': 'properties.authorizations', 'type': '[ApplicationProviderAuthorization]'}, @@ -300,7 +323,25 @@ class ApplicationDefinition(GenericResource): 'create_ui_definition': {'key': 'properties.createUiDefinition', 'type': 'object'}, } - def __init__(self, *, lock_level, authorizations, location: str=None, tags=None, managed_by: str=None, sku=None, identity=None, display_name: str=None, is_enabled: str=None, artifacts=None, description: str=None, package_file_uri: str=None, main_template=None, create_ui_definition=None, **kwargs) -> None: + def __init__( + self, + *, + lock_level: Union[str, "ApplicationLockLevel"], + authorizations: List["ApplicationProviderAuthorization"], + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + managed_by: Optional[str] = None, + sku: Optional["Sku"] = None, + identity: Optional["Identity"] = None, + display_name: Optional[str] = None, + is_enabled: Optional[str] = None, + artifacts: Optional[List["ApplicationArtifact"]] = None, + description: Optional[str] = None, + package_file_uri: Optional[str] = None, + main_template: Optional[object] = None, + create_ui_definition: Optional[object] = None, + **kwargs + ): 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 @@ -313,21 +354,72 @@ def __init__(self, *, lock_level, authorizations, location: str=None, tags=None, self.create_ui_definition = create_ui_definition +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 + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ApplicationDefinition]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["ApplicationDefinition"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(ApplicationDefinitionListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +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 + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Application]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["Application"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(ApplicationListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + class ApplicationPatchable(GenericResource): """Information about managed application. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID + :ivar id: Resource ID. :vartype id: str - :ivar name: Resource name + :ivar name: Resource name. :vartype name: str - :ivar type: Resource type + :ivar type: Resource type. :vartype type: str - :param location: Resource location + :param location: Resource location. :type location: str - :param tags: Resource tags + :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 @@ -335,37 +427,35 @@ class ApplicationPatchable(GenericResource): :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 + 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. + :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 be a JObject or a well formed JSON string. + :param parameters: Name and value pairs that define the managed application parameters. It can + be a JObject or a well formed JSON string. :type parameters: object - :ivar outputs: Name and value pairs that define the managed application - outputs. + :ivar outputs: Name and value pairs that define the managed application outputs. :vartype outputs: object - :ivar provisioning_state: The managed application provisioning state. - Possible values include: 'Accepted', 'Running', 'Ready', 'Creating', - 'Created', 'Deleting', 'Deleted', 'Canceled', 'Failed', 'Succeeded', - 'Updating' + :ivar provisioning_state: The managed application provisioning state. Possible values include: + "Accepted", "Running", "Ready", "Creating", "Created", "Deleting", "Deleted", "Canceled", + "Failed", "Succeeded", "Updating". :vartype provisioning_state: str or ~azure.mgmt.resource.managedapplications.models.ProvisioningState - :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 ServiceCatalog. - :type kind: str """ _validation = { 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, + 'kind': {'pattern': r'^[-\w\._,\(\)]+$'}, 'outputs': {'readonly': True}, 'provisioning_state': {'readonly': True}, - 'kind': {'pattern': r'^[-\w\._,\(\)]+$'}, } _attribute_map = { @@ -377,39 +467,51 @@ class ApplicationPatchable(GenericResource): 'managed_by': {'key': 'managedBy', 'type': 'str'}, 'sku': {'key': 'sku', 'type': 'Sku'}, 'identity': {'key': 'identity', 'type': 'Identity'}, + 'plan': {'key': 'plan', 'type': 'PlanPatchable'}, + 'kind': {'key': 'kind', 'type': 'str'}, 'managed_resource_group_id': {'key': 'properties.managedResourceGroupId', 'type': 'str'}, 'application_definition_id': {'key': 'properties.applicationDefinitionId', 'type': 'str'}, 'parameters': {'key': 'properties.parameters', 'type': 'object'}, 'outputs': {'key': 'properties.outputs', 'type': 'object'}, 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'plan': {'key': 'plan', 'type': 'PlanPatchable'}, - 'kind': {'key': 'kind', 'type': 'str'}, } - def __init__(self, *, location: str=None, tags=None, managed_by: str=None, sku=None, identity=None, managed_resource_group_id: str=None, application_definition_id: str=None, parameters=None, plan=None, kind: str=None, **kwargs) -> None: + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + managed_by: Optional[str] = None, + sku: Optional["Sku"] = None, + identity: Optional["Identity"] = None, + plan: Optional["PlanPatchable"] = None, + kind: Optional[str] = None, + managed_resource_group_id: Optional[str] = None, + application_definition_id: Optional[str] = None, + parameters: Optional[object] = None, + **kwargs + ): super(ApplicationPatchable, self).__init__(location=location, tags=tags, managed_by=managed_by, sku=sku, identity=identity, **kwargs) + self.plan = plan + self.kind = kind self.managed_resource_group_id = managed_resource_group_id self.application_definition_id = application_definition_id self.parameters = parameters self.outputs = None self.provisioning_state = None - self.plan = plan - self.kind = kind -class ApplicationProviderAuthorization(Model): +class ApplicationProviderAuthorization(msrest.serialization.Model): """The managed application provider authorization. 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 the provider will use to call ARM to manage the - managed application resources. + :param 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 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. + :param 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 """ @@ -423,23 +525,20 @@ class ApplicationProviderAuthorization(Model): 'role_definition_id': {'key': 'roleDefinitionId', 'type': 'str'}, } - def __init__(self, *, principal_id: str, role_definition_id: str, **kwargs) -> None: + def __init__( + self, + *, + principal_id: str, + role_definition_id: str, + **kwargs + ): super(ApplicationProviderAuthorization, self).__init__(**kwargs) self.principal_id = principal_id self.role_definition_id = role_definition_id -class CloudError(Model): - """CloudError. - """ - - _attribute_map = { - } - - -class ErrorResponse(Model): - """Error response indicates managed application is not able to process the - incoming request. The reason is provided in the error message. +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 @@ -455,59 +554,57 @@ class ErrorResponse(Model): 'error_message': {'key': 'errorMessage', 'type': 'str'}, } - def __init__(self, *, http_status: str=None, error_code: str=None, error_message: str=None, **kwargs) -> None: + def __init__( + self, + *, + http_status: Optional[str] = None, + error_code: Optional[str] = None, + error_message: Optional[str] = None, + **kwargs + ): super(ErrorResponse, self).__init__(**kwargs) self.http_status = http_status self.error_code = error_code self.error_message = error_message -class ErrorResponseException(HttpOperationError): - """Server responsed with exception of type: 'ErrorResponse'. - - :param deserialize: A deserializer - :param response: Server response to be deserialized. - """ - - def __init__(self, deserialize, response, *args): - - super(ErrorResponseException, self).__init__(deserialize, response, 'ErrorResponse', *args) - - -class Identity(Model): +class Identity(msrest.serialization.Model): """Identity for the resource. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar principal_id: The principal ID of resource identity. :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :param type: The identity type. Possible values include: 'SystemAssigned' - :type type: str or - ~azure.mgmt.resource.managedapplications.models.ResourceIdentityType + :ivar type: The identity type. Default value: "SystemAssigned". + :vartype type: str """ _validation = { 'principal_id': {'readonly': True}, 'tenant_id': {'readonly': True}, + 'type': {'constant': True}, } _attribute_map = { 'principal_id': {'key': 'principalId', 'type': 'str'}, 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'ResourceIdentityType'}, + 'type': {'key': 'type', 'type': 'str'}, } - def __init__(self, *, type=None, **kwargs) -> None: + type = "SystemAssigned" + + def __init__( + self, + **kwargs + ): super(Identity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None - self.type = type -class Plan(Model): +class Plan(msrest.serialization.Model): """Plan for the managed application. All required parameters must be populated in order to send to Azure. @@ -539,7 +636,16 @@ class Plan(Model): 'version': {'key': 'version', 'type': 'str'}, } - def __init__(self, *, name: str, publisher: str, product: str, version: str, promotion_code: str=None, **kwargs) -> None: + def __init__( + self, + *, + name: str, + publisher: str, + product: str, + version: str, + promotion_code: Optional[str] = None, + **kwargs + ): super(Plan, self).__init__(**kwargs) self.name = name self.publisher = publisher @@ -548,7 +654,7 @@ def __init__(self, *, name: str, publisher: str, product: str, version: str, pro self.version = version -class PlanPatchable(Model): +class PlanPatchable(msrest.serialization.Model): """Plan for the managed application. :param name: The plan name. @@ -571,7 +677,16 @@ class PlanPatchable(Model): 'version': {'key': 'version', 'type': 'str'}, } - def __init__(self, *, name: str=None, publisher: str=None, product: str=None, promotion_code: str=None, version: str=None, **kwargs) -> None: + def __init__( + self, + *, + name: Optional[str] = None, + publisher: Optional[str] = None, + product: Optional[str] = None, + promotion_code: Optional[str] = None, + version: Optional[str] = None, + **kwargs + ): super(PlanPatchable, self).__init__(**kwargs) self.name = name self.publisher = publisher @@ -580,7 +695,7 @@ def __init__(self, *, name: str=None, publisher: str=None, product: str=None, pr self.version = version -class Sku(Model): +class Sku(msrest.serialization.Model): """SKU for the resource. All required parameters must be populated in order to send to Azure. @@ -612,7 +727,17 @@ class Sku(Model): 'capacity': {'key': 'capacity', 'type': 'int'}, } - def __init__(self, *, name: str, tier: str=None, size: str=None, family: str=None, model: str=None, capacity: int=None, **kwargs) -> None: + def __init__( + self, + *, + name: str, + tier: Optional[str] = None, + size: Optional[str] = None, + family: Optional[str] = None, + model: Optional[str] = None, + capacity: Optional[int] = None, + **kwargs + ): super(Sku, self).__init__(**kwargs) self.name = name self.tier = tier diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/models/_paged_models.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/models/_paged_models.py deleted file mode 100644 index f043675463e2..000000000000 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/models/_paged_models.py +++ /dev/null @@ -1,40 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.paging import Paged - - -class ApplicationPaged(Paged): - """ - A paging container for iterating over a list of :class:`Application ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[Application]'} - } - - def __init__(self, *args, **kwargs): - - super(ApplicationPaged, self).__init__(*args, **kwargs) -class ApplicationDefinitionPaged(Paged): - """ - A paging container for iterating over a list of :class:`ApplicationDefinition ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[ApplicationDefinition]'} - } - - def __init__(self, *args, **kwargs): - - super(ApplicationDefinitionPaged, self).__init__(*args, **kwargs) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/operations/__init__.py index 60ebab061654..cef7549ec472 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/operations/__init__.py @@ -1,12 +1,9 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from ._applications_operations import ApplicationsOperations 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 2dde22fe0576..6df2125bdf5a 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 @@ -1,595 +1,627 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrest.polling import LROPoller, NoPolling -from msrestazure.polling.arm_polling import ARMPolling +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class ApplicationDefinitionsOperations(object): """ApplicationDefinitionsOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.managedapplications.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for this operation. Constant value: "2018-06-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2018-06-01" - - self.config = config + self._config = config def get( - self, resource_group_name, application_definition_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + application_definition_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.ApplicationDefinition" """Gets the managed application definition. - :param resource_group_name: The name of the resource group. The name - is case insensitive. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str - :param application_definition_name: The name of the managed - application definition. + :param application_definition_name: The name of the managed application definition. :type application_definition_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: ApplicationDefinition or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.managedapplications.models.ApplicationDefinition - or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.managedapplications.models.ApplicationDefinition or None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ApplicationDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-06-01" + # Construct URL - url = self.get.metadata['url'] + url = self.get.metadata['url'] # type: 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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 404]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ApplicationDefinition', response) + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}'} - + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}'} # type: ignore def _delete_initial( - self, resource_group_name, application_definition_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + application_definition_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-06-01" + # Construct URL - url = self.delete.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: - raise models.ErrorResponseException(self._deserialize, response) - - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - - def delete( - self, resource_group_name, application_definition_name, custom_headers=None, raw=False, polling=True, **operation_config): + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}'} # type: ignore + + def begin_delete( + self, + resource_group_name, # type: str + application_definition_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> LROPoller """Deletes the managed application definition. - :param resource_group_name: The name of the resource group. The name - is case insensitive. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str - :param application_definition_name: The name of the managed - application definition to delete. + :param application_definition_name: The name of the managed application definition to delete. :type application_definition_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns None or - ClientRawResponse if raw==True - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] - :raises: - :class:`ErrorResponseException` + :paramtype polling: bool or ~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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._delete_initial( resource_group_name=resource_group_name, application_definition_name=application_definition_name, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}'} - + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}'} # type: ignore def _create_or_update_initial( - self, resource_group_name, application_definition_name, parameters, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + application_definition_name, # type: str + parameters, # type: "models.ApplicationDefinition" + **kwargs # type: Any + ): + # type: (...) -> "models.ApplicationDefinition" + cls = kwargs.pop('cls', None) # type: ClsType["models.ApplicationDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-06-01" + content_type = kwargs.pop("content_type", "application/json") + # Construct URL - url = self.create_or_update.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'ApplicationDefinition') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('ApplicationDefinition', response) + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('ApplicationDefinition', response) + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - - def create_or_update( - self, resource_group_name, application_definition_name, parameters, custom_headers=None, raw=False, polling=True, **operation_config): + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}'} # type: ignore + + def begin_create_or_update( + self, + resource_group_name, # type: str + application_definition_name, # type: str + parameters, # type: "models.ApplicationDefinition" + **kwargs # type: Any + ): + # type: (...) -> LROPoller """Creates a new managed application definition. - :param resource_group_name: The name of the resource group. The name - is case insensitive. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str - :param application_definition_name: The name of the managed - application definition. + :param application_definition_name: The name of the managed application definition. :type application_definition_name: str - :param parameters: Parameters supplied to the create or update an - managed application definition. - :type parameters: - ~azure.mgmt.resource.managedapplications.models.ApplicationDefinition - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :param parameters: Parameters supplied to the create or update an managed application + definition. + :type parameters: ~azure.mgmt.resource.managedapplications.models.ApplicationDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy + :paramtype polling: bool or ~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 ApplicationDefinition - or ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.resource.managedapplications.models.ApplicationDefinition] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.resource.managedapplications.models.ApplicationDefinition]] - :raises: - :class:`ErrorResponseException` + :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] + cls = kwargs.pop('cls', None) # type: ClsType["models.ApplicationDefinition"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._create_or_update_initial( resource_group_name=resource_group_name, application_definition_name=application_definition_name, parameters=parameters, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - deserialized = self._deserialize('ApplicationDefinition', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}'} + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions/{applicationDefinitionName}'} # type: ignore def list_by_resource_group( - self, resource_group_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.ApplicationDefinitionListResult"] """Lists the managed application definitions in a resource group. - :param resource_group_name: The name of the resource group. The name - is case insensitive. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of ApplicationDefinition - :rtype: - ~azure.mgmt.resource.managedapplications.models.ApplicationDefinitionPaged[~azure.mgmt.resource.managedapplications.models.ApplicationDefinition] - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-06-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_by_resource_group.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('ApplicationDefinitionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) - - return response + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.ApplicationDefinitionPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions'} + return ItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applicationDefinitions'} # type: ignore def get_by_id( - self, application_definition_id, custom_headers=None, raw=False, **operation_config): + self, + application_definition_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.ApplicationDefinition" """Gets the managed application definition. - :param application_definition_id: The fully qualified ID of the - managed application definition, including the managed application name - and the managed application definition resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applicationDefinitions/{applicationDefinition-name} + :param application_definition_id: The fully qualified ID of the managed application definition, + including the managed application name and the managed application definition resource type. + Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/Microsoft.Solutions/applicationDefinitions/{applicationDefinition-name}. :type application_definition_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: ApplicationDefinition or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.managedapplications.models.ApplicationDefinition - or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApplicationDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.managedapplications.models.ApplicationDefinition or None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ApplicationDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-06-01" + # Construct URL - url = self.get_by_id.metadata['url'] + url = self.get_by_id.metadata['url'] # type: ignore path_format_arguments = { - 'applicationDefinitionId': self._serialize.url("application_definition_id", application_definition_id, 'str', skip_quote=True) + 'applicationDefinitionId': self._serialize.url("application_definition_id", application_definition_id, 'str', skip_quote=True), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 404]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ApplicationDefinition', response) + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/{applicationDefinitionId}'} - + get_by_id.metadata = {'url': '/{applicationDefinitionId}'} # type: ignore def _delete_by_id_initial( - self, application_definition_id, custom_headers=None, raw=False, **operation_config): + self, + application_definition_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-06-01" + # Construct URL - url = self.delete_by_id.metadata['url'] + url = self._delete_by_id_initial.metadata['url'] # type: ignore path_format_arguments = { - 'applicationDefinitionId': self._serialize.url("application_definition_id", application_definition_id, 'str', skip_quote=True) + 'applicationDefinitionId': self._serialize.url("application_definition_id", application_definition_id, 'str', skip_quote=True), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + if cls: + return cls(pipeline_response, None, {}) - def delete_by_id( - self, application_definition_id, custom_headers=None, raw=False, polling=True, **operation_config): + _delete_by_id_initial.metadata = {'url': '/{applicationDefinitionId}'} # type: ignore + + def begin_delete_by_id( + self, + application_definition_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> LROPoller """Deletes the managed application definition. - :param application_definition_id: The fully qualified ID of the - managed application definition, including the managed application name - and the managed application definition resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applicationDefinitions/{applicationDefinition-name} + :param application_definition_id: The fully qualified ID of the managed application definition, + including the managed application name and the managed application definition resource type. + Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/Microsoft.Solutions/applicationDefinitions/{applicationDefinition-name}. :type application_definition_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns None or - ClientRawResponse if raw==True - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] - :raises: - :class:`ErrorResponseException` + :paramtype polling: bool or ~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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._delete_by_id_initial( application_definition_id=application_definition_id, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - delete_by_id.metadata = {'url': '/{applicationDefinitionId}'} - + begin_delete_by_id.metadata = {'url': '/{applicationDefinitionId}'} # type: ignore def _create_or_update_by_id_initial( - self, application_definition_id, parameters, custom_headers=None, raw=False, **operation_config): + self, + application_definition_id, # type: str + parameters, # type: "models.ApplicationDefinition" + **kwargs # type: Any + ): + # type: (...) -> "models.ApplicationDefinition" + cls = kwargs.pop('cls', None) # type: ClsType["models.ApplicationDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-06-01" + content_type = kwargs.pop("content_type", "application/json") + # Construct URL - url = self.create_or_update_by_id.metadata['url'] + url = self._create_or_update_by_id_initial.metadata['url'] # type: ignore path_format_arguments = { - 'applicationDefinitionId': self._serialize.url("application_definition_id", application_definition_id, 'str', skip_quote=True) + 'applicationDefinitionId': self._serialize.url("application_definition_id", application_definition_id, 'str', skip_quote=True), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'ApplicationDefinition') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('ApplicationDefinition', response) + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('ApplicationDefinition', response) + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - - def create_or_update_by_id( - self, application_definition_id, parameters, custom_headers=None, raw=False, polling=True, **operation_config): + _create_or_update_by_id_initial.metadata = {'url': '/{applicationDefinitionId}'} # type: ignore + + def begin_create_or_update_by_id( + self, + application_definition_id, # type: str + parameters, # type: "models.ApplicationDefinition" + **kwargs # type: Any + ): + # type: (...) -> LROPoller """Creates a new managed application definition. - :param application_definition_id: The fully qualified ID of the - managed application definition, including the managed application name - and the managed application definition resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applicationDefinitions/{applicationDefinition-name} + :param application_definition_id: The fully qualified ID of the managed application definition, + including the managed application name and the managed application definition resource type. + Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/Microsoft.Solutions/applicationDefinitions/{applicationDefinition-name}. :type application_definition_id: str - :param parameters: Parameters supplied to the create or update a - managed application definition. - :type parameters: - ~azure.mgmt.resource.managedapplications.models.ApplicationDefinition - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :param parameters: Parameters supplied to the create or update a managed application + definition. + :type parameters: ~azure.mgmt.resource.managedapplications.models.ApplicationDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy + :paramtype polling: bool or ~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 ApplicationDefinition - or ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.resource.managedapplications.models.ApplicationDefinition] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.resource.managedapplications.models.ApplicationDefinition]] - :raises: - :class:`ErrorResponseException` + :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] + cls = kwargs.pop('cls', None) # type: ClsType["models.ApplicationDefinition"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._create_or_update_by_id_initial( application_definition_id=application_definition_id, parameters=parameters, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - deserialized = self._deserialize('ApplicationDefinition', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ApplicationDefinition', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - create_or_update_by_id.metadata = {'url': '/{applicationDefinitionId}'} + begin_create_or_update_by_id.metadata = {'url': '/{applicationDefinitionId}'} # 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 200dc626853a..bb4ee5670ca8 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 @@ -1,799 +1,828 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrest.polling import LROPoller, NoPolling -from msrestazure.polling.arm_polling import ARMPolling +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class ApplicationsOperations(object): """ApplicationsOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.managedapplications.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for this operation. Constant value: "2018-06-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2018-06-01" - - self.config = config + self._config = config def get( - self, resource_group_name, application_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + application_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.Application" """Gets the managed application. - :param resource_group_name: The name of the resource group. The name - is case insensitive. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param application_name: The name of the managed application. :type application_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: Application or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.resource.managedapplications.models.Application or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Application or the result of cls(response) + :rtype: ~azure.mgmt.resource.managedapplications.models.Application or None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Application"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-06-01" + # Construct URL - url = self.get.metadata['url'] + url = self.get.metadata['url'] # type: 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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 404]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Application', response) + deserialized = self._deserialize('Application', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}'} - + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}'} # type: ignore def _delete_initial( - self, resource_group_name, application_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + application_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-06-01" + # Construct URL - url = self.delete.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [202, 204]: - raise models.ErrorResponseException(self._deserialize, response) - - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - - def delete( - self, resource_group_name, application_name, custom_headers=None, raw=False, polling=True, **operation_config): + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}'} # type: ignore + + def begin_delete( + self, + resource_group_name, # type: str + application_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> LROPoller """Deletes the managed application. - :param resource_group_name: The name of the resource group. The name - is case insensitive. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param application_name: The name of the managed application. :type application_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns None or - ClientRawResponse if raw==True - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] - :raises: - :class:`ErrorResponseException` + :paramtype polling: bool or ~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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._delete_initial( resource_group_name=resource_group_name, application_name=application_name, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}'} - + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}'} # type: ignore def _create_or_update_initial( - self, resource_group_name, application_name, parameters, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + application_name, # type: str + parameters, # type: "models.Application" + **kwargs # type: Any + ): + # type: (...) -> "models.Application" + cls = kwargs.pop('cls', None) # type: ClsType["models.Application"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-06-01" + content_type = kwargs.pop("content_type", "application/json") + # Construct URL - url = self.create_or_update.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'Application') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('Application', response) + deserialized = self._deserialize('Application', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('Application', response) + deserialized = self._deserialize('Application', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - - def create_or_update( - self, resource_group_name, application_name, parameters, custom_headers=None, raw=False, polling=True, **operation_config): + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}'} # type: ignore + + def begin_create_or_update( + self, + resource_group_name, # type: str + application_name, # type: str + parameters, # type: "models.Application" + **kwargs # type: Any + ): + # type: (...) -> LROPoller """Creates a new managed application. - :param resource_group_name: The name of the resource group. The name - is case insensitive. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param application_name: The name of the managed application. :type application_name: str - :param parameters: Parameters supplied to the create or update a - managed application. - :type parameters: - ~azure.mgmt.resource.managedapplications.models.Application - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :param parameters: Parameters supplied to the create or update a managed application. + :type parameters: ~azure.mgmt.resource.managedapplications.models.Application + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns Application or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.resource.managedapplications.models.Application] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.resource.managedapplications.models.Application]] - :raises: - :class:`ErrorResponseException` + :paramtype polling: bool or ~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 Application + :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] + cls = kwargs.pop('cls', None) # type: ClsType["models.Application"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._create_or_update_initial( resource_group_name=resource_group_name, application_name=application_name, parameters=parameters, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - deserialized = self._deserialize('Application', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('Application', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}'} + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}'} # type: ignore def update( - self, resource_group_name, application_name, parameters=None, custom_headers=None, raw=False, **operation_config): - """Updates an existing managed application. The only value that can be - updated via PATCH currently is the tags. - - :param resource_group_name: The name of the resource group. The name - is case insensitive. + self, + resource_group_name, # type: str + application_name, # type: str + parameters=None, # type: Optional["models.Application"] + **kwargs # type: Any + ): + # type: (...) -> "models.Application" + """Updates an existing managed application. The only value that can be updated via PATCH currently is the tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param application_name: The name of the managed application. :type application_name: str - :param parameters: Parameters supplied to update an existing managed - application. - :type parameters: - ~azure.mgmt.resource.managedapplications.models.Application - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: Application or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.resource.managedapplications.models.Application or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :param parameters: Parameters supplied to update an existing managed application. + :type parameters: ~azure.mgmt.resource.managedapplications.models.Application + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Application or the result of cls(response) + :rtype: ~azure.mgmt.resource.managedapplications.models.Application + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Application"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-06-01" + content_type = kwargs.pop("content_type", "application/json") + # Construct URL - url = self.update.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body + + # Construct and send request + body_content_kwargs = {} # type: Dict[str, Any] if parameters is not None: body_content = 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) - # Construct and send request - request = self._client.patch(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('Application', response) + deserialized = self._deserialize('Application', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}'} + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications/{applicationName}'} # type: ignore def list_by_resource_group( - self, resource_group_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.ApplicationListResult"] """Gets all the applications within a resource group. - :param resource_group_name: The name of the resource group. The name - is case insensitive. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of Application - :rtype: - ~azure.mgmt.resource.managedapplications.models.ApplicationPaged[~azure.mgmt.resource.managedapplications.models.Application] - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-06-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_by_resource_group.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('ApplicationListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) - - return response + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.ApplicationPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications'} + return ItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applications'} # type: ignore def list_by_subscription( - self, custom_headers=None, raw=False, **operation_config): + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.ApplicationListResult"] """Gets all the applications within a subscription. - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of Application - :rtype: - ~azure.mgmt.resource.managedapplications.models.ApplicationPaged[~azure.mgmt.resource.managedapplications.models.Application] - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-06-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_by_subscription.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('ApplicationListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.ApplicationPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/applications'} + return ItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/applications'} # type: ignore def get_by_id( - self, application_id, custom_headers=None, raw=False, **operation_config): + self, + application_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.Application" """Gets the managed application. - :param application_id: The fully qualified ID of the managed - application, including the managed application name and the managed - application resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name} + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group- + name}/Microsoft.Solutions/applications/{application-name}. :type application_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: Application or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.resource.managedapplications.models.Application or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Application or the result of cls(response) + :rtype: ~azure.mgmt.resource.managedapplications.models.Application or None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Application"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-06-01" + # Construct URL - url = self.get_by_id.metadata['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) + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 404]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Application', response) + deserialized = self._deserialize('Application', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/{applicationId}'} - + get_by_id.metadata = {'url': '/{applicationId}'} # type: ignore def _delete_by_id_initial( - self, application_id, custom_headers=None, raw=False, **operation_config): + self, + application_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-06-01" + # Construct URL - url = self.delete_by_id.metadata['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) + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [202, 204]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + if cls: + return cls(pipeline_response, None, {}) - def delete_by_id( - self, application_id, custom_headers=None, raw=False, polling=True, **operation_config): + _delete_by_id_initial.metadata = {'url': '/{applicationId}'} # type: ignore + + def begin_delete_by_id( + self, + application_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> LROPoller """Deletes the managed application. - :param application_id: The fully qualified ID of the managed - application, including the managed application name and the managed - application resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name} + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group- + name}/Microsoft.Solutions/applications/{application-name}. :type application_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns None or - ClientRawResponse if raw==True - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] - :raises: - :class:`ErrorResponseException` + :paramtype polling: bool or ~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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._delete_by_id_initial( application_id=application_id, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - delete_by_id.metadata = {'url': '/{applicationId}'} - + begin_delete_by_id.metadata = {'url': '/{applicationId}'} # type: ignore def _create_or_update_by_id_initial( - self, application_id, parameters, custom_headers=None, raw=False, **operation_config): + self, + application_id, # type: str + parameters, # type: "models.Application" + **kwargs # type: Any + ): + # type: (...) -> "models.Application" + cls = kwargs.pop('cls', None) # type: ClsType["models.Application"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-06-01" + content_type = kwargs.pop("content_type", "application/json") + # Construct URL - url = self.create_or_update_by_id.metadata['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) + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'Application') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('Application', response) + deserialized = self._deserialize('Application', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('Application', response) + deserialized = self._deserialize('Application', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - - def create_or_update_by_id( - self, application_id, parameters, custom_headers=None, raw=False, polling=True, **operation_config): + _create_or_update_by_id_initial.metadata = {'url': '/{applicationId}'} # type: ignore + + def begin_create_or_update_by_id( + self, + application_id, # type: str + parameters, # type: "models.Application" + **kwargs # type: Any + ): + # type: (...) -> LROPoller """Creates a new managed application. - :param application_id: The fully qualified ID of the managed - application, including the managed application name and the managed - application resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name} + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group- + name}/Microsoft.Solutions/applications/{application-name}. :type application_id: str - :param parameters: Parameters supplied to the create or update a - managed application. - :type parameters: - ~azure.mgmt.resource.managedapplications.models.Application - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :param parameters: Parameters supplied to the create or update a managed application. + :type parameters: ~azure.mgmt.resource.managedapplications.models.Application + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns Application or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.resource.managedapplications.models.Application] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.resource.managedapplications.models.Application]] - :raises: - :class:`ErrorResponseException` + :paramtype polling: bool or ~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 Application + :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] + cls = kwargs.pop('cls', None) # type: ClsType["models.Application"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._create_or_update_by_id_initial( application_id=application_id, parameters=parameters, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - deserialized = self._deserialize('Application', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('Application', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - create_or_update_by_id.metadata = {'url': '/{applicationId}'} + begin_create_or_update_by_id.metadata = {'url': '/{applicationId}'} # type: ignore def update_by_id( - self, application_id, parameters=None, custom_headers=None, raw=False, **operation_config): - """Updates an existing managed application. The only value that can be - updated via PATCH currently is the tags. - - :param application_id: The fully qualified ID of the managed - application, including the managed application name and the managed - application resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applications/{application-name} + self, + application_id, # type: str + parameters=None, # type: Optional["models.Application"] + **kwargs # type: Any + ): + # type: (...) -> "models.Application" + """Updates an existing managed application. The only value that can be updated via PATCH currently is the tags. + + :param application_id: The fully qualified ID of the managed application, including the managed + application name and the managed application resource type. Use the format, + /subscriptions/{guid}/resourceGroups/{resource-group- + name}/Microsoft.Solutions/applications/{application-name}. :type application_id: str - :param parameters: Parameters supplied to update an existing managed - application. - :type parameters: - ~azure.mgmt.resource.managedapplications.models.Application - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: Application or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.resource.managedapplications.models.Application or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :param parameters: Parameters supplied to update an existing managed application. + :type parameters: ~azure.mgmt.resource.managedapplications.models.Application + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Application or the result of cls(response) + :rtype: ~azure.mgmt.resource.managedapplications.models.Application + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Application"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-06-01" + content_type = kwargs.pop("content_type", "application/json") + # Construct URL - url = self.update_by_id.metadata['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) + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body + + # Construct and send request + body_content_kwargs = {} # type: Dict[str, Any] if parameters is not None: body_content = 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) - # Construct and send request - request = self._client.patch(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('Application', response) + deserialized = self._deserialize('Application', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - update_by_id.metadata = {'url': '/{applicationId}'} + update_by_id.metadata = {'url': '/{applicationId}'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/py.typed b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file 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 deleted file mode 100644 index 981cdfec35c6..000000000000 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/managedapplications/version.py +++ /dev/null @@ -1,13 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -VERSION = "2017-09-01" - diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/__init__.py index 969c52599990..e4bba9352a5c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/__init__.py @@ -1,19 +1,16 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._configuration import PolicyClientConfiguration from ._policy_client import PolicyClient -__all__ = ['PolicyClient', 'PolicyClientConfiguration'] - -from ..version import VERSION - -__version__ = VERSION +__all__ = ['PolicyClient'] +try: + from ._patch import patch_sdk + patch_sdk() +except ImportError: + pass 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 24a0790a53e9..0d567e5a495f 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 @@ -1,48 +1,69 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrestazure import AzureConfiguration -from ..version import VERSION +from typing import TYPE_CHECKING +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + + from azure.core.credentials import TokenCredential + +VERSION = "unknown" + +class PolicyClientConfiguration(Configuration): + """Configuration for PolicyClient. -class PolicyClientConfiguration(AzureConfiguration): - """Configuration for PolicyClient Note that all parameters used to create this instance are saved as instance attributes. - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` + :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 """ def __init__( - self, credentials, subscription_id, base_url=None): - - if credentials is None: - raise ValueError("Parameter 'credentials' must not be None.") + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + 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.") - if not base_url: - base_url = 'https://management.azure.com' + super(PolicyClientConfiguration, self).__init__(**kwargs) - super(PolicyClientConfiguration, self).__init__(base_url) - - # Starting Autorest.Python 4.0.64, make connection pool activated by default - self.keep_alive = True - - self.add_user_agent('azure-mgmt-resource/{}'.format(VERSION)) - self.add_user_agent('Azure-SDK-For-Python') - - self.credentials = credentials + self.credential = credential self.subscription_id = subscription_id + self.api_version = "2019-09-01" + self.credential_scopes = ['https://management.azure.com/.default'] + self.credential_scopes.extend(kwargs.pop('credential_scopes', [])) + kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + 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) 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 56bf47bfb9e4..e4bba9352a5c 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 @@ -1,19 +1,16 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._configuration import PolicyClientConfiguration from ._policy_client import PolicyClient -__all__ = ['PolicyClient', 'PolicyClientConfiguration'] - -from .version import VERSION - -__version__ = VERSION +__all__ = ['PolicyClient'] +try: + from ._patch import patch_sdk + patch_sdk() +except ImportError: + pass 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 ede4f42045d0..6304700c5dfb 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 @@ -1,48 +1,69 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrestazure import AzureConfiguration -from .version import VERSION +from typing import TYPE_CHECKING +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + + from azure.core.credentials import TokenCredential + +VERSION = "unknown" + +class PolicyClientConfiguration(Configuration): + """Configuration for PolicyClient. -class PolicyClientConfiguration(AzureConfiguration): - """Configuration for PolicyClient Note that all parameters used to create this instance are saved as instance attributes. - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` + :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 """ def __init__( - self, credentials, subscription_id, base_url=None): - - if credentials is None: - raise ValueError("Parameter 'credentials' must not be None.") + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + 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.") - if not base_url: - base_url = 'https://management.azure.com' + super(PolicyClientConfiguration, self).__init__(**kwargs) - super(PolicyClientConfiguration, self).__init__(base_url) - - # Starting Autorest.Python 4.0.64, make connection pool activated by default - self.keep_alive = True - - self.add_user_agent('azure-mgmt-resource/{}'.format(VERSION)) - self.add_user_agent('Azure-SDK-For-Python') - - self.credentials = credentials + self.credential = credential self.subscription_id = subscription_id + self.api_version = "2015-10-01-preview" + self.credential_scopes = ['https://management.azure.com/.default'] + self.credential_scopes.extend(kwargs.pop('credential_scopes', [])) + kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + 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) 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 new file mode 100644 index 000000000000..ce760d5b2063 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/_metadata.json @@ -0,0 +1,54 @@ +{ + "chosen_version": "2015-10-01-preview", + "total_api_version_list": ["2015-10-01-preview"], + "client": { + "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." + }, + "global_parameters": { + "sync_method": { + "credential": { + "method_signature": "credential, # type: \"TokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials.TokenCredential", + "required": true + }, + "subscription_id": { + "method_signature": "subscription_id, # type: str", + "description": "The ID of the target subscription.", + "docstring_type": "str", + "required": true + } + }, + "async_method": { + "credential": { + "method_signature": "credential, # type: \"AsyncTokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + }, + "subscription_id": { + "method_signature": "subscription_id, # type: str", + "description": "The ID of the target subscription.", + "docstring_type": "str", + "required": true + } + }, + "constant": { + }, + "call": "credential, subscription_id" + }, + "config": { + "credential": true, + "credential_scopes": ["https://management.azure.com/.default"] + }, + "operation_groups": { + "policy_assignments": "PolicyAssignmentsOperations", + "policy_definitions": "PolicyDefinitionsOperations" + }, + "operation_mixins": { + }, + "sync_imports": "None", + "async_imports": "None" +} \ 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 2dfec399fdaa..a9cea7378a37 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 @@ -1,16 +1,19 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.service_client import SDKClient -from msrest import Serializer, Deserializer +from typing import TYPE_CHECKING + +from azure.mgmt.core import ARMPipelineClient +from msrest import Deserializer, Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional from ._configuration import PolicyClientConfiguration from .operations import PolicyAssignmentsOperations @@ -18,37 +21,52 @@ from . import models -class PolicyClient(SDKClient): +class PolicyClient(object): """To manage and control access to your resources, you can define customized policies and assign them at a scope. - :ivar config: Configuration for client. - :vartype config: PolicyClientConfiguration - - :ivar policy_assignments: PolicyAssignments operations + :ivar policy_assignments: PolicyAssignmentsOperations operations :vartype policy_assignments: azure.mgmt.resource.policy.v2015_10_01_preview.operations.PolicyAssignmentsOperations - :ivar policy_definitions: PolicyDefinitions operations + :ivar policy_definitions: PolicyDefinitionsOperations operations :vartype policy_definitions: azure.mgmt.resource.policy.v2015_10_01_preview.operations.PolicyDefinitionsOperations - - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` + :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. """ def __init__( - self, credentials, subscription_id, base_url=None): - - self.config = PolicyClientConfiguration(credentials, subscription_id, base_url) - super(PolicyClient, self).__init__(self.config.credentials, self.config) + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = 'https://management.azure.com' + self._config = PolicyClientConfiguration(credential, 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.api_version = '2015-10-01-preview' self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self.policy_assignments = PolicyAssignmentsOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.policy_definitions = PolicyDefinitionsOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> PolicyClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) 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/policy/v2015_10_01_preview/aio/__init__.py similarity index 76% rename from sdk/resources/azure-mgmt-resource/azure/mgmt/resource/links/v2016_09_01/version.py rename to sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/aio/__init__.py index e63d4addb017..df3c0beab48a 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/policy/v2015_10_01_preview/aio/__init__.py @@ -1,13 +1,10 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2016-09-01" - +from ._policy_client_async import PolicyClient +__all__ = ['PolicyClient'] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/aio/_configuration_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/aio/_configuration_async.py new file mode 100644 index 000000000000..00054b7167dc --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/aio/_configuration_async.py @@ -0,0 +1,65 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + +VERSION = "unknown" + +class PolicyClientConfiguration(Configuration): + """Configuration for PolicyClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :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 + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + 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 + self.api_version = "2015-10-01-preview" + self.credential_scopes = ['https://management.azure.com/.default'] + self.credential_scopes.extend(kwargs.pop('credential_scopes', [])) + kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs: Any + ) -> None: + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + 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) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/aio/_policy_client_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/aio/_policy_client_async.py new file mode 100644 index 000000000000..8906835b2b7d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/aio/_policy_client_async.py @@ -0,0 +1,64 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, Optional + +from azure.mgmt.core import AsyncARMPipelineClient +from msrest import Deserializer, Serializer + +from ._configuration_async import PolicyClientConfiguration +from .operations_async import PolicyAssignmentsOperations +from .operations_async import PolicyDefinitionsOperations +from .. import models + + +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.aio.operations_async.PolicyAssignmentsOperations + :ivar policy_definitions: PolicyDefinitionsOperations operations + :vartype policy_definitions: azure.mgmt.resource.policy.v2015_10_01_preview.aio.operations_async.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 + :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, + **kwargs: 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) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + + self.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 close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "PolicyClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/aio/operations_async/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/aio/operations_async/__init__.py new file mode 100644 index 000000000000..04da551aae58 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/aio/operations_async/__init__.py @@ -0,0 +1,15 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._policy_assignments_operations_async import PolicyAssignmentsOperations +from ._policy_definitions_operations_async import PolicyDefinitionsOperations + +__all__ = [ + 'PolicyAssignmentsOperations', + 'PolicyDefinitionsOperations', +] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/aio/operations_async/_policy_assignments_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/aio/operations_async/_policy_assignments_operations_async.py new file mode 100644 index 000000000000..8a79bb7f38c4 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/aio/operations_async/_policy_assignments_operations_async.py @@ -0,0 +1,618 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import 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 ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class PolicyAssignmentsOperations: + """PolicyAssignmentsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.policy.v2015_10_01_preview.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def delete( + self, + scope: str, + policy_assignment_name: str, + **kwargs + ) -> "models.PolicyAssignment": + """Deletes a policy assignment. + + :param scope: The scope of the policy assignment. + :type scope: str + :param policy_assignment_name: The name of the policy assignment to delete. + :type policy_assignment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {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 = { + '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'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyassignments/{policyAssignmentName}'} # type: ignore + + async def create( + self, + scope: str, + policy_assignment_name: str, + parameters: "models.PolicyAssignment", + **kwargs + ) -> "models.PolicyAssignment": + """Policy assignments are inherited by child resources. For example, when you apply a policy to a resource group that policy is assigned to all resources in the group. + + Creates a policy assignment. + + :param scope: The scope of the policy assignment. + :type scope: str + :param policy_assignment_name: The name of the policy assignment. + :type policy_assignment_name: str + :param parameters: Parameters for the policy assignment. + :type parameters: ~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyAssignment + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {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") + + # 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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyassignments/{policyAssignmentName}'} # type: ignore + + async def get( + self, + scope: str, + policy_assignment_name: str, + **kwargs + ) -> "models.PolicyAssignment": + """Gets a policy assignment. + + :param scope: The scope of the policy assignment. + :type scope: str + :param policy_assignment_name: The name of the policy assignment to get. + :type policy_assignment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2015-10-01-preview" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyassignments/{policyAssignmentName}'} # type: ignore + + def list_for_resource_group( + self, + resource_group_name: str, + filter: Optional[str] = None, + **kwargs + ) -> AsyncIterable["models.PolicyAssignmentListResult"]: + """Gets policy assignments for the resource group. + + :param resource_group_name: The name of the resource group that contains policy assignments. + :type resource_group_name: str + :param filter: The filter to apply on the operation. + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2015-10-01-preview" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, 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 + + def list_for_resource( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + filter: Optional[str] = None, + **kwargs + ) -> AsyncIterable["models.PolicyAssignmentListResult"]: + """Gets policy assignments for a resource. + + :param resource_group_name: The name of the resource group containing the resource. The name is + case insensitive. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource path. + :type parent_resource_path: str + :param resource_type: The resource type. + :type resource_type: str + :param resource_name: The name of the resource with policy assignments. + :type resource_name: str + :param filter: The filter to apply on the operation. + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2015-10-01-preview" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, 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 + + def list( + self, + filter: Optional[str] = None, + **kwargs + ) -> AsyncIterable["models.PolicyAssignmentListResult"]: + """Gets all the policy assignments for a subscription. + + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2015-10-01-preview" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyassignments'} # type: ignore + + async def delete_by_id( + self, + policy_assignment_id: str, + **kwargs + ) -> "models.PolicyAssignment": + """When providing a scope for the assignment, use '/subscriptions/{subscription-id}/' for subscriptions, '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for resource groups, and '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider-namespace}/{resource-type}/{resource-name}' for resources. + + Deletes a policy assignment by ID. + + :param policy_assignment_id: The ID of the policy assignment to delete. Use the format + '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policy-assignment-name}'. + :type policy_assignment_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2015-10-01-preview" + + # 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'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + delete_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + + async def create_by_id( + self, + policy_assignment_id: str, + parameters: "models.PolicyAssignment", + **kwargs + ) -> "models.PolicyAssignment": + """Policy assignments are inherited by child resources. For example, when you apply a policy to a resource group that policy is assigned to all resources in the group. When providing a scope for the assignment, use '/subscriptions/{subscription-id}/' for subscriptions, '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for resource groups, and '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider-namespace}/{resource-type}/{resource-name}' for resources. + + Creates a policy assignment by ID. + + :param policy_assignment_id: The ID of the policy assignment to create. Use the format + '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policy-assignment-name}'. + :type policy_assignment_id: str + :param parameters: Parameters for policy assignment. + :type parameters: ~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyAssignment + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {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") + + # 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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + + async def get_by_id( + self, + policy_assignment_id: str, + **kwargs + ) -> "models.PolicyAssignment": + """When providing a scope for the assignment, use '/subscriptions/{subscription-id}/' for subscriptions, '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for resource groups, and '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider-namespace}/{resource-type}/{resource-name}' for resources. + + Gets a policy assignment by ID. + + :param policy_assignment_id: The ID of the policy assignment to get. Use the format + '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policy-assignment-name}'. + :type policy_assignment_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2015-10-01-preview" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyAssignment', pipeline_response) + + if cls: + 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_async/_policy_definitions_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/aio/operations_async/_policy_definitions_operations_async.py new file mode 100644 index 000000000000..e5ad96d8f191 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/aio/operations_async/_policy_definitions_operations_async.py @@ -0,0 +1,271 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import 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 ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class PolicyDefinitionsOperations: + """PolicyDefinitionsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.policy.v2015_10_01_preview.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def create_or_update( + self, + policy_definition_name: str, + parameters: "models.PolicyDefinition", + **kwargs + ) -> "models.PolicyDefinition": + """Creates or updates a policy definition. + + :param policy_definition_name: The name of the policy definition to create. + :type policy_definition_name: str + :param parameters: The policy definition properties. + :type parameters: ~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyDefinition"] + error_map = {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") + + # 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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions/{policyDefinitionName}'} # type: ignore + + async def delete( + self, + policy_definition_name: str, + **kwargs + ) -> None: + """Deletes a policy definition. + + :param policy_definition_name: The name of the policy definition to delete. + :type policy_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions/{policyDefinitionName}'} # type: ignore + + async def get( + self, + policy_definition_name: str, + **kwargs + ) -> "models.PolicyDefinition": + """Gets the policy definition. + + :param policy_definition_name: The name of the policy definition to get. + :type policy_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2015-10-01-preview" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions/{policyDefinitionName}'} # type: ignore + + def list( + self, + filter: Optional[str] = None, + **kwargs + ) -> AsyncIterable["models.PolicyDefinitionListResult"]: + """Gets all the policy definitions for a subscription. + + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2015-10-01-preview" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyDefinitionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/models/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/models/__init__.py index 09123683300d..e3aa53d09d9c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/models/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/models/__init__.py @@ -1,30 +1,30 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- try: from ._models_py3 import PolicyAssignment + from ._models_py3 import PolicyAssignmentListResult from ._models_py3 import PolicyDefinition + from ._models_py3 import PolicyDefinitionListResult except (SyntaxError, ImportError): - from ._models import PolicyAssignment - from ._models import PolicyDefinition -from ._paged_models import PolicyAssignmentPaged -from ._paged_models import PolicyDefinitionPaged + from ._models import PolicyAssignment # type: ignore + from ._models import PolicyAssignmentListResult # type: ignore + from ._models import PolicyDefinition # type: ignore + from ._models import PolicyDefinitionListResult # type: ignore + from ._policy_client_enums import ( PolicyType, ) __all__ = [ 'PolicyAssignment', + 'PolicyAssignmentListResult', 'PolicyDefinition', - 'PolicyAssignmentPaged', - 'PolicyDefinitionPaged', + 'PolicyDefinitionListResult', 'PolicyType', ] 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 558bbfee84ca..e08b7edfbaf4 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 @@ -1,84 +1,95 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.serialization import Model +import msrest.serialization -class CloudError(Model): - """CloudError. - """ - - _attribute_map = { - } - - -class PolicyAssignment(Model): +class PolicyAssignment(msrest.serialization.Model): """The policy assignment. - :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 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 """ _attribute_map = { - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'policy_definition_id': {'key': 'properties.policyDefinitionId', 'type': 'str'}, - 'scope': {'key': 'properties.scope', 'type': 'str'}, 'id': {'key': 'id', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, + 'display_name': {'key': 'properties.displayName', 'type': 'str'}, + 'policy_definition_id': {'key': 'properties.policyDefinitionId', 'type': 'str'}, + 'scope': {'key': 'properties.scope', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(PolicyAssignment, self).__init__(**kwargs) - self.display_name = kwargs.get('display_name', None) - self.policy_definition_id = kwargs.get('policy_definition_id', None) - self.scope = kwargs.get('scope', None) self.id = kwargs.get('id', None) self.type = kwargs.get('type', None) self.name = kwargs.get('name', None) + self.display_name = kwargs.get('display_name', None) + self.policy_definition_id = kwargs.get('policy_definition_id', None) + self.scope = kwargs.get('scope', None) -class PolicyDefinition(Model): +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 + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[PolicyAssignment]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(PolicyAssignmentListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class PolicyDefinition(msrest.serialization.Model): """The policy definition. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :param 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 + :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 + 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, + 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: object - :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 value is inferred from the name value in the request - URI. - :type name: str """ _validation = { @@ -86,19 +97,45 @@ class PolicyDefinition(Model): } _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, 'policy_type': {'key': 'properties.policyType', 'type': 'str'}, 'display_name': {'key': 'properties.displayName', 'type': 'str'}, 'description': {'key': 'properties.description', 'type': 'str'}, 'policy_rule': {'key': 'properties.policyRule', 'type': 'object'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(PolicyDefinition, self).__init__(**kwargs) + self.id = None + self.name = kwargs.get('name', None) self.policy_type = kwargs.get('policy_type', None) self.display_name = kwargs.get('display_name', None) self.description = kwargs.get('description', None) self.policy_rule = kwargs.get('policy_rule', None) - self.id = None - self.name = kwargs.get('name', None) + + +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 + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[PolicyDefinition]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + 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 c4894b54cc90..ac7f5ac8949f 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 @@ -1,84 +1,109 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.serialization import Model +from typing import List, Optional, Union +import msrest.serialization -class CloudError(Model): - """CloudError. - """ - - _attribute_map = { - } +from ._policy_client_enums import * -class PolicyAssignment(Model): +class PolicyAssignment(msrest.serialization.Model): """The policy assignment. - :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 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 """ _attribute_map = { - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'policy_definition_id': {'key': 'properties.policyDefinitionId', 'type': 'str'}, - 'scope': {'key': 'properties.scope', 'type': 'str'}, 'id': {'key': 'id', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, + 'display_name': {'key': 'properties.displayName', 'type': 'str'}, + 'policy_definition_id': {'key': 'properties.policyDefinitionId', 'type': 'str'}, + 'scope': {'key': 'properties.scope', 'type': 'str'}, } - def __init__(self, *, display_name: str=None, policy_definition_id: str=None, scope: str=None, id: str=None, type: str=None, name: str=None, **kwargs) -> None: + def __init__( + self, + *, + id: Optional[str] = None, + type: Optional[str] = None, + name: Optional[str] = None, + display_name: Optional[str] = None, + policy_definition_id: Optional[str] = None, + scope: Optional[str] = None, + **kwargs + ): super(PolicyAssignment, self).__init__(**kwargs) - self.display_name = display_name - self.policy_definition_id = policy_definition_id - self.scope = scope self.id = id self.type = type self.name = name + self.display_name = display_name + self.policy_definition_id = policy_definition_id + self.scope = scope + +class PolicyAssignmentListResult(msrest.serialization.Model): + """List of policy assignments. -class PolicyDefinition(Model): + :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 + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[PolicyAssignment]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["PolicyAssignment"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(PolicyAssignmentListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class PolicyDefinition(msrest.serialization.Model): """The policy definition. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :param 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 + :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 + 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, + 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: object - :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 value is inferred from the name value in the request - URI. - :type name: str """ _validation = { @@ -86,19 +111,54 @@ class PolicyDefinition(Model): } _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, 'policy_type': {'key': 'properties.policyType', 'type': 'str'}, 'display_name': {'key': 'properties.displayName', 'type': 'str'}, 'description': {'key': 'properties.description', 'type': 'str'}, 'policy_rule': {'key': 'properties.policyRule', 'type': 'object'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, } - def __init__(self, *, policy_type=None, display_name: str=None, description: str=None, policy_rule=None, name: str=None, **kwargs) -> None: + def __init__( + self, + *, + name: Optional[str] = None, + policy_type: Optional[Union[str, "PolicyType"]] = None, + display_name: Optional[str] = None, + description: Optional[str] = None, + policy_rule: Optional[object] = None, + **kwargs + ): super(PolicyDefinition, self).__init__(**kwargs) + self.id = None + self.name = name self.policy_type = policy_type self.display_name = display_name self.description = description self.policy_rule = policy_rule - self.id = None - self.name = name + + +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 + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[PolicyDefinition]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["PolicyDefinition"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + 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/_paged_models.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/models/_paged_models.py deleted file mode 100644 index 5915c2e75c4a..000000000000 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/models/_paged_models.py +++ /dev/null @@ -1,40 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.paging import Paged - - -class PolicyAssignmentPaged(Paged): - """ - A paging container for iterating over a list of :class:`PolicyAssignment ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[PolicyAssignment]'} - } - - def __init__(self, *args, **kwargs): - - super(PolicyAssignmentPaged, self).__init__(*args, **kwargs) -class PolicyDefinitionPaged(Paged): - """ - A paging container for iterating over a list of :class:`PolicyDefinition ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[PolicyDefinition]'} - } - - def __init__(self, *args, **kwargs): - - super(PolicyDefinitionPaged, self).__init__(*args, **kwargs) 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 1f86f6a3029a..f9fc1bc3ffad 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 @@ -1,18 +1,16 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from enum import Enum - class PolicyType(str, Enum): + """The type of policy definition. Possible values are NotSpecified, BuiltIn, and Custom. + """ not_specified = "NotSpecified" built_in = "BuiltIn" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/operations/__init__.py index 2bae0e10444d..00fca18d6555 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/operations/__init__.py @@ -1,12 +1,9 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from ._policy_assignments_operations import PolicyAssignmentsOperations 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 3c8dc016dc06..a044a4bb015f 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 @@ -1,678 +1,631 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class PolicyAssignmentsOperations(object): """PolicyAssignmentsOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.policy.v2015_10_01_preview.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for the operation. Constant value: "2015-10-01-preview". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2015-10-01-preview" - - self.config = config + self._config = config def delete( - self, scope, policy_assignment_name, custom_headers=None, raw=False, **operation_config): + self, + scope, # type: str + policy_assignment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyAssignment" """Deletes a policy assignment. :param scope: The scope of the policy assignment. :type scope: str - :param policy_assignment_name: The name of the policy assignment to - delete. + :param policy_assignment_name: The name of the policy assignment to delete. :type policy_assignment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyAssignment or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyAssignment - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2015-10-01-preview" + # Construct URL - url = self.delete.metadata['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') + 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('PolicyAssignment', response) + deserialized = self._deserialize('PolicyAssignment', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyassignments/{policyAssignmentName}'} + delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyassignments/{policyAssignmentName}'} # type: ignore def create( - self, scope, policy_assignment_name, parameters, custom_headers=None, raw=False, **operation_config): - """Creates a policy assignment. + self, + scope, # type: str + policy_assignment_name, # type: str + parameters, # type: "models.PolicyAssignment" + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyAssignment" + """Policy assignments are inherited by child resources. For example, when you apply a policy to a resource group that policy is assigned to all resources in the group. - Policy assignments are inherited by child resources. For example, when - you apply a policy to a resource group that policy is assigned to all - resources in the group. + Creates a policy assignment. :param scope: The scope of the policy assignment. :type scope: str :param policy_assignment_name: The name of the policy assignment. :type policy_assignment_name: str :param parameters: Parameters for the policy assignment. - :type parameters: - ~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyAssignment - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyAssignment or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyAssignment - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :type parameters: ~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyAssignment + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {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") + # Construct URL - url = self.create.metadata['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') + 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'PolicyAssignment') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 201: - deserialized = self._deserialize('PolicyAssignment', response) + deserialized = self._deserialize('PolicyAssignment', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyassignments/{policyAssignmentName}'} + create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyassignments/{policyAssignmentName}'} # type: ignore def get( - self, scope, policy_assignment_name, custom_headers=None, raw=False, **operation_config): + self, + scope, # type: str + policy_assignment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyAssignment" """Gets a policy assignment. :param scope: The scope of the policy assignment. :type scope: str - :param policy_assignment_name: The name of the policy assignment to - get. + :param policy_assignment_name: The name of the policy assignment to get. :type policy_assignment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyAssignment or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyAssignment - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2015-10-01-preview" + # Construct URL - url = self.get.metadata['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') + 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('PolicyAssignment', response) + deserialized = self._deserialize('PolicyAssignment', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyassignments/{policyAssignmentName}'} + get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyassignments/{policyAssignmentName}'} # type: ignore def list_for_resource_group( - self, resource_group_name, filter=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + filter=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.PolicyAssignmentListResult"] """Gets policy assignments for the resource group. - :param resource_group_name: The name of the resource group that - contains policy assignments. + :param resource_group_name: The name of the resource group that contains policy assignments. :type resource_group_name: str :param filter: The filter to apply on the operation. :type filter: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of PolicyAssignment - :rtype: - ~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyAssignmentPaged[~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyAssignment] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2015-10-01-preview" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_for_resource_group.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.PolicyAssignmentPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_for_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments'} + return ItemPaged( + get_next, extract_data + ) + list_for_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments'} # type: ignore def list_for_resource( - self, resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, filter=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + filter=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.PolicyAssignmentListResult"] """Gets policy assignments for a resource. - :param resource_group_name: The name of the resource group containing - the resource. The name is case insensitive. + :param resource_group_name: The name of the resource group containing the resource. The name is + case insensitive. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource - provider. + :param resource_provider_namespace: The namespace of the resource provider. :type resource_provider_namespace: str :param parent_resource_path: The parent resource path. :type parent_resource_path: str :param resource_type: The resource type. :type resource_type: str - :param resource_name: The name of the resource with policy - assignments. + :param resource_name: The name of the resource with policy assignments. :type resource_name: str :param filter: The filter to apply on the operation. :type filter: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of PolicyAssignment - :rtype: - ~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyAssignmentPaged[~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyAssignment] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2015-10-01-preview" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_for_resource.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.PolicyAssignmentPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_for_resource.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyassignments'} + 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 def list( - self, filter=None, custom_headers=None, raw=False, **operation_config): + self, + filter=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.PolicyAssignmentListResult"] """Gets all the policy assignments for a subscription. :param filter: The filter to apply on the operation. :type filter: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of PolicyAssignment - :rtype: - ~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyAssignmentPaged[~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyAssignment] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2015-10-01-preview" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['url'] + url = self.list.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_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 = {} + 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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.PolicyAssignmentPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyassignments'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyassignments'} # type: ignore def delete_by_id( - self, policy_assignment_id, custom_headers=None, raw=False, **operation_config): - """Deletes a policy assignment by ID. - - When providing a scope for the assignment, use - '/subscriptions/{subscription-id}/' for subscriptions, - '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' - for resource groups, and - '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider-namespace}/{resource-type}/{resource-name}' - for resources. - - :param policy_assignment_id: The ID of the policy assignment to - delete. Use the format + self, + policy_assignment_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyAssignment" + """When providing a scope for the assignment, use '/subscriptions/{subscription-id}/' for subscriptions, '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for resource groups, and '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider-namespace}/{resource-type}/{resource-name}' for resources. + + Deletes a policy assignment by ID. + + :param policy_assignment_id: The ID of the policy assignment to delete. Use the format '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policy-assignment-name}'. :type policy_assignment_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyAssignment or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyAssignment - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2015-10-01-preview" + # Construct URL - url = self.delete_by_id.metadata['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) + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('PolicyAssignment', response) + deserialized = self._deserialize('PolicyAssignment', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - delete_by_id.metadata = {'url': '/{policyAssignmentId}'} + delete_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore def create_by_id( - self, policy_assignment_id, parameters, custom_headers=None, raw=False, **operation_config): - """Creates a policy assignment by ID. - - Policy assignments are inherited by child resources. For example, when - you apply a policy to a resource group that policy is assigned to all - resources in the group. When providing a scope for the assignment, use - '/subscriptions/{subscription-id}/' for subscriptions, - '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' - for resource groups, and - '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider-namespace}/{resource-type}/{resource-name}' - for resources. - - :param policy_assignment_id: The ID of the policy assignment to - create. Use the format + self, + policy_assignment_id, # type: str + parameters, # type: "models.PolicyAssignment" + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyAssignment" + """Policy assignments are inherited by child resources. For example, when you apply a policy to a resource group that policy is assigned to all resources in the group. When providing a scope for the assignment, use '/subscriptions/{subscription-id}/' for subscriptions, '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for resource groups, and '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider-namespace}/{resource-type}/{resource-name}' for resources. + + Creates a policy assignment by ID. + + :param policy_assignment_id: The ID of the policy assignment to create. Use the format '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policy-assignment-name}'. :type policy_assignment_id: str :param parameters: Parameters for policy assignment. - :type parameters: - ~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyAssignment - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyAssignment or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyAssignment - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :type parameters: ~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyAssignment + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {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") + # Construct URL - url = self.create_by_id.metadata['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) + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'PolicyAssignment') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 201: - deserialized = self._deserialize('PolicyAssignment', response) + deserialized = self._deserialize('PolicyAssignment', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create_by_id.metadata = {'url': '/{policyAssignmentId}'} + create_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore def get_by_id( - self, policy_assignment_id, custom_headers=None, raw=False, **operation_config): - """Gets a policy assignment by ID. - - When providing a scope for the assignment, use - '/subscriptions/{subscription-id}/' for subscriptions, - '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' - for resource groups, and - '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider-namespace}/{resource-type}/{resource-name}' - for resources. - - :param policy_assignment_id: The ID of the policy assignment to get. - Use the format + self, + policy_assignment_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyAssignment" + """When providing a scope for the assignment, use '/subscriptions/{subscription-id}/' for subscriptions, '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for resource groups, and '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider-namespace}/{resource-type}/{resource-name}' for resources. + + Gets a policy assignment by ID. + + :param policy_assignment_id: The ID of the policy assignment to get. Use the format '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policy-assignment-name}'. :type policy_assignment_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyAssignment or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyAssignment - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2015-10-01-preview" + # Construct URL - url = self.get_by_id.metadata['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) + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('PolicyAssignment', response) + deserialized = self._deserialize('PolicyAssignment', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/{policyAssignmentId}'} + 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 254227e67e04..f22148479d36 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 @@ -1,288 +1,279 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class PolicyDefinitionsOperations(object): """PolicyDefinitionsOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.policy.v2015_10_01_preview.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for the operation. Constant value: "2015-10-01-preview". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2015-10-01-preview" - - self.config = config + self._config = config def create_or_update( - self, policy_definition_name, parameters, custom_headers=None, raw=False, **operation_config): + self, + policy_definition_name, # type: str + parameters, # type: "models.PolicyDefinition" + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyDefinition" """Creates or updates a policy definition. - :param policy_definition_name: The name of the policy definition to - create. + :param policy_definition_name: The name of the policy definition to create. :type policy_definition_name: str :param parameters: The policy definition properties. - :type parameters: - ~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyDefinition - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyDefinition or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyDefinition - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :type parameters: ~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyDefinition + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyDefinition"] + error_map = {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") + # Construct URL - url = self.create_or_update.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'PolicyDefinition') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [201]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 201: - deserialized = self._deserialize('PolicyDefinition', response) + deserialized = self._deserialize('PolicyDefinition', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions/{policyDefinitionName}'} + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions/{policyDefinitionName}'} # type: ignore def delete( - self, policy_definition_name, custom_headers=None, raw=False, **operation_config): + self, + policy_definition_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Deletes a policy definition. - :param policy_definition_name: The name of the policy definition to - delete. + :param policy_definition_name: The name of the policy definition to delete. :type policy_definition_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2015-10-01-preview" + # Construct URL - url = self.delete.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions/{policyDefinitionName}'} + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions/{policyDefinitionName}'} # type: ignore def get( - self, policy_definition_name, custom_headers=None, raw=False, **operation_config): + self, + policy_definition_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyDefinition" """Gets the policy definition. - :param policy_definition_name: The name of the policy definition to - get. + :param policy_definition_name: The name of the policy definition to get. :type policy_definition_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyDefinition or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyDefinition - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyDefinition + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2015-10-01-preview" + # Construct URL - url = self.get.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('PolicyDefinition', response) + deserialized = self._deserialize('PolicyDefinition', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions/{policyDefinitionName}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions/{policyDefinitionName}'} # type: ignore def list( - self, filter=None, custom_headers=None, raw=False, **operation_config): + self, + filter=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.PolicyDefinitionListResult"] """Gets all the policy definitions for a subscription. :param filter: The filter to apply on the operation. :type filter: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of PolicyDefinition - :rtype: - ~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyDefinitionPaged[~azure.mgmt.resource.policy.v2015_10_01_preview.models.PolicyDefinition] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2015-10-01-preview" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['url'] + url = self.list.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_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 = {} + 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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyDefinitionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.PolicyDefinitionPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/py.typed b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file 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 deleted file mode 100644 index aa8170222621..000000000000 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2015_10_01_preview/version.py +++ /dev/null @@ -1,13 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -VERSION = "2015-10-01-preview" - 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 56bf47bfb9e4..e4bba9352a5c 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 @@ -1,19 +1,16 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._configuration import PolicyClientConfiguration from ._policy_client import PolicyClient -__all__ = ['PolicyClient', 'PolicyClientConfiguration'] - -from .version import VERSION - -__version__ = VERSION +__all__ = ['PolicyClient'] +try: + from ._patch import patch_sdk + patch_sdk() +except ImportError: + pass 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 ede4f42045d0..80ae12f100dc 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 @@ -1,48 +1,69 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrestazure import AzureConfiguration -from .version import VERSION +from typing import TYPE_CHECKING +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + + from azure.core.credentials import TokenCredential + +VERSION = "unknown" + +class PolicyClientConfiguration(Configuration): + """Configuration for PolicyClient. -class PolicyClientConfiguration(AzureConfiguration): - """Configuration for PolicyClient Note that all parameters used to create this instance are saved as instance attributes. - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` + :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 """ def __init__( - self, credentials, subscription_id, base_url=None): - - if credentials is None: - raise ValueError("Parameter 'credentials' must not be None.") + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + 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.") - if not base_url: - base_url = 'https://management.azure.com' + super(PolicyClientConfiguration, self).__init__(**kwargs) - super(PolicyClientConfiguration, self).__init__(base_url) - - # Starting Autorest.Python 4.0.64, make connection pool activated by default - self.keep_alive = True - - self.add_user_agent('azure-mgmt-resource/{}'.format(VERSION)) - self.add_user_agent('Azure-SDK-For-Python') - - self.credentials = credentials + self.credential = credential self.subscription_id = subscription_id + self.api_version = "2016-04-01" + self.credential_scopes = ['https://management.azure.com/.default'] + self.credential_scopes.extend(kwargs.pop('credential_scopes', [])) + kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + 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) 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 new file mode 100644 index 000000000000..4cd84faa9251 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/_metadata.json @@ -0,0 +1,54 @@ +{ + "chosen_version": "2016-04-01", + "total_api_version_list": ["2016-04-01"], + "client": { + "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." + }, + "global_parameters": { + "sync_method": { + "credential": { + "method_signature": "credential, # type: \"TokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials.TokenCredential", + "required": true + }, + "subscription_id": { + "method_signature": "subscription_id, # type: str", + "description": "The ID of the target subscription.", + "docstring_type": "str", + "required": true + } + }, + "async_method": { + "credential": { + "method_signature": "credential, # type: \"AsyncTokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + }, + "subscription_id": { + "method_signature": "subscription_id, # type: str", + "description": "The ID of the target subscription.", + "docstring_type": "str", + "required": true + } + }, + "constant": { + }, + "call": "credential, subscription_id" + }, + "config": { + "credential": true, + "credential_scopes": ["https://management.azure.com/.default"] + }, + "operation_groups": { + "policy_assignments": "PolicyAssignmentsOperations", + "policy_definitions": "PolicyDefinitionsOperations" + }, + "operation_mixins": { + }, + "sync_imports": "None", + "async_imports": "None" +} \ 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 cedfb2dbeb95..14b95699abad 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 @@ -1,16 +1,19 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.service_client import SDKClient -from msrest import Serializer, Deserializer +from typing import TYPE_CHECKING + +from azure.mgmt.core import ARMPipelineClient +from msrest import Deserializer, Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional from ._configuration import PolicyClientConfiguration from .operations import PolicyAssignmentsOperations @@ -18,37 +21,52 @@ from . import models -class PolicyClient(SDKClient): +class PolicyClient(object): """To manage and control access to your resources, you can define customized policies and assign them at a scope. - :ivar config: Configuration for client. - :vartype config: PolicyClientConfiguration - - :ivar policy_assignments: PolicyAssignments operations + :ivar policy_assignments: PolicyAssignmentsOperations operations :vartype policy_assignments: azure.mgmt.resource.policy.v2016_04_01.operations.PolicyAssignmentsOperations - :ivar policy_definitions: PolicyDefinitions operations + :ivar policy_definitions: PolicyDefinitionsOperations operations :vartype policy_definitions: azure.mgmt.resource.policy.v2016_04_01.operations.PolicyDefinitionsOperations - - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` + :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. """ def __init__( - self, credentials, subscription_id, base_url=None): - - self.config = PolicyClientConfiguration(credentials, subscription_id, base_url) - super(PolicyClient, self).__init__(self.config.credentials, self.config) + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = 'https://management.azure.com' + self._config = PolicyClientConfiguration(credential, 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.api_version = '2016-04-01' self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self.policy_assignments = PolicyAssignmentsOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.policy_definitions = PolicyDefinitionsOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> PolicyClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_preview/version.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/aio/__init__.py similarity index 76% rename from sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_preview/version.py rename to sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/aio/__init__.py index 90309975708c..df3c0beab48a 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/deploymentscripts/v2019_10_preview/version.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/aio/__init__.py @@ -1,13 +1,10 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2019-10-01-preview" - +from ._policy_client_async import PolicyClient +__all__ = ['PolicyClient'] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/aio/_configuration_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/aio/_configuration_async.py new file mode 100644 index 000000000000..5912bfda6955 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/aio/_configuration_async.py @@ -0,0 +1,65 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + +VERSION = "unknown" + +class PolicyClientConfiguration(Configuration): + """Configuration for PolicyClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :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 + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + 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 + self.api_version = "2016-04-01" + self.credential_scopes = ['https://management.azure.com/.default'] + self.credential_scopes.extend(kwargs.pop('credential_scopes', [])) + kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs: Any + ) -> None: + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + 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) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/aio/_policy_client_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/aio/_policy_client_async.py new file mode 100644 index 000000000000..18249aa5740a --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/aio/_policy_client_async.py @@ -0,0 +1,64 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, Optional + +from azure.mgmt.core import AsyncARMPipelineClient +from msrest import Deserializer, Serializer + +from ._configuration_async import PolicyClientConfiguration +from .operations_async import PolicyAssignmentsOperations +from .operations_async import PolicyDefinitionsOperations +from .. import models + + +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.aio.operations_async.PolicyAssignmentsOperations + :ivar policy_definitions: PolicyDefinitionsOperations operations + :vartype policy_definitions: azure.mgmt.resource.policy.v2016_04_01.aio.operations_async.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 + :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, + **kwargs: 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) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + + self.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 close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "PolicyClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/aio/operations_async/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/aio/operations_async/__init__.py new file mode 100644 index 000000000000..04da551aae58 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/aio/operations_async/__init__.py @@ -0,0 +1,15 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._policy_assignments_operations_async import PolicyAssignmentsOperations +from ._policy_definitions_operations_async import PolicyDefinitionsOperations + +__all__ = [ + 'PolicyAssignmentsOperations', + 'PolicyDefinitionsOperations', +] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/aio/operations_async/_policy_assignments_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/aio/operations_async/_policy_assignments_operations_async.py new file mode 100644 index 000000000000..f1b2731db7f6 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/aio/operations_async/_policy_assignments_operations_async.py @@ -0,0 +1,618 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import 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 ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class PolicyAssignmentsOperations: + """PolicyAssignmentsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.policy.v2016_04_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def delete( + self, + scope: str, + policy_assignment_name: str, + **kwargs + ) -> "models.PolicyAssignment": + """Deletes a policy assignment. + + :param scope: The scope of the policy assignment. + :type scope: str + :param policy_assignment_name: The name of the policy assignment to delete. + :type policy_assignment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {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 = { + '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'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyassignments/{policyAssignmentName}'} # type: ignore + + async def create( + self, + scope: str, + policy_assignment_name: str, + parameters: "models.PolicyAssignment", + **kwargs + ) -> "models.PolicyAssignment": + """Policy assignments are inherited by child resources. For example, when you apply a policy to a resource group that policy is assigned to all resources in the group. + + Creates a policy assignment. + + :param scope: The scope of the policy assignment. + :type scope: str + :param policy_assignment_name: The name of the policy assignment. + :type policy_assignment_name: str + :param parameters: Parameters for the policy assignment. + :type parameters: ~azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignment + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-04-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyassignments/{policyAssignmentName}'} # type: ignore + + async def get( + self, + scope: str, + policy_assignment_name: str, + **kwargs + ) -> "models.PolicyAssignment": + """Gets a policy assignment. + + :param scope: The scope of the policy assignment. + :type scope: str + :param policy_assignment_name: The name of the policy assignment to get. + :type policy_assignment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-04-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyassignments/{policyAssignmentName}'} # type: ignore + + def list_for_resource_group( + self, + resource_group_name: str, + filter: Optional[str] = None, + **kwargs + ) -> AsyncIterable["models.PolicyAssignmentListResult"]: + """Gets policy assignments for the resource group. + + :param resource_group_name: The name of the resource group that contains policy assignments. + :type resource_group_name: str + :param filter: The filter to apply on the operation. + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-04-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, 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 + + def list_for_resource( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + filter: Optional[str] = None, + **kwargs + ) -> AsyncIterable["models.PolicyAssignmentListResult"]: + """Gets policy assignments for a resource. + + :param resource_group_name: The name of the resource group containing the resource. The name is + case insensitive. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource path. + :type parent_resource_path: str + :param resource_type: The resource type. + :type resource_type: str + :param resource_name: The name of the resource with policy assignments. + :type resource_name: str + :param filter: The filter to apply on the operation. + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-04-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, 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 + + def list( + self, + filter: Optional[str] = None, + **kwargs + ) -> AsyncIterable["models.PolicyAssignmentListResult"]: + """Gets all the policy assignments for a subscription. + + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-04-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyassignments'} # type: ignore + + async def delete_by_id( + self, + policy_assignment_id: str, + **kwargs + ) -> "models.PolicyAssignment": + """When providing a scope for the assignment, use '/subscriptions/{subscription-id}/' for subscriptions, '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for resource groups, and '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider-namespace}/{resource-type}/{resource-name}' for resources. + + Deletes a policy assignment by ID. + + :param policy_assignment_id: The ID of the policy assignment to delete. Use the format + '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policy-assignment-name}'. + :type policy_assignment_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-04-01" + + # 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'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + delete_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + + async def create_by_id( + self, + policy_assignment_id: str, + parameters: "models.PolicyAssignment", + **kwargs + ) -> "models.PolicyAssignment": + """Policy assignments are inherited by child resources. For example, when you apply a policy to a resource group that policy is assigned to all resources in the group. When providing a scope for the assignment, use '/subscriptions/{subscription-id}/' for subscriptions, '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for resource groups, and '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider-namespace}/{resource-type}/{resource-name}' for resources. + + Creates a policy assignment by ID. + + :param policy_assignment_id: The ID of the policy assignment to create. Use the format + '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policy-assignment-name}'. + :type policy_assignment_id: str + :param parameters: Parameters for policy assignment. + :type parameters: ~azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignment + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-04-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + + async def get_by_id( + self, + policy_assignment_id: str, + **kwargs + ) -> "models.PolicyAssignment": + """When providing a scope for the assignment, use '/subscriptions/{subscription-id}/' for subscriptions, '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for resource groups, and '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider-namespace}/{resource-type}/{resource-name}' for resources. + + Gets a policy assignment by ID. + + :param policy_assignment_id: The ID of the policy assignment to get. Use the format + '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policy-assignment-name}'. + :type policy_assignment_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-04-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyAssignment', pipeline_response) + + if cls: + 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_async/_policy_definitions_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/aio/operations_async/_policy_definitions_operations_async.py new file mode 100644 index 000000000000..89526326ef7c --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/aio/operations_async/_policy_definitions_operations_async.py @@ -0,0 +1,271 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import 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 ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class PolicyDefinitionsOperations: + """PolicyDefinitionsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.policy.v2016_04_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def create_or_update( + self, + policy_definition_name: str, + parameters: "models.PolicyDefinition", + **kwargs + ) -> "models.PolicyDefinition": + """Creates or updates a policy definition. + + :param policy_definition_name: The name of the policy definition to create. + :type policy_definition_name: str + :param parameters: The policy definition properties. + :type parameters: ~azure.mgmt.resource.policy.v2016_04_01.models.PolicyDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2016_04_01.models.PolicyDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-04-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions/{policyDefinitionName}'} # type: ignore + + async def delete( + self, + policy_definition_name: str, + **kwargs + ) -> None: + """Deletes a policy definition. + + :param policy_definition_name: The name of the policy definition to delete. + :type policy_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions/{policyDefinitionName}'} # type: ignore + + async def get( + self, + policy_definition_name: str, + **kwargs + ) -> "models.PolicyDefinition": + """Gets the policy definition. + + :param policy_definition_name: The name of the policy definition to get. + :type policy_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2016_04_01.models.PolicyDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-04-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions/{policyDefinitionName}'} # type: ignore + + def list( + self, + filter: Optional[str] = None, + **kwargs + ) -> AsyncIterable["models.PolicyDefinitionListResult"]: + """Gets all the policy definitions for a subscription. + + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-04-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyDefinitionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/models/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/models/__init__.py index 09123683300d..e3aa53d09d9c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/models/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/models/__init__.py @@ -1,30 +1,30 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- try: from ._models_py3 import PolicyAssignment + from ._models_py3 import PolicyAssignmentListResult from ._models_py3 import PolicyDefinition + from ._models_py3 import PolicyDefinitionListResult except (SyntaxError, ImportError): - from ._models import PolicyAssignment - from ._models import PolicyDefinition -from ._paged_models import PolicyAssignmentPaged -from ._paged_models import PolicyDefinitionPaged + from ._models import PolicyAssignment # type: ignore + from ._models import PolicyAssignmentListResult # type: ignore + from ._models import PolicyDefinition # type: ignore + from ._models import PolicyDefinitionListResult # type: ignore + from ._policy_client_enums import ( PolicyType, ) __all__ = [ 'PolicyAssignment', + 'PolicyAssignmentListResult', 'PolicyDefinition', - 'PolicyAssignmentPaged', - 'PolicyDefinitionPaged', + 'PolicyDefinitionListResult', 'PolicyType', ] 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 e1e7a613a531..adadad757d01 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 @@ -1,84 +1,95 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.serialization import Model +import msrest.serialization -class CloudError(Model): - """CloudError. - """ - - _attribute_map = { - } - - -class PolicyAssignment(Model): +class PolicyAssignment(msrest.serialization.Model): """The policy assignment. - :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 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 """ _attribute_map = { - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'policy_definition_id': {'key': 'properties.policyDefinitionId', 'type': 'str'}, - 'scope': {'key': 'properties.scope', 'type': 'str'}, 'id': {'key': 'id', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, + 'display_name': {'key': 'properties.displayName', 'type': 'str'}, + 'policy_definition_id': {'key': 'properties.policyDefinitionId', 'type': 'str'}, + 'scope': {'key': 'properties.scope', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(PolicyAssignment, self).__init__(**kwargs) - self.display_name = kwargs.get('display_name', None) - self.policy_definition_id = kwargs.get('policy_definition_id', None) - self.scope = kwargs.get('scope', None) self.id = kwargs.get('id', None) self.type = kwargs.get('type', None) self.name = kwargs.get('name', None) + self.display_name = kwargs.get('display_name', None) + self.policy_definition_id = kwargs.get('policy_definition_id', None) + self.scope = kwargs.get('scope', None) -class PolicyDefinition(Model): +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 + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[PolicyAssignment]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(PolicyAssignmentListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class PolicyDefinition(msrest.serialization.Model): """The policy definition. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :param 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 + :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 + 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, + 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: object - :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 value is inferred from the name value in the request - URI. - :type name: str """ _validation = { @@ -86,19 +97,45 @@ class PolicyDefinition(Model): } _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, 'policy_type': {'key': 'properties.policyType', 'type': 'str'}, 'display_name': {'key': 'properties.displayName', 'type': 'str'}, 'description': {'key': 'properties.description', 'type': 'str'}, 'policy_rule': {'key': 'properties.policyRule', 'type': 'object'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(PolicyDefinition, self).__init__(**kwargs) + self.id = None + self.name = kwargs.get('name', None) self.policy_type = kwargs.get('policy_type', None) self.display_name = kwargs.get('display_name', None) self.description = kwargs.get('description', None) self.policy_rule = kwargs.get('policy_rule', None) - self.id = None - self.name = kwargs.get('name', None) + + +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 + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[PolicyDefinition]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + 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 2dbbb7f60952..7f083c96ae7e 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 @@ -1,84 +1,109 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.serialization import Model +from typing import List, Optional, Union +import msrest.serialization -class CloudError(Model): - """CloudError. - """ - - _attribute_map = { - } +from ._policy_client_enums import * -class PolicyAssignment(Model): +class PolicyAssignment(msrest.serialization.Model): """The policy assignment. - :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 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 """ _attribute_map = { - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'policy_definition_id': {'key': 'properties.policyDefinitionId', 'type': 'str'}, - 'scope': {'key': 'properties.scope', 'type': 'str'}, 'id': {'key': 'id', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, + 'display_name': {'key': 'properties.displayName', 'type': 'str'}, + 'policy_definition_id': {'key': 'properties.policyDefinitionId', 'type': 'str'}, + 'scope': {'key': 'properties.scope', 'type': 'str'}, } - def __init__(self, *, display_name: str=None, policy_definition_id: str=None, scope: str=None, id: str=None, type: str=None, name: str=None, **kwargs) -> None: + def __init__( + self, + *, + id: Optional[str] = None, + type: Optional[str] = None, + name: Optional[str] = None, + display_name: Optional[str] = None, + policy_definition_id: Optional[str] = None, + scope: Optional[str] = None, + **kwargs + ): super(PolicyAssignment, self).__init__(**kwargs) - self.display_name = display_name - self.policy_definition_id = policy_definition_id - self.scope = scope self.id = id self.type = type self.name = name + self.display_name = display_name + self.policy_definition_id = policy_definition_id + self.scope = scope + +class PolicyAssignmentListResult(msrest.serialization.Model): + """List of policy assignments. -class PolicyDefinition(Model): + :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 + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[PolicyAssignment]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["PolicyAssignment"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(PolicyAssignmentListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class PolicyDefinition(msrest.serialization.Model): """The policy definition. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :param 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 + :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 + 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, + 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: object - :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 value is inferred from the name value in the request - URI. - :type name: str """ _validation = { @@ -86,19 +111,54 @@ class PolicyDefinition(Model): } _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, 'policy_type': {'key': 'properties.policyType', 'type': 'str'}, 'display_name': {'key': 'properties.displayName', 'type': 'str'}, 'description': {'key': 'properties.description', 'type': 'str'}, 'policy_rule': {'key': 'properties.policyRule', 'type': 'object'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, } - def __init__(self, *, policy_type=None, display_name: str=None, description: str=None, policy_rule=None, name: str=None, **kwargs) -> None: + def __init__( + self, + *, + name: Optional[str] = None, + policy_type: Optional[Union[str, "PolicyType"]] = None, + display_name: Optional[str] = None, + description: Optional[str] = None, + policy_rule: Optional[object] = None, + **kwargs + ): super(PolicyDefinition, self).__init__(**kwargs) + self.id = None + self.name = name self.policy_type = policy_type self.display_name = display_name self.description = description self.policy_rule = policy_rule - self.id = None - self.name = name + + +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 + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[PolicyDefinition]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["PolicyDefinition"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + 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/_paged_models.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/models/_paged_models.py deleted file mode 100644 index 48f651cb865c..000000000000 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/models/_paged_models.py +++ /dev/null @@ -1,40 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.paging import Paged - - -class PolicyAssignmentPaged(Paged): - """ - A paging container for iterating over a list of :class:`PolicyAssignment ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[PolicyAssignment]'} - } - - def __init__(self, *args, **kwargs): - - super(PolicyAssignmentPaged, self).__init__(*args, **kwargs) -class PolicyDefinitionPaged(Paged): - """ - A paging container for iterating over a list of :class:`PolicyDefinition ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[PolicyDefinition]'} - } - - def __init__(self, *args, **kwargs): - - super(PolicyDefinitionPaged, self).__init__(*args, **kwargs) 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 1f86f6a3029a..f9fc1bc3ffad 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 @@ -1,18 +1,16 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from enum import Enum - class PolicyType(str, Enum): + """The type of policy definition. Possible values are NotSpecified, BuiltIn, and Custom. + """ not_specified = "NotSpecified" built_in = "BuiltIn" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/operations/__init__.py index 2bae0e10444d..00fca18d6555 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/operations/__init__.py @@ -1,12 +1,9 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from ._policy_assignments_operations import PolicyAssignmentsOperations 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 670e64b02432..97ff4100c0d6 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 @@ -1,678 +1,631 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class PolicyAssignmentsOperations(object): """PolicyAssignmentsOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.policy.v2016_04_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for the operation. Constant value: "2016-04-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2016-04-01" - - self.config = config + self._config = config def delete( - self, scope, policy_assignment_name, custom_headers=None, raw=False, **operation_config): + self, + scope, # type: str + policy_assignment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyAssignment" """Deletes a policy assignment. :param scope: The scope of the policy assignment. :type scope: str - :param policy_assignment_name: The name of the policy assignment to - delete. + :param policy_assignment_name: The name of the policy assignment to delete. :type policy_assignment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyAssignment or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignment or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-04-01" + # Construct URL - url = self.delete.metadata['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') + 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('PolicyAssignment', response) + deserialized = self._deserialize('PolicyAssignment', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyassignments/{policyAssignmentName}'} + delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyassignments/{policyAssignmentName}'} # type: ignore def create( - self, scope, policy_assignment_name, parameters, custom_headers=None, raw=False, **operation_config): - """Creates a policy assignment. + self, + scope, # type: str + policy_assignment_name, # type: str + parameters, # type: "models.PolicyAssignment" + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyAssignment" + """Policy assignments are inherited by child resources. For example, when you apply a policy to a resource group that policy is assigned to all resources in the group. - Policy assignments are inherited by child resources. For example, when - you apply a policy to a resource group that policy is assigned to all - resources in the group. + Creates a policy assignment. :param scope: The scope of the policy assignment. :type scope: str :param policy_assignment_name: The name of the policy assignment. :type policy_assignment_name: str :param parameters: Parameters for the policy assignment. - :type parameters: - ~azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignment - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyAssignment or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignment or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :type parameters: ~azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignment + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-04-01" + content_type = kwargs.pop("content_type", "application/json") + # Construct URL - url = self.create.metadata['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') + 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'PolicyAssignment') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 201: - deserialized = self._deserialize('PolicyAssignment', response) + deserialized = self._deserialize('PolicyAssignment', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyassignments/{policyAssignmentName}'} + create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyassignments/{policyAssignmentName}'} # type: ignore def get( - self, scope, policy_assignment_name, custom_headers=None, raw=False, **operation_config): + self, + scope, # type: str + policy_assignment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyAssignment" """Gets a policy assignment. :param scope: The scope of the policy assignment. :type scope: str - :param policy_assignment_name: The name of the policy assignment to - get. + :param policy_assignment_name: The name of the policy assignment to get. :type policy_assignment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyAssignment or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignment or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-04-01" + # Construct URL - url = self.get.metadata['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') + 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('PolicyAssignment', response) + deserialized = self._deserialize('PolicyAssignment', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyassignments/{policyAssignmentName}'} + get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyassignments/{policyAssignmentName}'} # type: ignore def list_for_resource_group( - self, resource_group_name, filter=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + filter=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.PolicyAssignmentListResult"] """Gets policy assignments for the resource group. - :param resource_group_name: The name of the resource group that - contains policy assignments. + :param resource_group_name: The name of the resource group that contains policy assignments. :type resource_group_name: str :param filter: The filter to apply on the operation. :type filter: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of PolicyAssignment - :rtype: - ~azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignmentPaged[~azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignment] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-04-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_for_resource_group.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.PolicyAssignmentPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_for_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments'} + return ItemPaged( + get_next, extract_data + ) + list_for_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments'} # type: ignore def list_for_resource( - self, resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, filter=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + filter=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.PolicyAssignmentListResult"] """Gets policy assignments for a resource. - :param resource_group_name: The name of the resource group containing - the resource. The name is case insensitive. + :param resource_group_name: The name of the resource group containing the resource. The name is + case insensitive. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource - provider. + :param resource_provider_namespace: The namespace of the resource provider. :type resource_provider_namespace: str :param parent_resource_path: The parent resource path. :type parent_resource_path: str :param resource_type: The resource type. :type resource_type: str - :param resource_name: The name of the resource with policy - assignments. + :param resource_name: The name of the resource with policy assignments. :type resource_name: str :param filter: The filter to apply on the operation. :type filter: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of PolicyAssignment - :rtype: - ~azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignmentPaged[~azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignment] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-04-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_for_resource.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.PolicyAssignmentPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_for_resource.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyassignments'} + 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 def list( - self, filter=None, custom_headers=None, raw=False, **operation_config): + self, + filter=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.PolicyAssignmentListResult"] """Gets all the policy assignments for a subscription. :param filter: The filter to apply on the operation. :type filter: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of PolicyAssignment - :rtype: - ~azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignmentPaged[~azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignment] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-04-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['url'] + url = self.list.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_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 = {} + 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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.PolicyAssignmentPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyassignments'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyassignments'} # type: ignore def delete_by_id( - self, policy_assignment_id, custom_headers=None, raw=False, **operation_config): - """Deletes a policy assignment by ID. - - When providing a scope for the assignment, use - '/subscriptions/{subscription-id}/' for subscriptions, - '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' - for resource groups, and - '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider-namespace}/{resource-type}/{resource-name}' - for resources. - - :param policy_assignment_id: The ID of the policy assignment to - delete. Use the format + self, + policy_assignment_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyAssignment" + """When providing a scope for the assignment, use '/subscriptions/{subscription-id}/' for subscriptions, '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for resource groups, and '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider-namespace}/{resource-type}/{resource-name}' for resources. + + Deletes a policy assignment by ID. + + :param policy_assignment_id: The ID of the policy assignment to delete. Use the format '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policy-assignment-name}'. :type policy_assignment_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyAssignment or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignment or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-04-01" + # Construct URL - url = self.delete_by_id.metadata['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) + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('PolicyAssignment', response) + deserialized = self._deserialize('PolicyAssignment', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - delete_by_id.metadata = {'url': '/{policyAssignmentId}'} + delete_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore def create_by_id( - self, policy_assignment_id, parameters, custom_headers=None, raw=False, **operation_config): - """Creates a policy assignment by ID. - - Policy assignments are inherited by child resources. For example, when - you apply a policy to a resource group that policy is assigned to all - resources in the group. When providing a scope for the assignment, use - '/subscriptions/{subscription-id}/' for subscriptions, - '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' - for resource groups, and - '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider-namespace}/{resource-type}/{resource-name}' - for resources. - - :param policy_assignment_id: The ID of the policy assignment to - create. Use the format + self, + policy_assignment_id, # type: str + parameters, # type: "models.PolicyAssignment" + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyAssignment" + """Policy assignments are inherited by child resources. For example, when you apply a policy to a resource group that policy is assigned to all resources in the group. When providing a scope for the assignment, use '/subscriptions/{subscription-id}/' for subscriptions, '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for resource groups, and '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider-namespace}/{resource-type}/{resource-name}' for resources. + + Creates a policy assignment by ID. + + :param policy_assignment_id: The ID of the policy assignment to create. Use the format '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policy-assignment-name}'. :type policy_assignment_id: str :param parameters: Parameters for policy assignment. - :type parameters: - ~azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignment - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyAssignment or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignment or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :type parameters: ~azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignment + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-04-01" + content_type = kwargs.pop("content_type", "application/json") + # Construct URL - url = self.create_by_id.metadata['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) + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'PolicyAssignment') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 201: - deserialized = self._deserialize('PolicyAssignment', response) + deserialized = self._deserialize('PolicyAssignment', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create_by_id.metadata = {'url': '/{policyAssignmentId}'} + create_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore def get_by_id( - self, policy_assignment_id, custom_headers=None, raw=False, **operation_config): - """Gets a policy assignment by ID. - - When providing a scope for the assignment, use - '/subscriptions/{subscription-id}/' for subscriptions, - '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' - for resource groups, and - '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider-namespace}/{resource-type}/{resource-name}' - for resources. - - :param policy_assignment_id: The ID of the policy assignment to get. - Use the format + self, + policy_assignment_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyAssignment" + """When providing a scope for the assignment, use '/subscriptions/{subscription-id}/' for subscriptions, '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for resource groups, and '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider-namespace}/{resource-type}/{resource-name}' for resources. + + Gets a policy assignment by ID. + + :param policy_assignment_id: The ID of the policy assignment to get. Use the format '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policy-assignment-name}'. :type policy_assignment_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyAssignment or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignment or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2016_04_01.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-04-01" + # Construct URL - url = self.get_by_id.metadata['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) + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('PolicyAssignment', response) + deserialized = self._deserialize('PolicyAssignment', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/{policyAssignmentId}'} + 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 6512160fdafb..749075feff8c 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 @@ -1,288 +1,279 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class PolicyDefinitionsOperations(object): """PolicyDefinitionsOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.policy.v2016_04_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for the operation. Constant value: "2016-04-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2016-04-01" - - self.config = config + self._config = config def create_or_update( - self, policy_definition_name, parameters, custom_headers=None, raw=False, **operation_config): + self, + policy_definition_name, # type: str + parameters, # type: "models.PolicyDefinition" + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyDefinition" """Creates or updates a policy definition. - :param policy_definition_name: The name of the policy definition to - create. + :param policy_definition_name: The name of the policy definition to create. :type policy_definition_name: str :param parameters: The policy definition properties. - :type parameters: - ~azure.mgmt.resource.policy.v2016_04_01.models.PolicyDefinition - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyDefinition or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2016_04_01.models.PolicyDefinition or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :type parameters: ~azure.mgmt.resource.policy.v2016_04_01.models.PolicyDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2016_04_01.models.PolicyDefinition + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-04-01" + content_type = kwargs.pop("content_type", "application/json") + # Construct URL - url = self.create_or_update.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'PolicyDefinition') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [201]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 201: - deserialized = self._deserialize('PolicyDefinition', response) + deserialized = self._deserialize('PolicyDefinition', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions/{policyDefinitionName}'} + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions/{policyDefinitionName}'} # type: ignore def delete( - self, policy_definition_name, custom_headers=None, raw=False, **operation_config): + self, + policy_definition_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Deletes a policy definition. - :param policy_definition_name: The name of the policy definition to - delete. + :param policy_definition_name: The name of the policy definition to delete. :type policy_definition_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-04-01" + # Construct URL - url = self.delete.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions/{policyDefinitionName}'} + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions/{policyDefinitionName}'} # type: ignore def get( - self, policy_definition_name, custom_headers=None, raw=False, **operation_config): + self, + policy_definition_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyDefinition" """Gets the policy definition. - :param policy_definition_name: The name of the policy definition to - get. + :param policy_definition_name: The name of the policy definition to get. :type policy_definition_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyDefinition or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2016_04_01.models.PolicyDefinition or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2016_04_01.models.PolicyDefinition + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-04-01" + # Construct URL - url = self.get.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('PolicyDefinition', response) + deserialized = self._deserialize('PolicyDefinition', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions/{policyDefinitionName}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions/{policyDefinitionName}'} # type: ignore def list( - self, filter=None, custom_headers=None, raw=False, **operation_config): + self, + filter=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.PolicyDefinitionListResult"] """Gets all the policy definitions for a subscription. :param filter: The filter to apply on the operation. :type filter: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of PolicyDefinition - :rtype: - ~azure.mgmt.resource.policy.v2016_04_01.models.PolicyDefinitionPaged[~azure.mgmt.resource.policy.v2016_04_01.models.PolicyDefinition] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-04-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['url'] + url = self.list.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_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 = {} + 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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyDefinitionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.PolicyDefinitionPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/py.typed b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file 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 deleted file mode 100644 index 5ddeb1e4b90a..000000000000 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/version.py +++ /dev/null @@ -1,13 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -VERSION = "2016-04-01" - 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 56bf47bfb9e4..e4bba9352a5c 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 @@ -1,19 +1,16 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._configuration import PolicyClientConfiguration from ._policy_client import PolicyClient -__all__ = ['PolicyClient', 'PolicyClientConfiguration'] - -from .version import VERSION - -__version__ = VERSION +__all__ = ['PolicyClient'] +try: + from ._patch import patch_sdk + patch_sdk() +except ImportError: + pass 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 ede4f42045d0..59c542c5efaf 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 @@ -1,48 +1,69 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrestazure import AzureConfiguration -from .version import VERSION +from typing import TYPE_CHECKING +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + + from azure.core.credentials import TokenCredential + +VERSION = "unknown" + +class PolicyClientConfiguration(Configuration): + """Configuration for PolicyClient. -class PolicyClientConfiguration(AzureConfiguration): - """Configuration for PolicyClient Note that all parameters used to create this instance are saved as instance attributes. - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` + :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 """ def __init__( - self, credentials, subscription_id, base_url=None): - - if credentials is None: - raise ValueError("Parameter 'credentials' must not be None.") + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + 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.") - if not base_url: - base_url = 'https://management.azure.com' + super(PolicyClientConfiguration, self).__init__(**kwargs) - super(PolicyClientConfiguration, self).__init__(base_url) - - # Starting Autorest.Python 4.0.64, make connection pool activated by default - self.keep_alive = True - - self.add_user_agent('azure-mgmt-resource/{}'.format(VERSION)) - self.add_user_agent('Azure-SDK-For-Python') - - self.credentials = credentials + self.credential = credential self.subscription_id = subscription_id + self.api_version = "2016-12-01" + self.credential_scopes = ['https://management.azure.com/.default'] + self.credential_scopes.extend(kwargs.pop('credential_scopes', [])) + kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + 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) 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 new file mode 100644 index 000000000000..d355e75492ab --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/_metadata.json @@ -0,0 +1,54 @@ +{ + "chosen_version": "2016-12-01", + "total_api_version_list": ["2016-12-01"], + "client": { + "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." + }, + "global_parameters": { + "sync_method": { + "credential": { + "method_signature": "credential, # type: \"TokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials.TokenCredential", + "required": true + }, + "subscription_id": { + "method_signature": "subscription_id, # type: str", + "description": "The ID of the target subscription.", + "docstring_type": "str", + "required": true + } + }, + "async_method": { + "credential": { + "method_signature": "credential, # type: \"AsyncTokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + }, + "subscription_id": { + "method_signature": "subscription_id, # type: str", + "description": "The ID of the target subscription.", + "docstring_type": "str", + "required": true + } + }, + "constant": { + }, + "call": "credential, subscription_id" + }, + "config": { + "credential": true, + "credential_scopes": ["https://management.azure.com/.default"] + }, + "operation_groups": { + "policy_definitions": "PolicyDefinitionsOperations", + "policy_assignments": "PolicyAssignmentsOperations" + }, + "operation_mixins": { + }, + "sync_imports": "None", + "async_imports": "None" +} \ 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 64180bde7926..cd9203f70cea 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 @@ -1,16 +1,19 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.service_client import SDKClient -from msrest import Serializer, Deserializer +from typing import TYPE_CHECKING + +from azure.mgmt.core import ARMPipelineClient +from msrest import Deserializer, Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional from ._configuration import PolicyClientConfiguration from .operations import PolicyDefinitionsOperations @@ -18,37 +21,52 @@ from . import models -class PolicyClient(SDKClient): +class PolicyClient(object): """To manage and control access to your resources, you can define customized policies and assign them at a scope. - :ivar config: Configuration for client. - :vartype config: PolicyClientConfiguration - - :ivar policy_definitions: PolicyDefinitions operations + :ivar policy_definitions: PolicyDefinitionsOperations operations :vartype policy_definitions: azure.mgmt.resource.policy.v2016_12_01.operations.PolicyDefinitionsOperations - :ivar policy_assignments: PolicyAssignments operations + :ivar policy_assignments: PolicyAssignmentsOperations operations :vartype policy_assignments: azure.mgmt.resource.policy.v2016_12_01.operations.PolicyAssignmentsOperations - - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` + :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. """ def __init__( - self, credentials, subscription_id, base_url=None): - - self.config = PolicyClientConfiguration(credentials, subscription_id, base_url) - super(PolicyClient, self).__init__(self.config.credentials, self.config) + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = 'https://management.azure.com' + self._config = PolicyClientConfiguration(credential, 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.api_version = '2016-12-01' self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self.policy_definitions = PolicyDefinitionsOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.policy_assignments = PolicyAssignmentsOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> PolicyClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) 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/policy/v2016_12_01/aio/__init__.py similarity index 76% rename from sdk/resources/azure-mgmt-resource/azure/mgmt/resource/locks/v2015_01_01/version.py rename to sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/aio/__init__.py index 14950bff1ccb..df3c0beab48a 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/policy/v2016_12_01/aio/__init__.py @@ -1,13 +1,10 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2015-01-01" - +from ._policy_client_async import PolicyClient +__all__ = ['PolicyClient'] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/aio/_configuration_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/aio/_configuration_async.py new file mode 100644 index 000000000000..990200880210 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/aio/_configuration_async.py @@ -0,0 +1,65 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + +VERSION = "unknown" + +class PolicyClientConfiguration(Configuration): + """Configuration for PolicyClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :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 + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + 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 + self.api_version = "2016-12-01" + self.credential_scopes = ['https://management.azure.com/.default'] + self.credential_scopes.extend(kwargs.pop('credential_scopes', [])) + kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs: Any + ) -> None: + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + 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) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/aio/_policy_client_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/aio/_policy_client_async.py new file mode 100644 index 000000000000..d30fd7a253ea --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/aio/_policy_client_async.py @@ -0,0 +1,64 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, Optional + +from azure.mgmt.core import AsyncARMPipelineClient +from msrest import Deserializer, Serializer + +from ._configuration_async import PolicyClientConfiguration +from .operations_async import PolicyDefinitionsOperations +from .operations_async import PolicyAssignmentsOperations +from .. import models + + +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.aio.operations_async.PolicyDefinitionsOperations + :ivar policy_assignments: PolicyAssignmentsOperations operations + :vartype policy_assignments: azure.mgmt.resource.policy.v2016_12_01.aio.operations_async.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 + :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, + **kwargs: 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) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + + self.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 close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "PolicyClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/aio/operations_async/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/aio/operations_async/__init__.py new file mode 100644 index 000000000000..61cf122561c4 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/aio/operations_async/__init__.py @@ -0,0 +1,15 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._policy_definitions_operations_async import PolicyDefinitionsOperations +from ._policy_assignments_operations_async import PolicyAssignmentsOperations + +__all__ = [ + 'PolicyDefinitionsOperations', + 'PolicyAssignmentsOperations', +] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/aio/operations_async/_policy_assignments_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/aio/operations_async/_policy_assignments_operations_async.py new file mode 100644 index 000000000000..2100ed1579c2 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/aio/operations_async/_policy_assignments_operations_async.py @@ -0,0 +1,620 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import 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 ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class PolicyAssignmentsOperations: + """PolicyAssignmentsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.policy.v2016_12_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def delete( + self, + scope: str, + policy_assignment_name: str, + **kwargs + ) -> "models.PolicyAssignment": + """Deletes a policy assignment. + + :param scope: The scope of the policy assignment. + :type scope: str + :param policy_assignment_name: The name of the policy assignment to delete. + :type policy_assignment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyAssignment or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {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 = { + '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'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('PolicyAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore + + async def create( + self, + scope: str, + policy_assignment_name: str, + parameters: "models.PolicyAssignment", + **kwargs + ) -> "models.PolicyAssignment": + """Policy assignments are inherited by child resources. For example, when you apply a policy to a resource group that policy is assigned to all resources in the group. + + Creates a policy assignment. + + :param scope: The scope of the policy assignment. + :type scope: str + :param policy_assignment_name: The name of the policy assignment. + :type policy_assignment_name: str + :param parameters: Parameters for the policy assignment. + :type parameters: ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyAssignment + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-12-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore + + async def get( + self, + scope: str, + policy_assignment_name: str, + **kwargs + ) -> "models.PolicyAssignment": + """Gets a policy assignment. + + :param scope: The scope of the policy assignment. + :type scope: str + :param policy_assignment_name: The name of the policy assignment to get. + :type policy_assignment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-12-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore + + def list_for_resource_group( + self, + resource_group_name: str, + filter: Optional[str] = None, + **kwargs + ) -> AsyncIterable["models.PolicyAssignmentListResult"]: + """Gets policy assignments for the resource group. + + :param resource_group_name: The name of the resource group that contains policy assignments. + :type resource_group_name: str + :param filter: The filter to apply on the operation. + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-12-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, 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 + + def list_for_resource( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + filter: Optional[str] = None, + **kwargs + ) -> AsyncIterable["models.PolicyAssignmentListResult"]: + """Gets policy assignments for a resource. + + :param resource_group_name: The name of the resource group containing the resource. The name is + case insensitive. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource path. + :type parent_resource_path: str + :param resource_type: The resource type. + :type resource_type: str + :param resource_name: The name of the resource with policy assignments. + :type resource_name: str + :param filter: The filter to apply on the operation. + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-12-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, 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 + + def list( + self, + filter: Optional[str] = None, + **kwargs + ) -> AsyncIterable["models.PolicyAssignmentListResult"]: + """Gets all the policy assignments for a subscription. + + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-12-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments'} # type: ignore + + async def delete_by_id( + self, + policy_assignment_id: str, + **kwargs + ) -> "models.PolicyAssignment": + """When providing a scope for the assignment, use '/subscriptions/{subscription-id}/' for subscriptions, '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for resource groups, and '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider-namespace}/{resource-type}/{resource-name}' for resources. + + Deletes a policy assignment by ID. + + :param policy_assignment_id: The ID of the policy assignment to delete. Use the format + '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policy-assignment-name}'. + :type policy_assignment_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-12-01" + + # 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'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + delete_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + + async def create_by_id( + self, + policy_assignment_id: str, + parameters: "models.PolicyAssignment", + **kwargs + ) -> "models.PolicyAssignment": + """Policy assignments are inherited by child resources. For example, when you apply a policy to a resource group that policy is assigned to all resources in the group. When providing a scope for the assignment, use '/subscriptions/{subscription-id}/' for subscriptions, '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for resource groups, and '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider-namespace}/{resource-type}/{resource-name}' for resources. + + Creates a policy assignment by ID. + + :param policy_assignment_id: The ID of the policy assignment to create. Use the format + '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policy-assignment-name}'. + :type policy_assignment_id: str + :param parameters: Parameters for policy assignment. + :type parameters: ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyAssignment + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-12-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + + async def get_by_id( + self, + policy_assignment_id: str, + **kwargs + ) -> "models.PolicyAssignment": + """When providing a scope for the assignment, use '/subscriptions/{subscription-id}/' for subscriptions, '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for resource groups, and '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider-namespace}/{resource-type}/{resource-name}' for resources. + + Gets a policy assignment by ID. + + :param policy_assignment_id: The ID of the policy assignment to get. Use the format + '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policy-assignment-name}'. + :type policy_assignment_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-12-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyAssignment', pipeline_response) + + if cls: + 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_async/_policy_definitions_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/aio/operations_async/_policy_definitions_operations_async.py new file mode 100644 index 000000000000..a73af3b7cfb9 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/aio/operations_async/_policy_definitions_operations_async.py @@ -0,0 +1,612 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import 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 ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class PolicyDefinitionsOperations: + """PolicyDefinitionsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.policy.v2016_12_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def create_or_update( + self, + policy_definition_name: str, + parameters: "models.PolicyDefinition", + **kwargs + ) -> "models.PolicyDefinition": + """Creates or updates a policy definition. + + :param policy_definition_name: The name of the policy definition to create. + :type policy_definition_name: str + :param parameters: The policy definition properties. + :type parameters: ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-12-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + async def delete( + self, + policy_definition_name: str, + **kwargs + ) -> None: + """Deletes a policy definition. + + :param policy_definition_name: The name of the policy definition to delete. + :type policy_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + async def get( + self, + policy_definition_name: str, + **kwargs + ) -> "models.PolicyDefinition": + """Gets the policy definition. + + :param policy_definition_name: The name of the policy definition to get. + :type policy_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-12-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + async def get_built_in( + self, + policy_definition_name: str, + **kwargs + ) -> "models.PolicyDefinition": + """Gets the built in policy definition. + + :param policy_definition_name: The name of the built in policy definition to get. + :type policy_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-12-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + async def create_or_update_at_management_group( + self, + policy_definition_name: str, + management_group_id: str, + parameters: "models.PolicyDefinition", + **kwargs + ) -> "models.PolicyDefinition": + """Creates or updates a policy definition at management group level. + + :param policy_definition_name: The name of the policy definition to create. + :type policy_definition_name: str + :param management_group_id: The ID of the management group. + :type management_group_id: str + :param parameters: The policy definition properties. + :type parameters: ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-12-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyDefinition', pipeline_response) + + if cls: + 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 + + async def delete_at_management_group( + self, + policy_definition_name: str, + management_group_id: str, + **kwargs + ) -> None: + """Deletes a policy definition at management group level. + + :param policy_definition_name: The name of the policy definition to delete. + :type policy_definition_name: str + :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: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + async def get_at_management_group( + self, + policy_definition_name: str, + management_group_id: str, + **kwargs + ) -> "models.PolicyDefinition": + """Gets the policy definition at management group level. + + :param policy_definition_name: The name of the policy definition to get. + :type policy_definition_name: str + :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: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-12-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyDefinition', pipeline_response) + + if cls: + 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 + + def list( + self, + **kwargs + ) -> AsyncIterable["models.PolicyDefinitionListResult"]: + """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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-12-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyDefinitionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions'} # type: ignore + + def list_built_in( + self, + **kwargs + ) -> AsyncIterable["models.PolicyDefinitionListResult"]: + """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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-12-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyDefinitionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policyDefinitions'} # type: ignore + + def list_by_management_group( + self, + management_group_id: str, + **kwargs + ) -> AsyncIterable["models.PolicyDefinitionListResult"]: + """Gets all the policy definitions for a subscription at management group level. + + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-12-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyDefinitionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/models/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/models/__init__.py index 838a18dd9f62..551ba376f7f8 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/models/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/models/__init__.py @@ -1,32 +1,32 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- try: from ._models_py3 import PolicyAssignment + from ._models_py3 import PolicyAssignmentListResult from ._models_py3 import PolicyDefinition + from ._models_py3 import PolicyDefinitionListResult except (SyntaxError, ImportError): - from ._models import PolicyAssignment - from ._models import PolicyDefinition -from ._paged_models import PolicyAssignmentPaged -from ._paged_models import PolicyDefinitionPaged + from ._models import PolicyAssignment # type: ignore + from ._models import PolicyAssignmentListResult # type: ignore + from ._models import PolicyDefinition # type: ignore + from ._models import PolicyDefinitionListResult # type: ignore + from ._policy_client_enums import ( - PolicyType, PolicyMode, + PolicyType, ) __all__ = [ 'PolicyAssignment', + 'PolicyAssignmentListResult', 'PolicyDefinition', - 'PolicyDefinitionPaged', - 'PolicyAssignmentPaged', - 'PolicyType', + 'PolicyDefinitionListResult', 'PolicyMode', + 'PolicyType', ] 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 10968d424ab4..9bec5b0edf12 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 @@ -1,31 +1,25 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.serialization import Model +import msrest.serialization -class CloudError(Model): - """CloudError. - """ - - _attribute_map = { - } - - -class PolicyAssignment(Model): +class PolicyAssignment(msrest.serialization.Model): """The policy assignment. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. + :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. @@ -34,15 +28,8 @@ class PolicyAssignment(Model): :type scope: str :param parameters: Required if a parameter is used in policy rule. :type parameters: object - :param description: This message will be part of response in case of - policy violation. + :param description: This message will be part of response in case of policy violation. :type description: str - :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 """ _validation = { @@ -50,44 +37,69 @@ class PolicyAssignment(Model): } _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, 'display_name': {'key': 'properties.displayName', 'type': 'str'}, 'policy_definition_id': {'key': 'properties.policyDefinitionId', 'type': 'str'}, 'scope': {'key': 'properties.scope', 'type': 'str'}, 'parameters': {'key': 'properties.parameters', 'type': 'object'}, 'description': {'key': 'properties.description', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(PolicyAssignment, self).__init__(**kwargs) + self.id = None + self.type = kwargs.get('type', None) + self.name = kwargs.get('name', None) self.display_name = kwargs.get('display_name', None) self.policy_definition_id = kwargs.get('policy_definition_id', None) self.scope = kwargs.get('scope', None) self.parameters = kwargs.get('parameters', None) self.description = kwargs.get('description', None) - self.id = None - self.type = kwargs.get('type', None) - self.name = kwargs.get('name', None) -class PolicyDefinition(Model): +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 + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[PolicyAssignment]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(PolicyAssignmentListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class PolicyDefinition(msrest.serialization.Model): """The policy definition. - Variables are only populated by the server, and will be ignored when - sending a request. - - :param 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. Possible values include: 'NotSpecified', 'Indexed', - 'All' - :type mode: str or - ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyMode + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The ID of the policy definition. + :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, + 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. + 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. @@ -98,10 +110,6 @@ class PolicyDefinition(Model): :type metadata: object :param parameters: Required if a parameter is used in policy rule. :type parameters: object - :ivar id: The ID of the policy definition. - :vartype id: str - :ivar name: The name of the policy definition. - :vartype name: str """ _validation = { @@ -110,6 +118,8 @@ class PolicyDefinition(Model): } _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, 'policy_type': {'key': 'properties.policyType', 'type': 'str'}, 'mode': {'key': 'properties.mode', 'type': 'str'}, 'display_name': {'key': 'properties.displayName', 'type': 'str'}, @@ -117,12 +127,15 @@ class PolicyDefinition(Model): 'policy_rule': {'key': 'properties.policyRule', 'type': 'object'}, 'metadata': {'key': 'properties.metadata', 'type': 'object'}, 'parameters': {'key': 'properties.parameters', 'type': 'object'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(PolicyDefinition, self).__init__(**kwargs) + self.id = None + self.name = None self.policy_type = kwargs.get('policy_type', None) self.mode = kwargs.get('mode', None) self.display_name = kwargs.get('display_name', None) @@ -130,5 +143,26 @@ def __init__(self, **kwargs): self.policy_rule = kwargs.get('policy_rule', None) self.metadata = kwargs.get('metadata', None) self.parameters = kwargs.get('parameters', None) - self.id = None - self.name = None + + +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 + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[PolicyDefinition]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + 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 bac7a3c437ab..5f9d7c3f41a5 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 @@ -1,31 +1,29 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.serialization import Model +from typing import List, Optional, Union +import msrest.serialization -class CloudError(Model): - """CloudError. - """ - - _attribute_map = { - } +from ._policy_client_enums import * -class PolicyAssignment(Model): +class PolicyAssignment(msrest.serialization.Model): """The policy assignment. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. + :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. @@ -34,15 +32,8 @@ class PolicyAssignment(Model): :type scope: str :param parameters: Required if a parameter is used in policy rule. :type parameters: object - :param description: This message will be part of response in case of - policy violation. + :param description: This message will be part of response in case of policy violation. :type description: str - :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 """ _validation = { @@ -50,44 +41,80 @@ class PolicyAssignment(Model): } _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, 'display_name': {'key': 'properties.displayName', 'type': 'str'}, 'policy_definition_id': {'key': 'properties.policyDefinitionId', 'type': 'str'}, 'scope': {'key': 'properties.scope', 'type': 'str'}, 'parameters': {'key': 'properties.parameters', 'type': 'object'}, 'description': {'key': 'properties.description', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, } - def __init__(self, *, display_name: str=None, policy_definition_id: str=None, scope: str=None, parameters=None, description: str=None, type: str=None, name: str=None, **kwargs) -> None: + def __init__( + self, + *, + type: Optional[str] = None, + name: Optional[str] = None, + display_name: Optional[str] = None, + policy_definition_id: Optional[str] = None, + scope: Optional[str] = None, + parameters: Optional[object] = None, + description: Optional[str] = None, + **kwargs + ): super(PolicyAssignment, self).__init__(**kwargs) + self.id = None + self.type = type + self.name = name self.display_name = display_name self.policy_definition_id = policy_definition_id self.scope = scope self.parameters = parameters self.description = description - self.id = None - self.type = type - self.name = name -class PolicyDefinition(Model): +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 + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[PolicyAssignment]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["PolicyAssignment"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(PolicyAssignmentListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class PolicyDefinition(msrest.serialization.Model): """The policy definition. - Variables are only populated by the server, and will be ignored when - sending a request. - - :param 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. Possible values include: 'NotSpecified', 'Indexed', - 'All' - :type mode: str or - ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyMode + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The ID of the policy definition. + :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, + 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. + 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. @@ -98,10 +125,6 @@ class PolicyDefinition(Model): :type metadata: object :param parameters: Required if a parameter is used in policy rule. :type parameters: object - :ivar id: The ID of the policy definition. - :vartype id: str - :ivar name: The name of the policy definition. - :vartype name: str """ _validation = { @@ -110,6 +133,8 @@ class PolicyDefinition(Model): } _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, 'policy_type': {'key': 'properties.policyType', 'type': 'str'}, 'mode': {'key': 'properties.mode', 'type': 'str'}, 'display_name': {'key': 'properties.displayName', 'type': 'str'}, @@ -117,12 +142,23 @@ class PolicyDefinition(Model): 'policy_rule': {'key': 'properties.policyRule', 'type': 'object'}, 'metadata': {'key': 'properties.metadata', 'type': 'object'}, 'parameters': {'key': 'properties.parameters', 'type': 'object'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, } - def __init__(self, *, policy_type=None, mode=None, display_name: str=None, description: str=None, policy_rule=None, metadata=None, parameters=None, **kwargs) -> None: + def __init__( + self, + *, + policy_type: Optional[Union[str, "PolicyType"]] = None, + mode: Optional[Union[str, "PolicyMode"]] = None, + display_name: Optional[str] = None, + description: Optional[str] = None, + policy_rule: Optional[object] = None, + metadata: Optional[object] = None, + parameters: Optional[object] = None, + **kwargs + ): super(PolicyDefinition, self).__init__(**kwargs) + self.id = None + self.name = None self.policy_type = policy_type self.mode = mode self.display_name = display_name @@ -130,5 +166,29 @@ def __init__(self, *, policy_type=None, mode=None, display_name: str=None, descr self.policy_rule = policy_rule self.metadata = metadata self.parameters = parameters - self.id = None - self.name = None + + +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 + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[PolicyDefinition]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["PolicyDefinition"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + 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/_paged_models.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/models/_paged_models.py deleted file mode 100644 index d5b970ba2abe..000000000000 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/models/_paged_models.py +++ /dev/null @@ -1,40 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.paging import Paged - - -class PolicyDefinitionPaged(Paged): - """ - A paging container for iterating over a list of :class:`PolicyDefinition ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[PolicyDefinition]'} - } - - def __init__(self, *args, **kwargs): - - super(PolicyDefinitionPaged, self).__init__(*args, **kwargs) -class PolicyAssignmentPaged(Paged): - """ - A paging container for iterating over a list of :class:`PolicyAssignment ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[PolicyAssignment]'} - } - - def __init__(self, *args, **kwargs): - - super(PolicyAssignmentPaged, self).__init__(*args, **kwargs) 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 a9dcf44c1e7c..65c6d02a7e1c 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 @@ -1,26 +1,25 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from enum import Enum +class PolicyMode(str, Enum): + """The policy definition mode. Possible values are NotSpecified, Indexed, and All. + """ + + not_specified = "NotSpecified" + indexed = "Indexed" + all = "All" class PolicyType(str, Enum): + """The type of policy definition. Possible values are NotSpecified, BuiltIn, and Custom. + """ not_specified = "NotSpecified" built_in = "BuiltIn" custom = "Custom" - - -class PolicyMode(str, Enum): - - not_specified = "NotSpecified" - indexed = "Indexed" - all = "All" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/operations/__init__.py index f2da9f519a58..fb00eaa9760d 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/operations/__init__.py @@ -1,12 +1,9 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from ._policy_definitions_operations import PolicyDefinitionsOperations 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 31db8aee95ed..49ecff8408de 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 @@ -1,678 +1,633 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class PolicyAssignmentsOperations(object): """PolicyAssignmentsOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.policy.v2016_12_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for the operation. Constant value: "2016-12-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2016-12-01" - - self.config = config + self._config = config def delete( - self, scope, policy_assignment_name, custom_headers=None, raw=False, **operation_config): + self, + scope, # type: str + policy_assignment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyAssignment" """Deletes a policy assignment. :param scope: The scope of the policy assignment. :type scope: str - :param policy_assignment_name: The name of the policy assignment to - delete. + :param policy_assignment_name: The name of the policy assignment to delete. :type policy_assignment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyAssignment or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyAssignment or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyAssignment or None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-12-01" + # Construct URL - url = self.delete.metadata['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') + 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('PolicyAssignment', response) + deserialized = self._deserialize('PolicyAssignment', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} + delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore def create( - self, scope, policy_assignment_name, parameters, custom_headers=None, raw=False, **operation_config): - """Creates a policy assignment. + self, + scope, # type: str + policy_assignment_name, # type: str + parameters, # type: "models.PolicyAssignment" + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyAssignment" + """Policy assignments are inherited by child resources. For example, when you apply a policy to a resource group that policy is assigned to all resources in the group. - Policy assignments are inherited by child resources. For example, when - you apply a policy to a resource group that policy is assigned to all - resources in the group. + Creates a policy assignment. :param scope: The scope of the policy assignment. :type scope: str :param policy_assignment_name: The name of the policy assignment. :type policy_assignment_name: str :param parameters: Parameters for the policy assignment. - :type parameters: - ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyAssignment - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyAssignment or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyAssignment or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :type parameters: ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyAssignment + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-12-01" + content_type = kwargs.pop("content_type", "application/json") + # Construct URL - url = self.create.metadata['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') + 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'PolicyAssignment') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 201: - deserialized = self._deserialize('PolicyAssignment', response) + deserialized = self._deserialize('PolicyAssignment', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} + create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore def get( - self, scope, policy_assignment_name, custom_headers=None, raw=False, **operation_config): + self, + scope, # type: str + policy_assignment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyAssignment" """Gets a policy assignment. :param scope: The scope of the policy assignment. :type scope: str - :param policy_assignment_name: The name of the policy assignment to - get. + :param policy_assignment_name: The name of the policy assignment to get. :type policy_assignment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyAssignment or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyAssignment or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-12-01" + # Construct URL - url = self.get.metadata['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') + 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('PolicyAssignment', response) + deserialized = self._deserialize('PolicyAssignment', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} + get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore def list_for_resource_group( - self, resource_group_name, filter=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + filter=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.PolicyAssignmentListResult"] """Gets policy assignments for the resource group. - :param resource_group_name: The name of the resource group that - contains policy assignments. + :param resource_group_name: The name of the resource group that contains policy assignments. :type resource_group_name: str :param filter: The filter to apply on the operation. :type filter: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of PolicyAssignment - :rtype: - ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyAssignmentPaged[~azure.mgmt.resource.policy.v2016_12_01.models.PolicyAssignment] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-12-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_for_resource_group.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.PolicyAssignmentPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list_for_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments'} + return ItemPaged( + get_next, extract_data + ) + list_for_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments'} # type: ignore def list_for_resource( - self, resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, filter=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + filter=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.PolicyAssignmentListResult"] """Gets policy assignments for a resource. - :param resource_group_name: The name of the resource group containing - the resource. The name is case insensitive. + :param resource_group_name: The name of the resource group containing the resource. The name is + case insensitive. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource - provider. + :param resource_provider_namespace: The namespace of the resource provider. :type resource_provider_namespace: str :param parent_resource_path: The parent resource path. :type parent_resource_path: str :param resource_type: The resource type. :type resource_type: str - :param resource_name: The name of the resource with policy - assignments. + :param resource_name: The name of the resource with policy assignments. :type resource_name: str :param filter: The filter to apply on the operation. :type filter: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of PolicyAssignment - :rtype: - ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyAssignmentPaged[~azure.mgmt.resource.policy.v2016_12_01.models.PolicyAssignment] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-12-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_for_resource.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.PolicyAssignmentPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list_for_resource.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments'} + 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 def list( - self, filter=None, custom_headers=None, raw=False, **operation_config): + self, + filter=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.PolicyAssignmentListResult"] """Gets all the policy assignments for a subscription. :param filter: The filter to apply on the operation. :type filter: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of PolicyAssignment - :rtype: - ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyAssignmentPaged[~azure.mgmt.resource.policy.v2016_12_01.models.PolicyAssignment] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-12-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['url'] + url = self.list.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_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 = {} + 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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.PolicyAssignmentPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments'} # type: ignore def delete_by_id( - self, policy_assignment_id, custom_headers=None, raw=False, **operation_config): - """Deletes a policy assignment by ID. - - When providing a scope for the assignment, use - '/subscriptions/{subscription-id}/' for subscriptions, - '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' - for resource groups, and - '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider-namespace}/{resource-type}/{resource-name}' - for resources. - - :param policy_assignment_id: The ID of the policy assignment to - delete. Use the format + self, + policy_assignment_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyAssignment" + """When providing a scope for the assignment, use '/subscriptions/{subscription-id}/' for subscriptions, '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for resource groups, and '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider-namespace}/{resource-type}/{resource-name}' for resources. + + Deletes a policy assignment by ID. + + :param policy_assignment_id: The ID of the policy assignment to delete. Use the format '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policy-assignment-name}'. :type policy_assignment_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyAssignment or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyAssignment or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-12-01" + # Construct URL - url = self.delete_by_id.metadata['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) + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('PolicyAssignment', response) + deserialized = self._deserialize('PolicyAssignment', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - delete_by_id.metadata = {'url': '/{policyAssignmentId}'} + delete_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore def create_by_id( - self, policy_assignment_id, parameters, custom_headers=None, raw=False, **operation_config): - """Creates a policy assignment by ID. - - Policy assignments are inherited by child resources. For example, when - you apply a policy to a resource group that policy is assigned to all - resources in the group. When providing a scope for the assignment, use - '/subscriptions/{subscription-id}/' for subscriptions, - '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' - for resource groups, and - '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider-namespace}/{resource-type}/{resource-name}' - for resources. - - :param policy_assignment_id: The ID of the policy assignment to - create. Use the format + self, + policy_assignment_id, # type: str + parameters, # type: "models.PolicyAssignment" + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyAssignment" + """Policy assignments are inherited by child resources. For example, when you apply a policy to a resource group that policy is assigned to all resources in the group. When providing a scope for the assignment, use '/subscriptions/{subscription-id}/' for subscriptions, '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for resource groups, and '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider-namespace}/{resource-type}/{resource-name}' for resources. + + Creates a policy assignment by ID. + + :param policy_assignment_id: The ID of the policy assignment to create. Use the format '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policy-assignment-name}'. :type policy_assignment_id: str :param parameters: Parameters for policy assignment. - :type parameters: - ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyAssignment - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyAssignment or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyAssignment or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :type parameters: ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyAssignment + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-12-01" + content_type = kwargs.pop("content_type", "application/json") + # Construct URL - url = self.create_by_id.metadata['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) + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'PolicyAssignment') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 201: - deserialized = self._deserialize('PolicyAssignment', response) + deserialized = self._deserialize('PolicyAssignment', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create_by_id.metadata = {'url': '/{policyAssignmentId}'} + create_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore def get_by_id( - self, policy_assignment_id, custom_headers=None, raw=False, **operation_config): - """Gets a policy assignment by ID. - - When providing a scope for the assignment, use - '/subscriptions/{subscription-id}/' for subscriptions, - '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' - for resource groups, and - '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider-namespace}/{resource-type}/{resource-name}' - for resources. - - :param policy_assignment_id: The ID of the policy assignment to get. - Use the format + self, + policy_assignment_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyAssignment" + """When providing a scope for the assignment, use '/subscriptions/{subscription-id}/' for subscriptions, '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for resource groups, and '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider-namespace}/{resource-type}/{resource-name}' for resources. + + Gets a policy assignment by ID. + + :param policy_assignment_id: The ID of the policy assignment to get. Use the format '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policy-assignment-name}'. :type policy_assignment_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyAssignment or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyAssignment or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-12-01" + # Construct URL - url = self.get_by_id.metadata['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) + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('PolicyAssignment', response) + deserialized = self._deserialize('PolicyAssignment', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/{policyAssignmentId}'} + 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 ed33ad2ccbb7..3f838daea3bf 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 @@ -1,658 +1,626 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class PolicyDefinitionsOperations(object): """PolicyDefinitionsOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.policy.v2016_12_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for the operation. Constant value: "2016-12-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2016-12-01" - - self.config = config + self._config = config def create_or_update( - self, policy_definition_name, parameters, custom_headers=None, raw=False, **operation_config): + self, + policy_definition_name, # type: str + parameters, # type: "models.PolicyDefinition" + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyDefinition" """Creates or updates a policy definition. - :param policy_definition_name: The name of the policy definition to - create. + :param policy_definition_name: The name of the policy definition to create. :type policy_definition_name: str :param parameters: The policy definition properties. - :type parameters: - ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyDefinition - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyDefinition or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyDefinition or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :type parameters: ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyDefinition + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-12-01" + content_type = kwargs.pop("content_type", "application/json") + # Construct URL - url = self.create_or_update.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'PolicyDefinition') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [201]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 201: - deserialized = self._deserialize('PolicyDefinition', response) + deserialized = self._deserialize('PolicyDefinition', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore def delete( - self, policy_definition_name, custom_headers=None, raw=False, **operation_config): + self, + policy_definition_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Deletes a policy definition. - :param policy_definition_name: The name of the policy definition to - delete. + :param policy_definition_name: The name of the policy definition to delete. :type policy_definition_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-12-01" + # Construct URL - url = self.delete.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore def get( - self, policy_definition_name, custom_headers=None, raw=False, **operation_config): + self, + policy_definition_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyDefinition" """Gets the policy definition. - :param policy_definition_name: The name of the policy definition to - get. + :param policy_definition_name: The name of the policy definition to get. :type policy_definition_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyDefinition or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyDefinition or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyDefinition + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-12-01" + # Construct URL - url = self.get.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('PolicyDefinition', response) + deserialized = self._deserialize('PolicyDefinition', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore def get_built_in( - self, policy_definition_name, custom_headers=None, raw=False, **operation_config): + self, + policy_definition_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyDefinition" """Gets the built in policy definition. - :param policy_definition_name: The name of the built in policy - definition to get. + :param policy_definition_name: The name of the built in policy definition to get. :type policy_definition_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyDefinition or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyDefinition or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyDefinition + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-12-01" + # Construct URL - url = self.get_built_in.metadata['url'] + url = self.get_built_in.metadata['url'] # type: ignore path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str') + 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('PolicyDefinition', response) + deserialized = self._deserialize('PolicyDefinition', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} + get_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore def create_or_update_at_management_group( - self, policy_definition_name, parameters, management_group_id, custom_headers=None, raw=False, **operation_config): + self, + policy_definition_name, # type: str + management_group_id, # type: str + parameters, # type: "models.PolicyDefinition" + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyDefinition" """Creates or updates a policy definition at management group level. - :param policy_definition_name: The name of the policy definition to - create. + :param policy_definition_name: The name of the policy definition to create. :type policy_definition_name: str - :param parameters: The policy definition properties. - :type parameters: - ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyDefinition :param management_group_id: The ID of the management group. :type management_group_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyDefinition or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyDefinition or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :param parameters: The policy definition properties. + :type parameters: ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyDefinition + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-12-01" + content_type = kwargs.pop("content_type", "application/json") + # Construct URL - url = self.create_or_update_at_management_group.metadata['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') + 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'PolicyDefinition') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [201]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 201: - deserialized = self._deserialize('PolicyDefinition', response) + deserialized = self._deserialize('PolicyDefinition', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + 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}'} + create_or_update_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore def delete_at_management_group( - self, policy_definition_name, management_group_id, custom_headers=None, raw=False, **operation_config): + self, + policy_definition_name, # type: str + management_group_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Deletes a policy definition at management group level. - :param policy_definition_name: The name of the policy definition to - delete. + :param policy_definition_name: The name of the policy definition to delete. :type policy_definition_name: str :param management_group_id: The ID of the management group. :type management_group_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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'] + 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') + 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} + delete_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore def get_at_management_group( - self, policy_definition_name, management_group_id, custom_headers=None, raw=False, **operation_config): + self, + policy_definition_name, # type: str + management_group_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyDefinition" """Gets the policy definition at management group level. - :param policy_definition_name: The name of the policy definition to - get. + :param policy_definition_name: The name of the policy definition to get. :type policy_definition_name: str :param management_group_id: The ID of the management group. :type management_group_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyDefinition or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyDefinition or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyDefinition + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-12-01" + # Construct URL - url = self.get_at_management_group.metadata['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') + 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('PolicyDefinition', response) + deserialized = self._deserialize('PolicyDefinition', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} + get_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore def list( - self, custom_headers=None, raw=False, **operation_config): + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.PolicyDefinitionListResult"] """Gets all the policy definitions for a subscription. - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of PolicyDefinition - :rtype: - ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyDefinitionPaged[~azure.mgmt.resource.policy.v2016_12_01.models.PolicyDefinition] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-12-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['url'] + url = self.list.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyDefinitionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.PolicyDefinitionPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions'} # type: ignore def list_built_in( - self, custom_headers=None, raw=False, **operation_config): + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.PolicyDefinitionListResult"] """Gets all the built in policy definitions. - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of PolicyDefinition - :rtype: - ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyDefinitionPaged[~azure.mgmt.resource.policy.v2016_12_01.models.PolicyDefinition] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-12-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_built_in.metadata['url'] - + url = self.list_built_in.metadata['url'] # type: ignore # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyDefinitionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.PolicyDefinitionPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policyDefinitions'} + return ItemPaged( + get_next, extract_data + ) + list_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policyDefinitions'} # type: ignore def list_by_management_group( - self, management_group_id, custom_headers=None, raw=False, **operation_config): - """Gets all the policy definitions for a subscription at management group - level. + self, + management_group_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.PolicyDefinitionListResult"] + """Gets all the policy definitions for a subscription at management group level. :param management_group_id: The ID of the management group. :type management_group_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of PolicyDefinition - :rtype: - ~azure.mgmt.resource.policy.v2016_12_01.models.PolicyDefinitionPaged[~azure.mgmt.resource.policy.v2016_12_01.models.PolicyDefinition] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-12-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_by_management_group.metadata['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') + 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyDefinitionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.PolicyDefinitionPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_by_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions'} + return ItemPaged( + get_next, extract_data + ) + list_by_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/py.typed b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file 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 deleted file mode 100644 index eb083cbe85ea..000000000000 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_12_01/version.py +++ /dev/null @@ -1,13 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -VERSION = "2016-12-01" - 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 56bf47bfb9e4..e4bba9352a5c 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 @@ -1,19 +1,16 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._configuration import PolicyClientConfiguration from ._policy_client import PolicyClient -__all__ = ['PolicyClient', 'PolicyClientConfiguration'] - -from .version import VERSION - -__version__ = VERSION +__all__ = ['PolicyClient'] +try: + from ._patch import patch_sdk + patch_sdk() +except ImportError: + pass 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 ede4f42045d0..ceb0e31efe41 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 @@ -1,48 +1,68 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrestazure import AzureConfiguration -from .version import VERSION +from typing import TYPE_CHECKING +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + + from azure.core.credentials import TokenCredential + +VERSION = "unknown" + +class PolicyClientConfiguration(Configuration): + """Configuration for PolicyClient. -class PolicyClientConfiguration(AzureConfiguration): - """Configuration for PolicyClient Note that all parameters used to create this instance are saved as instance attributes. - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` + :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 """ def __init__( - self, credentials, subscription_id, base_url=None): - - if credentials is None: - raise ValueError("Parameter 'credentials' must not be None.") + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + 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.") - if not base_url: - base_url = 'https://management.azure.com' + super(PolicyClientConfiguration, self).__init__(**kwargs) - super(PolicyClientConfiguration, self).__init__(base_url) - - # Starting Autorest.Python 4.0.64, make connection pool activated by default - self.keep_alive = True - - self.add_user_agent('azure-mgmt-resource/{}'.format(VERSION)) - self.add_user_agent('Azure-SDK-For-Python') - - self.credentials = credentials + self.credential = credential self.subscription_id = subscription_id + self.credential_scopes = ['https://management.azure.com/.default'] + self.credential_scopes.extend(kwargs.pop('credential_scopes', [])) + kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + 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) 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 new file mode 100644 index 000000000000..dcffd39a27ca --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/_metadata.json @@ -0,0 +1,55 @@ +{ + "chosen_version": "2017-06-01-preview", + "total_api_version_list": ["2016-12-01", "2017-06-01-preview"], + "client": { + "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." + }, + "global_parameters": { + "sync_method": { + "credential": { + "method_signature": "credential, # type: \"TokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials.TokenCredential", + "required": true + }, + "subscription_id": { + "method_signature": "subscription_id, # type: str", + "description": "The ID of the target subscription.", + "docstring_type": "str", + "required": true + } + }, + "async_method": { + "credential": { + "method_signature": "credential, # type: \"AsyncTokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + }, + "subscription_id": { + "method_signature": "subscription_id, # type: str", + "description": "The ID of the target subscription.", + "docstring_type": "str", + "required": true + } + }, + "constant": { + }, + "call": "credential, subscription_id" + }, + "config": { + "credential": true, + "credential_scopes": ["https://management.azure.com/.default"] + }, + "operation_groups": { + "policy_assignments": "PolicyAssignmentsOperations", + "policy_set_definitions": "PolicySetDefinitionsOperations", + "policy_definitions": "PolicyDefinitionsOperations" + }, + "operation_mixins": { + }, + "sync_imports": "None", + "async_imports": "None" +} \ 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 9a00705a2b01..14787153cf2e 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 @@ -1,16 +1,19 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.service_client import SDKClient -from msrest import Serializer, Deserializer +from typing import TYPE_CHECKING + +from azure.mgmt.core import ARMPipelineClient +from msrest import Deserializer, Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional from ._configuration import PolicyClientConfiguration from .operations import PolicyAssignmentsOperations @@ -19,40 +22,56 @@ from . import models -class PolicyClient(SDKClient): +class PolicyClient(object): """To manage and control access to your resources, you can define customized policies and assign them at a scope. - :ivar config: Configuration for client. - :vartype config: PolicyClientConfiguration - - :ivar policy_assignments: PolicyAssignments operations + :ivar policy_assignments: PolicyAssignmentsOperations operations :vartype policy_assignments: azure.mgmt.resource.policy.v2017_06_01_preview.operations.PolicyAssignmentsOperations - :ivar policy_set_definitions: PolicySetDefinitions operations + :ivar policy_set_definitions: PolicySetDefinitionsOperations operations :vartype policy_set_definitions: azure.mgmt.resource.policy.v2017_06_01_preview.operations.PolicySetDefinitionsOperations - :ivar policy_definitions: PolicyDefinitions operations + :ivar policy_definitions: PolicyDefinitionsOperations operations :vartype policy_definitions: azure.mgmt.resource.policy.v2017_06_01_preview.operations.PolicyDefinitionsOperations - - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` + :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. """ def __init__( - self, credentials, subscription_id, base_url=None): - - self.config = PolicyClientConfiguration(credentials, subscription_id, base_url) - super(PolicyClient, self).__init__(self.config.credentials, self.config) + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = 'https://management.azure.com' + self._config = PolicyClientConfiguration(credential, subscription_id, **kwargs) + self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self.policy_assignments = PolicyAssignmentsOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.policy_set_definitions = PolicySetDefinitionsOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.policy_definitions = PolicyDefinitionsOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> PolicyClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) 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/policy/v2017_06_01_preview/aio/__init__.py similarity index 76% rename from sdk/resources/azure-mgmt-resource/azure/mgmt/resource/features/v2015_12_01/version.py rename to sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/aio/__init__.py index 1a7a157bd34d..df3c0beab48a 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/policy/v2017_06_01_preview/aio/__init__.py @@ -1,13 +1,10 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2015-12-01" - +from ._policy_client_async import PolicyClient +__all__ = ['PolicyClient'] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/aio/_configuration_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/aio/_configuration_async.py new file mode 100644 index 000000000000..0ab7453a1735 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/aio/_configuration_async.py @@ -0,0 +1,64 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + +VERSION = "unknown" + +class PolicyClientConfiguration(Configuration): + """Configuration for PolicyClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :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 + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + 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 + self.credential_scopes = ['https://management.azure.com/.default'] + self.credential_scopes.extend(kwargs.pop('credential_scopes', [])) + kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs: Any + ) -> None: + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + 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) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/aio/_policy_client_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/aio/_policy_client_async.py new file mode 100644 index 000000000000..b2d3ae9ccfe3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/aio/_policy_client_async.py @@ -0,0 +1,69 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, Optional + +from azure.mgmt.core import AsyncARMPipelineClient +from msrest import Deserializer, Serializer + +from ._configuration_async import PolicyClientConfiguration +from .operations_async import PolicyAssignmentsOperations +from .operations_async import PolicySetDefinitionsOperations +from .operations_async import PolicyDefinitionsOperations +from .. import models + + +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.aio.operations_async.PolicyAssignmentsOperations + :ivar policy_set_definitions: PolicySetDefinitionsOperations operations + :vartype policy_set_definitions: azure.mgmt.resource.policy.v2017_06_01_preview.aio.operations_async.PolicySetDefinitionsOperations + :ivar policy_definitions: PolicyDefinitionsOperations operations + :vartype policy_definitions: azure.mgmt.resource.policy.v2017_06_01_preview.aio.operations_async.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 + :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, + **kwargs: 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) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + + self.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 close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "PolicyClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/aio/operations_async/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/aio/operations_async/__init__.py new file mode 100644 index 000000000000..106c925f6e56 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/aio/operations_async/__init__.py @@ -0,0 +1,17 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._policy_assignments_operations_async import PolicyAssignmentsOperations +from ._policy_set_definitions_operations_async import PolicySetDefinitionsOperations +from ._policy_definitions_operations_async import PolicyDefinitionsOperations + +__all__ = [ + 'PolicyAssignmentsOperations', + 'PolicySetDefinitionsOperations', + 'PolicyDefinitionsOperations', +] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/aio/operations_async/_policy_assignments_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/aio/operations_async/_policy_assignments_operations_async.py new file mode 100644 index 000000000000..cb9490bc48f7 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/aio/operations_async/_policy_assignments_operations_async.py @@ -0,0 +1,629 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import 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 ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class PolicyAssignmentsOperations: + """PolicyAssignmentsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.policy.v2017_06_01_preview.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def delete( + self, + scope: str, + policy_assignment_name: str, + **kwargs + ) -> "models.PolicyAssignment": + """Deletes a policy assignment. + + :param scope: The scope of the policy assignment. + :type scope: str + :param policy_assignment_name: The name of the policy assignment to delete. + :type policy_assignment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignment or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-06-01-preview" + + # 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'] = 'application/json' + + # Construct and send request + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('PolicyAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore + + async def create( + self, + scope: str, + policy_assignment_name: str, + parameters: "models.PolicyAssignment", + **kwargs + ) -> "models.PolicyAssignment": + """Policy assignments are inherited by child resources. For example, when you apply a policy to a resource group that policy is assigned to all resources in the group. + + Creates a policy assignment. + + :param scope: The scope of the policy assignment. + :type scope: str + :param policy_assignment_name: The name of the policy assignment. + :type policy_assignment_name: str + :param parameters: Parameters for the policy assignment. + :type parameters: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignment + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {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") + + # 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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore + + async def get( + self, + scope: str, + policy_assignment_name: str, + **kwargs + ) -> "models.PolicyAssignment": + """Gets a policy assignment. + + :param scope: The scope of the policy assignment. + :type scope: str + :param policy_assignment_name: The name of the policy assignment to get. + :type policy_assignment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-06-01-preview" + + # 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'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore + + def list_for_resource_group( + self, + resource_group_name: str, + filter: Optional[str] = None, + **kwargs + ) -> AsyncIterable["models.PolicyAssignmentListResult"]: + """Gets policy assignments for the resource group. + + :param resource_group_name: The name of the resource group that contains policy assignments. + :type resource_group_name: str + :param filter: The filter to apply on the operation. + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-06-01-preview" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + 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 + + def list_for_resource( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + filter: Optional[str] = None, + **kwargs + ) -> AsyncIterable["models.PolicyAssignmentListResult"]: + """Gets policy assignments for a resource. + + :param resource_group_name: The name of the resource group containing the resource. The name is + case insensitive. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource path. + :type parent_resource_path: str + :param resource_type: The resource type. + :type resource_type: str + :param resource_name: The name of the resource with policy assignments. + :type resource_name: str + :param filter: The filter to apply on the operation. + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-06-01-preview" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + 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 + + def list( + self, + filter: Optional[str] = None, + **kwargs + ) -> AsyncIterable["models.PolicyAssignmentListResult"]: + """Gets all the policy assignments for a subscription. + + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-06-01-preview" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + 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 + + async def delete_by_id( + self, + policy_assignment_id: str, + **kwargs + ) -> "models.PolicyAssignment": + """When providing a scope for the assignment, use '/subscriptions/{subscription-id}/' for subscriptions, '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for resource groups, and '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider-namespace}/{resource-type}/{resource-name}' for resources. + + Deletes a policy assignment by ID. + + :param policy_assignment_id: The ID of the policy assignment to delete. Use the format + '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policy-assignment-name}'. + :type policy_assignment_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-06-01-preview" + + # 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'] = 'application/json' + + # Construct and send request + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + delete_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + + async def create_by_id( + self, + policy_assignment_id: str, + parameters: "models.PolicyAssignment", + **kwargs + ) -> "models.PolicyAssignment": + """Policy assignments are inherited by child resources. For example, when you apply a policy to a resource group that policy is assigned to all resources in the group. When providing a scope for the assignment, use '/subscriptions/{subscription-id}/' for subscriptions, '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for resource groups, and '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider-namespace}/{resource-type}/{resource-name}' for resources. + + Creates a policy assignment by ID. + + :param policy_assignment_id: The ID of the policy assignment to create. Use the format + '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policy-assignment-name}'. + :type policy_assignment_id: str + :param parameters: Parameters for policy assignment. + :type parameters: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignment + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {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") + + # 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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + + async def get_by_id( + self, + policy_assignment_id: str, + **kwargs + ) -> "models.PolicyAssignment": + """When providing a scope for the assignment, use '/subscriptions/{subscription-id}/' for subscriptions, '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for resource groups, and '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider-namespace}/{resource-type}/{resource-name}' for resources. + + Gets a policy assignment by ID. + + :param policy_assignment_id: The ID of the policy assignment to get. Use the format + '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policy-assignment-name}'. + :type policy_assignment_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-06-01-preview" + + # 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'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyAssignment', pipeline_response) + + if cls: + 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_async/_policy_definitions_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/aio/operations_async/_policy_definitions_operations_async.py new file mode 100644 index 000000000000..ff15453d62cf --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/aio/operations_async/_policy_definitions_operations_async.py @@ -0,0 +1,612 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import 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 ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class PolicyDefinitionsOperations: + """PolicyDefinitionsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.policy.v2017_06_01_preview.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def create_or_update( + self, + policy_definition_name: str, + parameters: "models.PolicyDefinition", + **kwargs + ) -> "models.PolicyDefinition": + """Creates or updates a policy definition. + + :param policy_definition_name: The name of the policy definition to create. + :type policy_definition_name: str + :param parameters: The policy definition properties. + :type parameters: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-12-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + async def delete( + self, + policy_definition_name: str, + **kwargs + ) -> None: + """Deletes a policy definition. + + :param policy_definition_name: The name of the policy definition to delete. + :type policy_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + async def get( + self, + policy_definition_name: str, + **kwargs + ) -> "models.PolicyDefinition": + """Gets the policy definition. + + :param policy_definition_name: The name of the policy definition to get. + :type policy_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-12-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + async def get_built_in( + self, + policy_definition_name: str, + **kwargs + ) -> "models.PolicyDefinition": + """Gets the built in policy definition. + + :param policy_definition_name: The name of the built in policy definition to get. + :type policy_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-12-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + async def create_or_update_at_management_group( + self, + policy_definition_name: str, + management_group_id: str, + parameters: "models.PolicyDefinition", + **kwargs + ) -> "models.PolicyDefinition": + """Creates or updates a policy definition at management group level. + + :param policy_definition_name: The name of the policy definition to create. + :type policy_definition_name: str + :param management_group_id: The ID of the management group. + :type management_group_id: str + :param parameters: The policy definition properties. + :type parameters: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-12-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyDefinition', pipeline_response) + + if cls: + 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 + + async def delete_at_management_group( + self, + policy_definition_name: str, + management_group_id: str, + **kwargs + ) -> None: + """Deletes a policy definition at management group level. + + :param policy_definition_name: The name of the policy definition to delete. + :type policy_definition_name: str + :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: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + async def get_at_management_group( + self, + policy_definition_name: str, + management_group_id: str, + **kwargs + ) -> "models.PolicyDefinition": + """Gets the policy definition at management group level. + + :param policy_definition_name: The name of the policy definition to get. + :type policy_definition_name: str + :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: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-12-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyDefinition', pipeline_response) + + if cls: + 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 + + def list( + self, + **kwargs + ) -> AsyncIterable["models.PolicyDefinitionListResult"]: + """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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-12-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyDefinitionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions'} # type: ignore + + def list_built_in( + self, + **kwargs + ) -> AsyncIterable["models.PolicyDefinitionListResult"]: + """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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-12-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyDefinitionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policyDefinitions'} # type: ignore + + def list_by_management_group( + self, + management_group_id: str, + **kwargs + ) -> AsyncIterable["models.PolicyDefinitionListResult"]: + """Gets all the policy definitions for a subscription at management group level. + + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-12-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyDefinitionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/aio/operations_async/_policy_set_definitions_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/aio/operations_async/_policy_set_definitions_operations_async.py new file mode 100644 index 000000000000..b69420708104 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/aio/operations_async/_policy_set_definitions_operations_async.py @@ -0,0 +1,632 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import 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 ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class PolicySetDefinitionsOperations: + """PolicySetDefinitionsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.policy.v2017_06_01_preview.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def create_or_update( + self, + policy_set_definition_name: str, + parameters: "models.PolicySetDefinition", + **kwargs + ) -> "models.PolicySetDefinition": + """Creates or updates a policy set definition. + + :param policy_set_definition_name: The name of the policy set definition to create. + :type policy_set_definition_name: str + :param parameters: The policy set definition properties. + :type parameters: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySetDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySetDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicySetDefinition"] + error_map = {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") + + # 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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + async def delete( + self, + policy_set_definition_name: str, + **kwargs + ) -> None: + """Deletes a policy set definition. + + :param policy_set_definition_name: The name of the policy set definition to delete. + :type policy_set_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-06-01-preview" + + # 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] + + # Construct and send request + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + async def get( + self, + policy_set_definition_name: str, + **kwargs + ) -> "models.PolicySetDefinition": + """Gets the policy set definition. + + :param policy_set_definition_name: The name of the policy set definition to get. + :type policy_set_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySetDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicySetDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-06-01-preview" + + # 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'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + async def get_built_in( + self, + policy_set_definition_name: str, + **kwargs + ) -> "models.PolicySetDefinition": + """Gets the built in policy set definition. + + :param policy_set_definition_name: The name of the policy set definition to get. + :type policy_set_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySetDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicySetDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-06-01-preview" + + # 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'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + def list( + self, + **kwargs + ) -> AsyncIterable["models.PolicySetDefinitionListResult"]: + """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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-06-01-preview" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('PolicySetDefinitionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + 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 + + def list_built_in( + self, + **kwargs + ) -> AsyncIterable["models.PolicySetDefinitionListResult"]: + """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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-06-01-preview" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('PolicySetDefinitionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + 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 + + async def create_or_update_at_management_group( + self, + policy_set_definition_name: str, + management_group_id: str, + parameters: "models.PolicySetDefinition", + **kwargs + ) -> "models.PolicySetDefinition": + """Creates or updates a policy set definition at management group level. + + :param policy_set_definition_name: The name of the policy set definition to create. + :type policy_set_definition_name: str + :param management_group_id: The ID of the management group. + :type management_group_id: str + :param parameters: The policy set definition properties. + :type parameters: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySetDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySetDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicySetDefinition"] + error_map = {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") + + # 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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + + if cls: + 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 + + async def delete_at_management_group( + self, + policy_set_definition_name: str, + management_group_id: str, + **kwargs + ) -> None: + """Deletes a policy set definition at management group level. + + :param policy_set_definition_name: The name of the policy set definition to delete. + :type policy_set_definition_name: str + :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: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-06-01-preview" + + # 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] + + # Construct and send request + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + async def get_at_management_group( + self, + policy_set_definition_name: str, + management_group_id: str, + **kwargs + ) -> "models.PolicySetDefinition": + """Gets the policy set definition at management group level. + + :param policy_set_definition_name: The name of the policy set definition to get. + :type policy_set_definition_name: str + :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: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySetDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicySetDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-06-01-preview" + + # 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'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + + if cls: + 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 + + def list_by_management_group( + self, + management_group_id: str, + **kwargs + ) -> AsyncIterable["models.PolicySetDefinitionListResult"]: + """Gets all the policy set definitions for a subscription at 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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-06-01-preview" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('PolicySetDefinitionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/models/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/models/__init__.py index e5181236c025..f9c468970ae3 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/models/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/models/__init__.py @@ -1,46 +1,47 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- try: - from ._models_py3 import ErrorResponse, ErrorResponseException + from ._models_py3 import ErrorResponse from ._models_py3 import PolicyAssignment + from ._models_py3 import PolicyAssignmentListResult from ._models_py3 import PolicyDefinition + from ._models_py3 import PolicyDefinitionListResult from ._models_py3 import PolicyDefinitionReference from ._models_py3 import PolicySetDefinition + from ._models_py3 import PolicySetDefinitionListResult from ._models_py3 import PolicySku except (SyntaxError, ImportError): - from ._models import ErrorResponse, ErrorResponseException - from ._models import PolicyAssignment - from ._models import PolicyDefinition - from ._models import PolicyDefinitionReference - from ._models import PolicySetDefinition - from ._models import PolicySku -from ._paged_models import PolicyAssignmentPaged -from ._paged_models import PolicyDefinitionPaged -from ._paged_models import PolicySetDefinitionPaged + from ._models import ErrorResponse # type: ignore + from ._models import PolicyAssignment # type: ignore + from ._models import PolicyAssignmentListResult # type: ignore + from ._models import PolicyDefinition # type: ignore + from ._models import PolicyDefinitionListResult # type: ignore + from ._models import PolicyDefinitionReference # type: ignore + from ._models import PolicySetDefinition # type: ignore + from ._models import PolicySetDefinitionListResult # type: ignore + from ._models import PolicySku # type: ignore + from ._policy_client_enums import ( - PolicyType, PolicyMode, + PolicyType, ) __all__ = [ - 'ErrorResponse', 'ErrorResponseException', + 'ErrorResponse', 'PolicyAssignment', + 'PolicyAssignmentListResult', 'PolicyDefinition', + 'PolicyDefinitionListResult', 'PolicyDefinitionReference', 'PolicySetDefinition', + 'PolicySetDefinitionListResult', 'PolicySku', - 'PolicyAssignmentPaged', - 'PolicySetDefinitionPaged', - 'PolicyDefinitionPaged', - 'PolicyType', 'PolicyMode', + 'PolicyType', ] 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 22d1ab104b50..8652c8ee6f6d 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 @@ -1,29 +1,17 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.serialization import Model -from msrest.exceptions import HttpOperationError +from azure.core.exceptions import HttpResponseError +import msrest.serialization -class CloudError(Model): - """CloudError. - """ - - _attribute_map = { - } - - -class ErrorResponse(Model): - """Error response indicates ARM is not able to process the incoming request. - The reason is provided in the error message. +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 @@ -39,31 +27,29 @@ class ErrorResponse(Model): 'error_message': {'key': 'errorMessage', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ErrorResponse, self).__init__(**kwargs) self.http_status = kwargs.get('http_status', None) self.error_code = kwargs.get('error_code', None) self.error_message = kwargs.get('error_message', None) -class ErrorResponseException(HttpOperationError): - """Server responsed with exception of type: 'ErrorResponse'. - - :param deserialize: A deserializer - :param response: Server response to be deserialized. - """ - - def __init__(self, deserialize, response, *args): - - super(ErrorResponseException, self).__init__(deserialize, response, 'ErrorResponse', *args) - - -class PolicyAssignment(Model): +class PolicyAssignment(msrest.serialization.Model): """The policy assignment. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. + :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 + :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. @@ -74,20 +60,10 @@ class PolicyAssignment(Model): :type not_scopes: list[str] :param parameters: Required if a parameter is used in policy rule. :type parameters: object - :param description: This message will be part of response in case of - policy violation. + :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: object - :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 - :param sku: The policy sku. - :type sku: - ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySku """ _validation = { @@ -97,6 +73,10 @@ class PolicyAssignment(Model): } _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'sku': {'key': 'sku', 'type': 'PolicySku'}, 'display_name': {'key': 'properties.displayName', 'type': 'str'}, 'policy_definition_id': {'key': 'properties.policyDefinitionId', 'type': 'str'}, 'scope': {'key': 'properties.scope', 'type': 'str'}, @@ -104,14 +84,17 @@ class PolicyAssignment(Model): 'parameters': {'key': 'properties.parameters', 'type': 'object'}, 'description': {'key': 'properties.description', 'type': 'str'}, 'metadata': {'key': 'properties.metadata', 'type': 'object'}, - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'PolicySku'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(PolicyAssignment, self).__init__(**kwargs) + self.id = None + self.type = None + self.name = None + self.sku = kwargs.get('sku', None) self.display_name = kwargs.get('display_name', None) self.policy_definition_id = kwargs.get('policy_definition_id', None) self.scope = kwargs.get('scope', None) @@ -119,28 +102,46 @@ def __init__(self, **kwargs): self.parameters = kwargs.get('parameters', None) self.description = kwargs.get('description', None) self.metadata = kwargs.get('metadata', None) - self.id = None - self.type = None - self.name = None - self.sku = kwargs.get('sku', None) -class PolicyDefinition(Model): +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 + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[PolicyAssignment]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(PolicyAssignmentListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class PolicyDefinition(msrest.serialization.Model): """The policy definition. - Variables are only populated by the server, and will be ignored when - sending a request. - - :param 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. Possible values include: 'NotSpecified', 'Indexed', - 'All' - :type mode: str or - ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyMode + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The ID of the policy definition. + :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, + 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. + 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. @@ -151,10 +152,6 @@ class PolicyDefinition(Model): :type metadata: object :param parameters: Required if a parameter is used in policy rule. :type parameters: object - :ivar id: The ID of the policy definition. - :vartype id: str - :ivar name: The name of the policy definition. - :vartype name: str """ _validation = { @@ -163,6 +160,8 @@ class PolicyDefinition(Model): } _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, 'policy_type': {'key': 'properties.policyType', 'type': 'str'}, 'mode': {'key': 'properties.mode', 'type': 'str'}, 'display_name': {'key': 'properties.displayName', 'type': 'str'}, @@ -170,12 +169,15 @@ class PolicyDefinition(Model): 'policy_rule': {'key': 'properties.policyRule', 'type': 'object'}, 'metadata': {'key': 'properties.metadata', 'type': 'object'}, 'parameters': {'key': 'properties.parameters', 'type': 'object'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(PolicyDefinition, self).__init__(**kwargs) + self.id = None + self.name = None self.policy_type = kwargs.get('policy_type', None) self.mode = kwargs.get('mode', None) self.display_name = kwargs.get('display_name', None) @@ -183,15 +185,35 @@ def __init__(self, **kwargs): self.policy_rule = kwargs.get('policy_rule', None) self.metadata = kwargs.get('metadata', None) self.parameters = kwargs.get('parameters', None) - self.id = None - self.name = None -class PolicyDefinitionReference(Model): +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 + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[PolicyDefinition]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(PolicyDefinitionListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class PolicyDefinitionReference(msrest.serialization.Model): """The policy definition reference. - :param policy_definition_id: The ID of the policy definition or policy set - definition. + :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: object @@ -202,86 +224,106 @@ class PolicyDefinitionReference(Model): 'parameters': {'key': 'parameters', 'type': 'object'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(PolicyDefinitionReference, self).__init__(**kwargs) self.policy_definition_id = kwargs.get('policy_definition_id', None) self.parameters = kwargs.get('parameters', None) -class PolicySetDefinition(Model): +class PolicySetDefinition(msrest.serialization.Model): """The policy set definition. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. - - :param 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 + :ivar id: The ID of the policy set definition. + :vartype id: str + :ivar name: The name of the policy set definition. + :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, + 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: object - :param parameters: The policy set definition parameters that can be used - in policy definition references. - :type parameters: object - :param policy_definitions: Required. An array of policy definition + :param parameters: The policy set definition parameters that can be used in policy definition references. + :type parameters: object + :param policy_definitions: An array of policy definition references. :type policy_definitions: list[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinitionReference] - :ivar id: The ID of the policy set definition. - :vartype id: str - :ivar name: The name of the policy set definition. - :vartype name: str - :ivar type: The type of the resource - (Microsoft.Authorization/policySetDefinitions). - :vartype type: str """ _validation = { - 'policy_definitions': {'required': True}, 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, } _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, 'policy_type': {'key': 'properties.policyType', 'type': 'str'}, 'display_name': {'key': 'properties.displayName', 'type': 'str'}, 'description': {'key': 'properties.description', 'type': 'str'}, 'metadata': {'key': 'properties.metadata', 'type': 'object'}, 'parameters': {'key': 'properties.parameters', 'type': 'object'}, 'policy_definitions': {'key': 'properties.policyDefinitions', 'type': '[PolicyDefinitionReference]'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(PolicySetDefinition, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None self.policy_type = kwargs.get('policy_type', None) self.display_name = kwargs.get('display_name', None) self.description = kwargs.get('description', None) self.metadata = kwargs.get('metadata', None) self.parameters = kwargs.get('parameters', None) self.policy_definitions = kwargs.get('policy_definitions', None) - self.id = None - self.name = None - self.type = None -class PolicySku(Model): +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 + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[PolicySetDefinition]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(PolicySetDefinitionListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class PolicySku(msrest.serialization.Model): """The policy sku. 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. + :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 @@ -296,7 +338,10 @@ class PolicySku(Model): 'tier': {'key': 'tier', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(PolicySku, self).__init__(**kwargs) - self.name = kwargs.get('name', None) + 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 55e76e7672e5..af0ea11dbb95 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 @@ -1,29 +1,21 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.serialization import Model -from msrest.exceptions import HttpOperationError +from typing import List, Optional, Union +from azure.core.exceptions import HttpResponseError +import msrest.serialization -class CloudError(Model): - """CloudError. - """ - - _attribute_map = { - } +from ._policy_client_enums import * -class ErrorResponse(Model): - """Error response indicates ARM is not able to process the incoming request. - The reason is provided in the error message. +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 @@ -39,31 +31,33 @@ class ErrorResponse(Model): 'error_message': {'key': 'errorMessage', 'type': 'str'}, } - def __init__(self, *, http_status: str=None, error_code: str=None, error_message: str=None, **kwargs) -> None: + def __init__( + self, + *, + http_status: Optional[str] = None, + error_code: Optional[str] = None, + error_message: Optional[str] = None, + **kwargs + ): super(ErrorResponse, self).__init__(**kwargs) self.http_status = http_status self.error_code = error_code self.error_message = error_message -class ErrorResponseException(HttpOperationError): - """Server responsed with exception of type: 'ErrorResponse'. - - :param deserialize: A deserializer - :param response: Server response to be deserialized. - """ - - def __init__(self, deserialize, response, *args): - - super(ErrorResponseException, self).__init__(deserialize, response, 'ErrorResponse', *args) - - -class PolicyAssignment(Model): +class PolicyAssignment(msrest.serialization.Model): """The policy assignment. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. + :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 + :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. @@ -74,20 +68,10 @@ class PolicyAssignment(Model): :type not_scopes: list[str] :param parameters: Required if a parameter is used in policy rule. :type parameters: object - :param description: This message will be part of response in case of - policy violation. + :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: object - :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 - :param sku: The policy sku. - :type sku: - ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySku """ _validation = { @@ -97,6 +81,10 @@ class PolicyAssignment(Model): } _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'sku': {'key': 'sku', 'type': 'PolicySku'}, 'display_name': {'key': 'properties.displayName', 'type': 'str'}, 'policy_definition_id': {'key': 'properties.policyDefinitionId', 'type': 'str'}, 'scope': {'key': 'properties.scope', 'type': 'str'}, @@ -104,14 +92,26 @@ class PolicyAssignment(Model): 'parameters': {'key': 'properties.parameters', 'type': 'object'}, 'description': {'key': 'properties.description', 'type': 'str'}, 'metadata': {'key': 'properties.metadata', 'type': 'object'}, - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'PolicySku'}, } - def __init__(self, *, display_name: str=None, policy_definition_id: str=None, scope: str=None, not_scopes=None, parameters=None, description: str=None, metadata=None, sku=None, **kwargs) -> None: + def __init__( + self, + *, + sku: Optional["PolicySku"] = None, + display_name: Optional[str] = None, + policy_definition_id: Optional[str] = None, + scope: Optional[str] = None, + not_scopes: Optional[List[str]] = None, + parameters: Optional[object] = None, + description: Optional[str] = None, + metadata: Optional[object] = None, + **kwargs + ): super(PolicyAssignment, self).__init__(**kwargs) + self.id = None + self.type = None + self.name = None + self.sku = sku self.display_name = display_name self.policy_definition_id = policy_definition_id self.scope = scope @@ -119,28 +119,49 @@ def __init__(self, *, display_name: str=None, policy_definition_id: str=None, sc self.parameters = parameters self.description = description self.metadata = metadata - self.id = None - self.type = None - self.name = None - self.sku = sku -class PolicyDefinition(Model): +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 + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[PolicyAssignment]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["PolicyAssignment"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(PolicyAssignmentListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class PolicyDefinition(msrest.serialization.Model): """The policy definition. - Variables are only populated by the server, and will be ignored when - sending a request. - - :param 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. Possible values include: 'NotSpecified', 'Indexed', - 'All' - :type mode: str or - ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyMode + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The ID of the policy definition. + :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, + 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. + 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. @@ -151,10 +172,6 @@ class PolicyDefinition(Model): :type metadata: object :param parameters: Required if a parameter is used in policy rule. :type parameters: object - :ivar id: The ID of the policy definition. - :vartype id: str - :ivar name: The name of the policy definition. - :vartype name: str """ _validation = { @@ -163,6 +180,8 @@ class PolicyDefinition(Model): } _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, 'policy_type': {'key': 'properties.policyType', 'type': 'str'}, 'mode': {'key': 'properties.mode', 'type': 'str'}, 'display_name': {'key': 'properties.displayName', 'type': 'str'}, @@ -170,12 +189,23 @@ class PolicyDefinition(Model): 'policy_rule': {'key': 'properties.policyRule', 'type': 'object'}, 'metadata': {'key': 'properties.metadata', 'type': 'object'}, 'parameters': {'key': 'properties.parameters', 'type': 'object'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, } - def __init__(self, *, policy_type=None, mode=None, display_name: str=None, description: str=None, policy_rule=None, metadata=None, parameters=None, **kwargs) -> None: + def __init__( + self, + *, + policy_type: Optional[Union[str, "PolicyType"]] = None, + mode: Optional[Union[str, "PolicyMode"]] = None, + display_name: Optional[str] = None, + description: Optional[str] = None, + policy_rule: Optional[object] = None, + metadata: Optional[object] = None, + parameters: Optional[object] = None, + **kwargs + ): super(PolicyDefinition, self).__init__(**kwargs) + self.id = None + self.name = None self.policy_type = policy_type self.mode = mode self.display_name = display_name @@ -183,15 +213,38 @@ def __init__(self, *, policy_type=None, mode=None, display_name: str=None, descr self.policy_rule = policy_rule self.metadata = metadata self.parameters = parameters - self.id = None - self.name = None -class PolicyDefinitionReference(Model): +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 + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[PolicyDefinition]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["PolicyDefinition"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(PolicyDefinitionListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class PolicyDefinitionReference(msrest.serialization.Model): """The policy definition reference. - :param policy_definition_id: The ID of the policy definition or policy set - definition. + :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: object @@ -202,86 +255,119 @@ class PolicyDefinitionReference(Model): 'parameters': {'key': 'parameters', 'type': 'object'}, } - def __init__(self, *, policy_definition_id: str=None, parameters=None, **kwargs) -> None: + def __init__( + self, + *, + policy_definition_id: Optional[str] = None, + parameters: Optional[object] = None, + **kwargs + ): super(PolicyDefinitionReference, self).__init__(**kwargs) self.policy_definition_id = policy_definition_id self.parameters = parameters -class PolicySetDefinition(Model): +class PolicySetDefinition(msrest.serialization.Model): """The policy set definition. - Variables are only populated by the server, and will be ignored when - sending a request. - - All required parameters must be populated in order to send to Azure. + Variables are only populated by the server, and will be ignored when sending a request. - :param 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 + :ivar id: The ID of the policy set definition. + :vartype id: str + :ivar name: The name of the policy set definition. + :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, + 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: object - :param parameters: The policy set definition parameters that can be used - in policy definition references. - :type parameters: object - :param policy_definitions: Required. An array of policy definition + :param parameters: The policy set definition parameters that can be used in policy definition references. + :type parameters: object + :param policy_definitions: An array of policy definition references. :type policy_definitions: list[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinitionReference] - :ivar id: The ID of the policy set definition. - :vartype id: str - :ivar name: The name of the policy set definition. - :vartype name: str - :ivar type: The type of the resource - (Microsoft.Authorization/policySetDefinitions). - :vartype type: str """ _validation = { - 'policy_definitions': {'required': True}, 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, } _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, 'policy_type': {'key': 'properties.policyType', 'type': 'str'}, 'display_name': {'key': 'properties.displayName', 'type': 'str'}, 'description': {'key': 'properties.description', 'type': 'str'}, 'metadata': {'key': 'properties.metadata', 'type': 'object'}, 'parameters': {'key': 'properties.parameters', 'type': 'object'}, 'policy_definitions': {'key': 'properties.policyDefinitions', 'type': '[PolicyDefinitionReference]'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, } - def __init__(self, *, policy_definitions, policy_type=None, display_name: str=None, description: str=None, metadata=None, parameters=None, **kwargs) -> None: + def __init__( + self, + *, + policy_type: Optional[Union[str, "PolicyType"]] = None, + display_name: Optional[str] = None, + description: Optional[str] = None, + metadata: Optional[object] = None, + parameters: Optional[object] = None, + policy_definitions: Optional[List["PolicyDefinitionReference"]] = None, + **kwargs + ): super(PolicySetDefinition, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None self.policy_type = policy_type self.display_name = display_name self.description = description self.metadata = metadata self.parameters = parameters self.policy_definitions = policy_definitions - self.id = None - self.name = None - self.type = None -class PolicySku(Model): +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 + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[PolicySetDefinition]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["PolicySetDefinition"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(PolicySetDefinitionListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class PolicySku(msrest.serialization.Model): """The policy sku. 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. + :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 @@ -296,7 +382,13 @@ class PolicySku(Model): 'tier': {'key': 'tier', 'type': 'str'}, } - def __init__(self, *, name: str, tier: str=None, **kwargs) -> None: + def __init__( + self, + *, + name: str, + tier: Optional[str] = None, + **kwargs + ): 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/_paged_models.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/models/_paged_models.py deleted file mode 100644 index 0976003bf1d6..000000000000 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/models/_paged_models.py +++ /dev/null @@ -1,53 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.paging import Paged - - -class PolicyAssignmentPaged(Paged): - """ - A paging container for iterating over a list of :class:`PolicyAssignment ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[PolicyAssignment]'} - } - - def __init__(self, *args, **kwargs): - - super(PolicyAssignmentPaged, self).__init__(*args, **kwargs) -class PolicySetDefinitionPaged(Paged): - """ - A paging container for iterating over a list of :class:`PolicySetDefinition ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[PolicySetDefinition]'} - } - - def __init__(self, *args, **kwargs): - - super(PolicySetDefinitionPaged, self).__init__(*args, **kwargs) -class PolicyDefinitionPaged(Paged): - """ - A paging container for iterating over a list of :class:`PolicyDefinition ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[PolicyDefinition]'} - } - - def __init__(self, *args, **kwargs): - - super(PolicyDefinitionPaged, self).__init__(*args, **kwargs) 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 a9dcf44c1e7c..65c6d02a7e1c 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 @@ -1,26 +1,25 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from enum import Enum +class PolicyMode(str, Enum): + """The policy definition mode. Possible values are NotSpecified, Indexed, and All. + """ + + not_specified = "NotSpecified" + indexed = "Indexed" + all = "All" class PolicyType(str, Enum): + """The type of policy definition. Possible values are NotSpecified, BuiltIn, and Custom. + """ not_specified = "NotSpecified" built_in = "BuiltIn" custom = "Custom" - - -class PolicyMode(str, Enum): - - not_specified = "NotSpecified" - indexed = "Indexed" - all = "All" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/operations/__init__.py index c23e1d9aaddf..ec897bea6fe8 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/operations/__init__.py @@ -1,12 +1,9 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from ._policy_assignments_operations import PolicyAssignmentsOperations 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 83547de462c5..e92a15492045 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 @@ -1,668 +1,642 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class PolicyAssignmentsOperations(object): """PolicyAssignmentsOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.policy.v2017_06_01_preview.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for the operation. Constant value: "2017-06-01-preview". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2017-06-01-preview" - - self.config = config + self._config = config def delete( - self, scope, policy_assignment_name, custom_headers=None, raw=False, **operation_config): + self, + scope, # type: str + policy_assignment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyAssignment" """Deletes a policy assignment. :param scope: The scope of the policy assignment. :type scope: str - :param policy_assignment_name: The name of the policy assignment to - delete. + :param policy_assignment_name: The name of the policy assignment to delete. :type policy_assignment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyAssignment or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignment - or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignment or None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-06-01-preview" + # Construct URL - url = self.delete.metadata['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') + 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('PolicyAssignment', response) + deserialized = self._deserialize('PolicyAssignment', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} + delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore def create( - self, scope, policy_assignment_name, parameters, custom_headers=None, raw=False, **operation_config): - """Creates a policy assignment. + self, + scope, # type: str + policy_assignment_name, # type: str + parameters, # type: "models.PolicyAssignment" + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyAssignment" + """Policy assignments are inherited by child resources. For example, when you apply a policy to a resource group that policy is assigned to all resources in the group. - Policy assignments are inherited by child resources. For example, when - you apply a policy to a resource group that policy is assigned to all - resources in the group. + Creates a policy assignment. :param scope: The scope of the policy assignment. :type scope: str :param policy_assignment_name: The name of the policy assignment. :type policy_assignment_name: str :param parameters: Parameters for the policy assignment. - :type parameters: - ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignment - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyAssignment or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignment - or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :type parameters: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignment + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {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") + # Construct URL - url = self.create.metadata['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') + 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'PolicyAssignment') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 201: - deserialized = self._deserialize('PolicyAssignment', response) + deserialized = self._deserialize('PolicyAssignment', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} + create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore def get( - self, scope, policy_assignment_name, custom_headers=None, raw=False, **operation_config): + self, + scope, # type: str + policy_assignment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyAssignment" """Gets a policy assignment. :param scope: The scope of the policy assignment. :type scope: str - :param policy_assignment_name: The name of the policy assignment to - get. + :param policy_assignment_name: The name of the policy assignment to get. :type policy_assignment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyAssignment or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignment - or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-06-01-preview" + # Construct URL - url = self.get.metadata['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') + 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('PolicyAssignment', response) + deserialized = self._deserialize('PolicyAssignment', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} + get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore def list_for_resource_group( - self, resource_group_name, filter=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + filter=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.PolicyAssignmentListResult"] """Gets policy assignments for the resource group. - :param resource_group_name: The name of the resource group that - contains policy assignments. + :param resource_group_name: The name of the resource group that contains policy assignments. :type resource_group_name: str :param filter: The filter to apply on the operation. :type filter: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of PolicyAssignment - :rtype: - ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignmentPaged[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignment] - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-06-01-preview" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_for_resource_group.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) - - return response + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.PolicyAssignmentPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list_for_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments'} + return ItemPaged( + get_next, extract_data + ) + list_for_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments'} # type: ignore def list_for_resource( - self, resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, filter=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + filter=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.PolicyAssignmentListResult"] """Gets policy assignments for a resource. - :param resource_group_name: The name of the resource group containing - the resource. The name is case insensitive. + :param resource_group_name: The name of the resource group containing the resource. The name is + case insensitive. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource - provider. + :param resource_provider_namespace: The namespace of the resource provider. :type resource_provider_namespace: str :param parent_resource_path: The parent resource path. :type parent_resource_path: str :param resource_type: The resource type. :type resource_type: str - :param resource_name: The name of the resource with policy - assignments. + :param resource_name: The name of the resource with policy assignments. :type resource_name: str :param filter: The filter to apply on the operation. :type filter: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of PolicyAssignment - :rtype: - ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignmentPaged[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignment] - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-06-01-preview" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_for_resource.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) - - return response + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.PolicyAssignmentPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list_for_resource.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments'} + 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 def list( - self, filter=None, custom_headers=None, raw=False, **operation_config): + self, + filter=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.PolicyAssignmentListResult"] """Gets all the policy assignments for a subscription. :param filter: The filter to apply on the operation. :type filter: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of PolicyAssignment - :rtype: - ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignmentPaged[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignment] - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-06-01-preview" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['url'] + url = self.list.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_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 = {} + 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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) - - return response + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.PolicyAssignmentPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments'} # type: ignore def delete_by_id( - self, policy_assignment_id, custom_headers=None, raw=False, **operation_config): - """Deletes a policy assignment by ID. - - When providing a scope for the assignment, use - '/subscriptions/{subscription-id}/' for subscriptions, - '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' - for resource groups, and - '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider-namespace}/{resource-type}/{resource-name}' - for resources. - - :param policy_assignment_id: The ID of the policy assignment to - delete. Use the format + self, + policy_assignment_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyAssignment" + """When providing a scope for the assignment, use '/subscriptions/{subscription-id}/' for subscriptions, '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for resource groups, and '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider-namespace}/{resource-type}/{resource-name}' for resources. + + Deletes a policy assignment by ID. + + :param policy_assignment_id: The ID of the policy assignment to delete. Use the format '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policy-assignment-name}'. :type policy_assignment_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyAssignment or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignment - or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-06-01-preview" + # Construct URL - url = self.delete_by_id.metadata['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) + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('PolicyAssignment', response) + deserialized = self._deserialize('PolicyAssignment', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - delete_by_id.metadata = {'url': '/{policyAssignmentId}'} + delete_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore def create_by_id( - self, policy_assignment_id, parameters, custom_headers=None, raw=False, **operation_config): - """Creates a policy assignment by ID. - - Policy assignments are inherited by child resources. For example, when - you apply a policy to a resource group that policy is assigned to all - resources in the group. When providing a scope for the assignment, use - '/subscriptions/{subscription-id}/' for subscriptions, - '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' - for resource groups, and - '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider-namespace}/{resource-type}/{resource-name}' - for resources. - - :param policy_assignment_id: The ID of the policy assignment to - create. Use the format + self, + policy_assignment_id, # type: str + parameters, # type: "models.PolicyAssignment" + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyAssignment" + """Policy assignments are inherited by child resources. For example, when you apply a policy to a resource group that policy is assigned to all resources in the group. When providing a scope for the assignment, use '/subscriptions/{subscription-id}/' for subscriptions, '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for resource groups, and '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider-namespace}/{resource-type}/{resource-name}' for resources. + + Creates a policy assignment by ID. + + :param policy_assignment_id: The ID of the policy assignment to create. Use the format '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policy-assignment-name}'. :type policy_assignment_id: str :param parameters: Parameters for policy assignment. - :type parameters: - ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignment - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyAssignment or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignment - or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :type parameters: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignment + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {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") + # Construct URL - url = self.create_by_id.metadata['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) + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'PolicyAssignment') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 201: - deserialized = self._deserialize('PolicyAssignment', response) + deserialized = self._deserialize('PolicyAssignment', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create_by_id.metadata = {'url': '/{policyAssignmentId}'} + create_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore def get_by_id( - self, policy_assignment_id, custom_headers=None, raw=False, **operation_config): - """Gets a policy assignment by ID. - - When providing a scope for the assignment, use - '/subscriptions/{subscription-id}/' for subscriptions, - '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' - for resource groups, and - '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider-namespace}/{resource-type}/{resource-name}' - for resources. - - :param policy_assignment_id: The ID of the policy assignment to get. - Use the format + self, + policy_assignment_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyAssignment" + """When providing a scope for the assignment, use '/subscriptions/{subscription-id}/' for subscriptions, '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for resource groups, and '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider-namespace}/{resource-type}/{resource-name}' for resources. + + Gets a policy assignment by ID. + + :param policy_assignment_id: The ID of the policy assignment to get. Use the format '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policy-assignment-name}'. :type policy_assignment_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyAssignment or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignment - or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-06-01-preview" + # Construct URL - url = self.get_by_id.metadata['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) + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('PolicyAssignment', response) + deserialized = self._deserialize('PolicyAssignment', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/{policyAssignmentId}'} + 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 08ddebdf7963..f40fc1d1e6cd 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 @@ -1,658 +1,626 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class PolicyDefinitionsOperations(object): """PolicyDefinitionsOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.policy.v2017_06_01_preview.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for the operation. Constant value: "2016-12-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2016-12-01" - - self.config = config + self._config = config def create_or_update( - self, policy_definition_name, parameters, custom_headers=None, raw=False, **operation_config): + self, + policy_definition_name, # type: str + parameters, # type: "models.PolicyDefinition" + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyDefinition" """Creates or updates a policy definition. - :param policy_definition_name: The name of the policy definition to - create. + :param policy_definition_name: The name of the policy definition to create. :type policy_definition_name: str :param parameters: The policy definition properties. - :type parameters: - ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinition - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyDefinition or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinition - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :type parameters: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinition + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-12-01" + content_type = kwargs.pop("content_type", "application/json") + # Construct URL - url = self.create_or_update.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'PolicyDefinition') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [201]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 201: - deserialized = self._deserialize('PolicyDefinition', response) + deserialized = self._deserialize('PolicyDefinition', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore def delete( - self, policy_definition_name, custom_headers=None, raw=False, **operation_config): + self, + policy_definition_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Deletes a policy definition. - :param policy_definition_name: The name of the policy definition to - delete. + :param policy_definition_name: The name of the policy definition to delete. :type policy_definition_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-12-01" + # Construct URL - url = self.delete.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore def get( - self, policy_definition_name, custom_headers=None, raw=False, **operation_config): + self, + policy_definition_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyDefinition" """Gets the policy definition. - :param policy_definition_name: The name of the policy definition to - get. + :param policy_definition_name: The name of the policy definition to get. :type policy_definition_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyDefinition or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinition - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinition + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-12-01" + # Construct URL - url = self.get.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('PolicyDefinition', response) + deserialized = self._deserialize('PolicyDefinition', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore def get_built_in( - self, policy_definition_name, custom_headers=None, raw=False, **operation_config): + self, + policy_definition_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyDefinition" """Gets the built in policy definition. - :param policy_definition_name: The name of the built in policy - definition to get. + :param policy_definition_name: The name of the built in policy definition to get. :type policy_definition_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyDefinition or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinition - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinition + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-12-01" + # Construct URL - url = self.get_built_in.metadata['url'] + url = self.get_built_in.metadata['url'] # type: ignore path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str') + 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('PolicyDefinition', response) + deserialized = self._deserialize('PolicyDefinition', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} + get_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore def create_or_update_at_management_group( - self, policy_definition_name, parameters, management_group_id, custom_headers=None, raw=False, **operation_config): + self, + policy_definition_name, # type: str + management_group_id, # type: str + parameters, # type: "models.PolicyDefinition" + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyDefinition" """Creates or updates a policy definition at management group level. - :param policy_definition_name: The name of the policy definition to - create. + :param policy_definition_name: The name of the policy definition to create. :type policy_definition_name: str - :param parameters: The policy definition properties. - :type parameters: - ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinition :param management_group_id: The ID of the management group. :type management_group_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyDefinition or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinition - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :param parameters: The policy definition properties. + :type parameters: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinition + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-12-01" + content_type = kwargs.pop("content_type", "application/json") + # Construct URL - url = self.create_or_update_at_management_group.metadata['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') + 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'PolicyDefinition') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [201]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 201: - deserialized = self._deserialize('PolicyDefinition', response) + deserialized = self._deserialize('PolicyDefinition', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + 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}'} + create_or_update_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore def delete_at_management_group( - self, policy_definition_name, management_group_id, custom_headers=None, raw=False, **operation_config): + self, + policy_definition_name, # type: str + management_group_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Deletes a policy definition at management group level. - :param policy_definition_name: The name of the policy definition to - delete. + :param policy_definition_name: The name of the policy definition to delete. :type policy_definition_name: str :param management_group_id: The ID of the management group. :type management_group_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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'] + 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') + 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} + delete_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore def get_at_management_group( - self, policy_definition_name, management_group_id, custom_headers=None, raw=False, **operation_config): + self, + policy_definition_name, # type: str + management_group_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyDefinition" """Gets the policy definition at management group level. - :param policy_definition_name: The name of the policy definition to - get. + :param policy_definition_name: The name of the policy definition to get. :type policy_definition_name: str :param management_group_id: The ID of the management group. :type management_group_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyDefinition or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinition - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinition + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-12-01" + # Construct URL - url = self.get_at_management_group.metadata['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') + 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('PolicyDefinition', response) + deserialized = self._deserialize('PolicyDefinition', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} + get_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore def list( - self, custom_headers=None, raw=False, **operation_config): + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.PolicyDefinitionListResult"] """Gets all the policy definitions for a subscription. - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of PolicyDefinition - :rtype: - ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinitionPaged[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinition] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-12-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['url'] + url = self.list.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyDefinitionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.PolicyDefinitionPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions'} # type: ignore def list_built_in( - self, custom_headers=None, raw=False, **operation_config): + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.PolicyDefinitionListResult"] """Gets all the built in policy definitions. - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of PolicyDefinition - :rtype: - ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinitionPaged[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinition] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-12-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_built_in.metadata['url'] - + url = self.list_built_in.metadata['url'] # type: ignore # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyDefinitionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.PolicyDefinitionPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policyDefinitions'} + return ItemPaged( + get_next, extract_data + ) + list_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policyDefinitions'} # type: ignore def list_by_management_group( - self, management_group_id, custom_headers=None, raw=False, **operation_config): - """Gets all the policy definitions for a subscription at management group - level. + self, + management_group_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.PolicyDefinitionListResult"] + """Gets all the policy definitions for a subscription at management group level. :param management_group_id: The ID of the management group. :type management_group_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of PolicyDefinition - :rtype: - ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinitionPaged[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicyDefinition] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-12-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_by_management_group.metadata['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') + 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyDefinitionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.PolicyDefinitionPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_by_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions'} + return ItemPaged( + get_next, extract_data + ) + list_by_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions'} # type: ignore 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 1a7e847aaa28..fdddfb6e8f73 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 @@ -1,651 +1,646 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class PolicySetDefinitionsOperations(object): """PolicySetDefinitionsOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.policy.v2017_06_01_preview.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for the operation. Constant value: "2017-06-01-preview". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2017-06-01-preview" - - self.config = config + self._config = config def create_or_update( - self, policy_set_definition_name, parameters, custom_headers=None, raw=False, **operation_config): + self, + policy_set_definition_name, # type: str + parameters, # type: "models.PolicySetDefinition" + **kwargs # type: Any + ): + # type: (...) -> "models.PolicySetDefinition" """Creates or updates a policy set definition. - :param policy_set_definition_name: The name of the policy set - definition to create. + :param policy_set_definition_name: The name of the policy set definition to create. :type policy_set_definition_name: str :param parameters: The policy set definition properties. - :type parameters: - ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySetDefinition - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicySetDefinition or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySetDefinition - or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :type parameters: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySetDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySetDefinition + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicySetDefinition"] + error_map = {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") + # Construct URL - url = self.create_or_update.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'PolicySetDefinition') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('PolicySetDefinition', response) + deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('PolicySetDefinition', response) + deserialized = self._deserialize('PolicySetDefinition', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore def delete( - self, policy_set_definition_name, custom_headers=None, raw=False, **operation_config): + self, + policy_set_definition_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Deletes a policy set definition. - :param policy_set_definition_name: The name of the policy set - definition to delete. + :param policy_set_definition_name: The name of the policy set definition to delete. :type policy_set_definition_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-06-01-preview" + # Construct URL - url = self.delete.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore def get( - self, policy_set_definition_name, custom_headers=None, raw=False, **operation_config): + self, + policy_set_definition_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.PolicySetDefinition" """Gets the policy set definition. - :param policy_set_definition_name: The name of the policy set - definition to get. + :param policy_set_definition_name: The name of the policy set definition to get. :type policy_set_definition_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicySetDefinition or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySetDefinition - or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySetDefinition + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicySetDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-06-01-preview" + # Construct URL - url = self.get.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('PolicySetDefinition', response) + deserialized = self._deserialize('PolicySetDefinition', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore def get_built_in( - self, policy_set_definition_name, custom_headers=None, raw=False, **operation_config): + self, + policy_set_definition_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.PolicySetDefinition" """Gets the built in policy set definition. - :param policy_set_definition_name: The name of the policy set - definition to get. + :param policy_set_definition_name: The name of the policy set definition to get. :type policy_set_definition_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicySetDefinition or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySetDefinition - or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySetDefinition + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicySetDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-06-01-preview" + # Construct URL - url = self.get_built_in.metadata['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') + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('PolicySetDefinition', response) + deserialized = self._deserialize('PolicySetDefinition', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} + get_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore def list( - self, custom_headers=None, raw=False, **operation_config): + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.PolicySetDefinitionListResult"] """Gets all the policy set definitions for a subscription. - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of PolicySetDefinition - :rtype: - ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySetDefinitionPaged[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySetDefinition] - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-06-01-preview" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['url'] + url = self.list.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('PolicySetDefinitionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.PolicySetDefinitionPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions'} # type: ignore def list_built_in( - self, custom_headers=None, raw=False, **operation_config): + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.PolicySetDefinitionListResult"] """Gets all the built in policy set definitions. - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of PolicySetDefinition - :rtype: - ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySetDefinitionPaged[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySetDefinition] - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-06-01-preview" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_built_in.metadata['url'] - + url = self.list_built_in.metadata['url'] # type: ignore # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('PolicySetDefinitionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.PolicySetDefinitionPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policySetDefinitions'} + return ItemPaged( + get_next, extract_data + ) + list_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policySetDefinitions'} # type: ignore def create_or_update_at_management_group( - self, policy_set_definition_name, parameters, management_group_id, custom_headers=None, raw=False, **operation_config): + self, + policy_set_definition_name, # type: str + management_group_id, # type: str + parameters, # type: "models.PolicySetDefinition" + **kwargs # type: Any + ): + # type: (...) -> "models.PolicySetDefinition" """Creates or updates a policy set definition at management group level. - :param policy_set_definition_name: The name of the policy set - definition to create. + :param policy_set_definition_name: The name of the policy set definition to create. :type policy_set_definition_name: str - :param parameters: The policy set definition properties. - :type parameters: - ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySetDefinition :param management_group_id: The ID of the management group. :type management_group_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicySetDefinition or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySetDefinition - or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :param parameters: The policy set definition properties. + :type parameters: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySetDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySetDefinition + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicySetDefinition"] + error_map = {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") + # Construct URL - url = self.create_or_update_at_management_group.metadata['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') + 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'PolicySetDefinition') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('PolicySetDefinition', response) + deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('PolicySetDefinition', response) + deserialized = self._deserialize('PolicySetDefinition', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + 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}'} + create_or_update_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore def delete_at_management_group( - self, policy_set_definition_name, management_group_id, custom_headers=None, raw=False, **operation_config): + self, + policy_set_definition_name, # type: str + management_group_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Deletes a policy set definition at management group level. - :param policy_set_definition_name: The name of the policy set - definition to delete. + :param policy_set_definition_name: The name of the policy set definition to delete. :type policy_set_definition_name: str :param management_group_id: The ID of the management group. :type management_group_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-06-01-preview" + # Construct URL - url = self.delete_at_management_group.metadata['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') + 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} + delete_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore def get_at_management_group( - self, policy_set_definition_name, management_group_id, custom_headers=None, raw=False, **operation_config): + self, + policy_set_definition_name, # type: str + management_group_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.PolicySetDefinition" """Gets the policy set definition at management group level. - :param policy_set_definition_name: The name of the policy set - definition to get. + :param policy_set_definition_name: The name of the policy set definition to get. :type policy_set_definition_name: str :param management_group_id: The ID of the management group. :type management_group_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicySetDefinition or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySetDefinition - or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySetDefinition + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicySetDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-06-01-preview" + # Construct URL - url = self.get_at_management_group.metadata['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') + 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('PolicySetDefinition', response) + deserialized = self._deserialize('PolicySetDefinition', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} + get_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore def list_by_management_group( - self, management_group_id, custom_headers=None, raw=False, **operation_config): - """Gets all the policy set definitions for a subscription at management - group. + self, + management_group_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.PolicySetDefinitionListResult"] + """Gets all the policy set definitions for a subscription at management group. :param management_group_id: The ID of the management group. :type management_group_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of PolicySetDefinition - :rtype: - ~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySetDefinitionPaged[~azure.mgmt.resource.policy.v2017_06_01_preview.models.PolicySetDefinition] - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-06-01-preview" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_by_management_group.metadata['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') + 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('PolicySetDefinitionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.PolicySetDefinitionPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_by_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions'} + return ItemPaged( + get_next, extract_data + ) + list_by_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/py.typed b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file 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 deleted file mode 100644 index 53a203f32aaf..000000000000 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2017_06_01_preview/version.py +++ /dev/null @@ -1,13 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -VERSION = "" - 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 56bf47bfb9e4..e4bba9352a5c 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 @@ -1,19 +1,16 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._configuration import PolicyClientConfiguration from ._policy_client import PolicyClient -__all__ = ['PolicyClient', 'PolicyClientConfiguration'] - -from .version import VERSION - -__version__ = VERSION +__all__ = ['PolicyClient'] +try: + from ._patch import patch_sdk + patch_sdk() +except ImportError: + pass 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 ede4f42045d0..e1077417d882 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 @@ -1,48 +1,69 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrestazure import AzureConfiguration -from .version import VERSION +from typing import TYPE_CHECKING +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + + from azure.core.credentials import TokenCredential + +VERSION = "unknown" + +class PolicyClientConfiguration(Configuration): + """Configuration for PolicyClient. -class PolicyClientConfiguration(AzureConfiguration): - """Configuration for PolicyClient Note that all parameters used to create this instance are saved as instance attributes. - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` + :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 """ def __init__( - self, credentials, subscription_id, base_url=None): - - if credentials is None: - raise ValueError("Parameter 'credentials' must not be None.") + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + 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.") - if not base_url: - base_url = 'https://management.azure.com' + super(PolicyClientConfiguration, self).__init__(**kwargs) - super(PolicyClientConfiguration, self).__init__(base_url) - - # Starting Autorest.Python 4.0.64, make connection pool activated by default - self.keep_alive = True - - self.add_user_agent('azure-mgmt-resource/{}'.format(VERSION)) - self.add_user_agent('Azure-SDK-For-Python') - - self.credentials = credentials + self.credential = credential self.subscription_id = subscription_id + self.api_version = "2018-03-01" + self.credential_scopes = ['https://management.azure.com/.default'] + self.credential_scopes.extend(kwargs.pop('credential_scopes', [])) + kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + 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) 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 new file mode 100644 index 000000000000..4938b2ce1d2f --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/_metadata.json @@ -0,0 +1,55 @@ +{ + "chosen_version": "2018-03-01", + "total_api_version_list": ["2018-03-01"], + "client": { + "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." + }, + "global_parameters": { + "sync_method": { + "credential": { + "method_signature": "credential, # type: \"TokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials.TokenCredential", + "required": true + }, + "subscription_id": { + "method_signature": "subscription_id, # type: str", + "description": "The ID of the target subscription.", + "docstring_type": "str", + "required": true + } + }, + "async_method": { + "credential": { + "method_signature": "credential, # type: \"AsyncTokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + }, + "subscription_id": { + "method_signature": "subscription_id, # type: str", + "description": "The ID of the target subscription.", + "docstring_type": "str", + "required": true + } + }, + "constant": { + }, + "call": "credential, subscription_id" + }, + "config": { + "credential": true, + "credential_scopes": ["https://management.azure.com/.default"] + }, + "operation_groups": { + "policy_assignments": "PolicyAssignmentsOperations", + "policy_definitions": "PolicyDefinitionsOperations", + "policy_set_definitions": "PolicySetDefinitionsOperations" + }, + "operation_mixins": { + }, + "sync_imports": "None", + "async_imports": "None" +} \ 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 4983c9ac6074..1b3d3d7ce10c 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 @@ -1,16 +1,19 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.service_client import SDKClient -from msrest import Serializer, Deserializer +from typing import TYPE_CHECKING + +from azure.mgmt.core import ARMPipelineClient +from msrest import Deserializer, Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional from ._configuration import PolicyClientConfiguration from .operations import PolicyAssignmentsOperations @@ -19,41 +22,56 @@ from . import models -class PolicyClient(SDKClient): +class PolicyClient(object): """To manage and control access to your resources, you can define customized policies and assign them at a scope. - :ivar config: Configuration for client. - :vartype config: PolicyClientConfiguration - - :ivar policy_assignments: PolicyAssignments operations + :ivar policy_assignments: PolicyAssignmentsOperations operations :vartype policy_assignments: azure.mgmt.resource.policy.v2018_03_01.operations.PolicyAssignmentsOperations - :ivar policy_definitions: PolicyDefinitions operations + :ivar policy_definitions: PolicyDefinitionsOperations operations :vartype policy_definitions: azure.mgmt.resource.policy.v2018_03_01.operations.PolicyDefinitionsOperations - :ivar policy_set_definitions: PolicySetDefinitions operations + :ivar policy_set_definitions: PolicySetDefinitionsOperations operations :vartype policy_set_definitions: azure.mgmt.resource.policy.v2018_03_01.operations.PolicySetDefinitionsOperations - - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` + :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. """ def __init__( - self, credentials, subscription_id, base_url=None): - - self.config = PolicyClientConfiguration(credentials, subscription_id, base_url) - super(PolicyClient, self).__init__(self.config.credentials, self.config) + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = 'https://management.azure.com' + self._config = PolicyClientConfiguration(credential, 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.api_version = '2018-03-01' self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self.policy_assignments = PolicyAssignmentsOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.policy_definitions = PolicyDefinitionsOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.policy_set_definitions = PolicySetDefinitionsOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> PolicyClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) 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 new file mode 100644 index 000000000000..df3c0beab48a --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/aio/__init__.py @@ -0,0 +1,10 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._policy_client_async import PolicyClient +__all__ = ['PolicyClient'] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/aio/_configuration_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/aio/_configuration_async.py new file mode 100644 index 000000000000..834591de4c0d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/aio/_configuration_async.py @@ -0,0 +1,65 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + +VERSION = "unknown" + +class PolicyClientConfiguration(Configuration): + """Configuration for PolicyClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :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 + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + 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 + self.api_version = "2018-03-01" + self.credential_scopes = ['https://management.azure.com/.default'] + self.credential_scopes.extend(kwargs.pop('credential_scopes', [])) + kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs: Any + ) -> None: + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + 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) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/aio/_policy_client_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/aio/_policy_client_async.py new file mode 100644 index 000000000000..5af5ff9909d5 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/aio/_policy_client_async.py @@ -0,0 +1,69 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, Optional + +from azure.mgmt.core import AsyncARMPipelineClient +from msrest import Deserializer, Serializer + +from ._configuration_async import PolicyClientConfiguration +from .operations_async import PolicyAssignmentsOperations +from .operations_async import PolicyDefinitionsOperations +from .operations_async import PolicySetDefinitionsOperations +from .. import models + + +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.aio.operations_async.PolicyAssignmentsOperations + :ivar policy_definitions: PolicyDefinitionsOperations operations + :vartype policy_definitions: azure.mgmt.resource.policy.v2018_03_01.aio.operations_async.PolicyDefinitionsOperations + :ivar policy_set_definitions: PolicySetDefinitionsOperations operations + :vartype policy_set_definitions: azure.mgmt.resource.policy.v2018_03_01.aio.operations_async.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 + :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, + **kwargs: 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) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + + self.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 close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "PolicyClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/aio/operations_async/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/aio/operations_async/__init__.py new file mode 100644 index 000000000000..6a33a6888921 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/aio/operations_async/__init__.py @@ -0,0 +1,17 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._policy_assignments_operations_async import PolicyAssignmentsOperations +from ._policy_definitions_operations_async import PolicyDefinitionsOperations +from ._policy_set_definitions_operations_async import PolicySetDefinitionsOperations + +__all__ = [ + 'PolicyAssignmentsOperations', + 'PolicyDefinitionsOperations', + 'PolicySetDefinitionsOperations', +] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/aio/operations_async/_policy_assignments_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/aio/operations_async/_policy_assignments_operations_async.py new file mode 100644 index 000000000000..624e369a6c3b --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/aio/operations_async/_policy_assignments_operations_async.py @@ -0,0 +1,657 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import 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 ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class PolicyAssignmentsOperations: + """PolicyAssignmentsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.policy.v2018_03_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def delete( + self, + scope: str, + policy_assignment_name: str, + **kwargs + ) -> "models.PolicyAssignment": + """This operation deletes a policy assignment, given its name and the scope it was created in. The scope of a policy assignment is the part of its ID preceding '/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + + Deletes a policy assignment. + + :param scope: The scope of the policy assignment. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + :type scope: str + :param policy_assignment_name: The name of the policy assignment to delete. + :type policy_assignment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyAssignment or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {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 = { + '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'] = 'application/json' + + # Construct and send request + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('PolicyAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore + + async def create( + self, + scope: str, + policy_assignment_name: str, + parameters: "models.PolicyAssignment", + **kwargs + ) -> "models.PolicyAssignment": + """This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + + Creates or updates a policy assignment. + + :param scope: The scope of the policy assignment. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + :type scope: str + :param policy_assignment_name: The name of the policy assignment. + :type policy_assignment_name: str + :param parameters: Parameters for the policy assignment. + :type parameters: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyAssignment + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-03-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore + + async def get( + self, + scope: str, + policy_assignment_name: str, + **kwargs + ) -> "models.PolicyAssignment": + """This operation retrieves a single policy assignment, given its name and the scope it was created at. + + Retrieves a policy assignment. + + :param scope: The scope of the policy assignment. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + :type scope: str + :param policy_assignment_name: The name of the policy assignment to get. + :type policy_assignment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-03-01" + + # 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'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore + + def list_for_resource_group( + self, + resource_group_name: str, + filter: Optional[str] = None, + **kwargs + ) -> AsyncIterable["models.PolicyAssignmentListResult"]: + """This operation retrieves the list of all policy assignments associated with the given resource group in the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource group, including those that apply directly or apply from containing scopes, as well as any applied to resources contained within the resource group. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource group, which is everything in the unfiltered list except those applied to resources contained within the resource group. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource group. + + Retrieves all policy assignments that apply to a resource group. + + :param resource_group_name: The name of the resource group that contains policy assignments. + :type resource_group_name: str + :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()' + 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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-03-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + 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 + + def list_for_resource( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + filter: Optional[str] = None, + **kwargs + ) -> AsyncIterable["models.PolicyAssignmentListResult"]: + """This operation retrieves the list of all policy assignments associated with the specified resource in the given resource group and subscription that match the optional given $filter. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource, including those that apply directly or from all containing scopes, as well as any applied to resources contained within the resource. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource, which is everything in the unfiltered list except those applied to resources contained within the resource. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource. Three parameters plus the resource name are used to identify a specific resource. If the resource is not part of a parent resource (the more common case), the parent resource path should not be provided (or provided as ''). For example a web app could be specified as ({resourceProviderNamespace} == 'Microsoft.Web', {parentResourcePath} == '', {resourceType} == 'sites', {resourceName} == 'MyWebApp'). If the resource is part of a parent resource, then all parameters should be provided. For example a virtual machine DNS name could be specified as ({resourceProviderNamespace} == 'Microsoft.Compute', {parentResourcePath} == 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames', {resourceName} == 'MyComputerName'). A convenient alternative to providing the namespace and type name separately is to provide both in the {resourceType} parameter, format: ({resourceProviderNamespace} == '', {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). + + Retrieves all policy assignments that apply to a resource. + + :param resource_group_name: The name of the resource group containing the resource. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. For example, the + namespace of a virtual machine is Microsoft.Compute (from Microsoft.Compute/virtualMachines). + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource path. Use empty string if there is none. + :type parent_resource_path: str + :param resource_type: The resource type name. For example the type name of a web app is 'sites' + (from Microsoft.Web/sites). + :type resource_type: str + :param resource_name: The name of the resource. + :type resource_name: str + :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()' + 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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-03-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + 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 + + def list( + self, + filter: Optional[str] = None, + **kwargs + ) -> AsyncIterable["models.PolicyAssignmentListResult"]: + """This operation retrieves the list of all policy assignments associated with the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the subscription, including those that apply directly or from management groups that contain the given subscription, as well as any applied to objects contained within the subscription. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the subscription, which is everything in the unfiltered list except those applied to objects contained within the subscription. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value}. + + Retrieves all policy assignments that apply to a subscription. + + :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()' + 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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-03-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + 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 + + async def delete_by_id( + self, + policy_assignment_id: str, + **kwargs + ) -> "models.PolicyAssignment": + """This operation deletes the policy with the given ID. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid formats for {scope} are: '/providers/Microsoft.Management/managementGroups/{managementGroup}' (management group), '/subscriptions/{subscriptionId}' (subscription), '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' (resource group), or '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' (resource). + + Deletes a policy assignment. + + :param policy_assignment_id: The ID of the policy assignment to delete. Use the format + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + :type policy_assignment_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyAssignment or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-03-01" + + # 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'] = 'application/json' + + # Construct and send request + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('PolicyAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + delete_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + + async def create_by_id( + self, + policy_assignment_id: str, + parameters: "models.PolicyAssignment", + **kwargs + ) -> "models.PolicyAssignment": + """This operation creates or updates the policy assignment with the given ID. Policy assignments made on a scope apply to all resources contained in that scope. For example, when you assign a policy to a resource group that policy applies to all resources in the group. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + + Creates or updates a policy assignment. + + :param policy_assignment_id: The ID of the policy assignment to create. Use the format + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + :type policy_assignment_id: str + :param parameters: Parameters for policy assignment. + :type parameters: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyAssignment + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-03-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + + async def get_by_id( + self, + policy_assignment_id: str, + **kwargs + ) -> "models.PolicyAssignment": + """The operation retrieves the policy assignment with the given ID. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + + Retrieves the policy assignment with the given ID. + + :param policy_assignment_id: The ID of the policy assignment to get. Use the format + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + :type policy_assignment_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-03-01" + + # 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'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyAssignment', pipeline_response) + + if cls: + 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_async/_policy_definitions_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/aio/operations_async/_policy_definitions_operations_async.py new file mode 100644 index 000000000000..0ba194bda7ed --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/aio/operations_async/_policy_definitions_operations_async.py @@ -0,0 +1,632 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import 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 ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class PolicyDefinitionsOperations: + """PolicyDefinitionsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.policy.v2018_03_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def create_or_update( + self, + policy_definition_name: str, + parameters: "models.PolicyDefinition", + **kwargs + ) -> "models.PolicyDefinition": + """This operation creates or updates a policy definition in the given subscription with the given name. + + Creates or updates a policy definition in a subscription. + + :param policy_definition_name: The name of the policy definition to create. + :type policy_definition_name: str + :param parameters: The policy definition properties. + :type parameters: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-03-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + async def delete( + self, + policy_definition_name: str, + **kwargs + ) -> None: + """This operation deletes the policy definition in the given subscription with the given name. + + Deletes a policy definition in a subscription. + + :param policy_definition_name: The name of the policy definition to delete. + :type policy_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + async def get( + self, + policy_definition_name: str, + **kwargs + ) -> "models.PolicyDefinition": + """This operation retrieves the policy definition in the given subscription with the given name. + + Retrieves a policy definition in a subscription. + + :param policy_definition_name: The name of the policy definition to get. + :type policy_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-03-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + async def get_built_in( + self, + policy_definition_name: str, + **kwargs + ) -> "models.PolicyDefinition": + """This operation retrieves the built-in policy definition with the given name. + + Retrieves a built-in policy definition. + + :param policy_definition_name: The name of the built-in policy definition to get. + :type policy_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-03-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + async def create_or_update_at_management_group( + self, + policy_definition_name: str, + management_group_id: str, + parameters: "models.PolicyDefinition", + **kwargs + ) -> "models.PolicyDefinition": + """This operation creates or updates a policy definition in the given management group with the given name. + + Creates or updates a policy definition in a management group. + + :param policy_definition_name: The name of the policy definition to create. + :type policy_definition_name: str + :param management_group_id: The ID of the management group. + :type management_group_id: str + :param parameters: The policy definition properties. + :type parameters: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-03-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyDefinition', pipeline_response) + + if cls: + 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 + + async def delete_at_management_group( + self, + policy_definition_name: str, + management_group_id: str, + **kwargs + ) -> None: + """This operation deletes the policy definition in the given management group with the given name. + + Deletes a policy definition in a management group. + + :param policy_definition_name: The name of the policy definition to delete. + :type policy_definition_name: str + :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: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + async def get_at_management_group( + self, + policy_definition_name: str, + management_group_id: str, + **kwargs + ) -> "models.PolicyDefinition": + """This operation retrieves the policy definition in the given management group with the given name. + + Retrieve a policy definition in a management group. + + :param policy_definition_name: The name of the policy definition to get. + :type policy_definition_name: str + :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: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-03-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyDefinition', pipeline_response) + + if cls: + 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 + + def list( + self, + **kwargs + ) -> AsyncIterable["models.PolicyDefinitionListResult"]: + """This operation retrieves a list of all the policy definitions in a given subscription. + + Retrieves policy definitions in a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-03-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyDefinitionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions'} # type: ignore + + def list_built_in( + self, + **kwargs + ) -> AsyncIterable["models.PolicyDefinitionListResult"]: + """This operation retrieves a list of all the built-in policy definitions. + + Retrieve 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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-03-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyDefinitionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policyDefinitions'} # type: ignore + + def list_by_management_group( + self, + management_group_id: str, + **kwargs + ) -> AsyncIterable["models.PolicyDefinitionListResult"]: + """This operation retrieves a list of all the policy definitions in a given management group. + + Retrieve policy definitions in a 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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-03-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyDefinitionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/aio/operations_async/_policy_set_definitions_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/aio/operations_async/_policy_set_definitions_operations_async.py new file mode 100644 index 000000000000..1d4e11d422f2 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/aio/operations_async/_policy_set_definitions_operations_async.py @@ -0,0 +1,652 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import 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 ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class PolicySetDefinitionsOperations: + """PolicySetDefinitionsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.policy.v2018_03_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def create_or_update( + self, + policy_set_definition_name: str, + parameters: "models.PolicySetDefinition", + **kwargs + ) -> "models.PolicySetDefinition": + """This operation creates or updates a policy set definition in the given subscription with the given name. + + Creates or updates a policy set definition. + + :param policy_set_definition_name: The name of the policy set definition to create. + :type policy_set_definition_name: str + :param parameters: The policy set definition properties. + :type parameters: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicySetDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicySetDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicySetDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-03-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + async def delete( + self, + policy_set_definition_name: str, + **kwargs + ) -> None: + """This operation deletes the policy set definition in the given subscription with the given name. + + Deletes a policy set definition. + + :param policy_set_definition_name: The name of the policy set definition to delete. + :type policy_set_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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 = { + '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] + + # Construct and send request + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + async def get( + self, + policy_set_definition_name: str, + **kwargs + ) -> "models.PolicySetDefinition": + """This operation retrieves the policy set definition in the given subscription with the given name. + + Retrieves a policy set definition. + + :param policy_set_definition_name: The name of the policy set definition to get. + :type policy_set_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicySetDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicySetDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-03-01" + + # 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'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + async def get_built_in( + self, + policy_set_definition_name: str, + **kwargs + ) -> "models.PolicySetDefinition": + """This operation retrieves the built-in policy set definition with the given name. + + Retrieves a built in policy set definition. + + :param policy_set_definition_name: The name of the policy set definition to get. + :type policy_set_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicySetDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicySetDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-03-01" + + # 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'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + def list( + self, + **kwargs + ) -> AsyncIterable["models.PolicySetDefinitionListResult"]: + """This operation retrieves a list of all the policy set definitions in the given subscription. + + Retrieves 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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-03-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('PolicySetDefinitionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + 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 + + def list_built_in( + self, + **kwargs + ) -> AsyncIterable["models.PolicySetDefinitionListResult"]: + """This operation retrieves a list of all the built-in policy set definitions. + + Retrieves 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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-03-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('PolicySetDefinitionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + 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 + + async def create_or_update_at_management_group( + self, + policy_set_definition_name: str, + management_group_id: str, + parameters: "models.PolicySetDefinition", + **kwargs + ) -> "models.PolicySetDefinition": + """This operation creates or updates a policy set definition in the given management group with the given name. + + Creates or updates a policy set definition. + + :param policy_set_definition_name: The name of the policy set definition to create. + :type policy_set_definition_name: str + :param management_group_id: The ID of the management group. + :type management_group_id: str + :param parameters: The policy set definition properties. + :type parameters: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicySetDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicySetDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicySetDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-03-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + + if cls: + 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 + + async def delete_at_management_group( + self, + policy_set_definition_name: str, + management_group_id: str, + **kwargs + ) -> None: + """This operation deletes the policy set definition in the given management group with the given name. + + Deletes a policy set definition. + + :param policy_set_definition_name: The name of the policy set definition to delete. + :type policy_set_definition_name: str + :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: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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 = { + '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] + + # Construct and send request + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + async def get_at_management_group( + self, + policy_set_definition_name: str, + management_group_id: str, + **kwargs + ) -> "models.PolicySetDefinition": + """This operation retrieves the policy set definition in the given management group with the given name. + + Retrieves a policy set definition. + + :param policy_set_definition_name: The name of the policy set definition to get. + :type policy_set_definition_name: str + :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: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicySetDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicySetDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-03-01" + + # 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'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + + if cls: + 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 + + def list_by_management_group( + self, + management_group_id: str, + **kwargs + ) -> AsyncIterable["models.PolicySetDefinitionListResult"]: + """This operation retrieves a list of all the a policy set definition in the given management group. + + Retrieves all policy set definitions in 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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-03-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('PolicySetDefinitionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/models/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/models/__init__.py index 1a9eddc2a495..f9c468970ae3 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/models/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/models/__init__.py @@ -1,46 +1,47 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- try: - from ._models_py3 import ErrorResponse, ErrorResponseException + from ._models_py3 import ErrorResponse from ._models_py3 import PolicyAssignment + from ._models_py3 import PolicyAssignmentListResult from ._models_py3 import PolicyDefinition + from ._models_py3 import PolicyDefinitionListResult from ._models_py3 import PolicyDefinitionReference from ._models_py3 import PolicySetDefinition + from ._models_py3 import PolicySetDefinitionListResult from ._models_py3 import PolicySku except (SyntaxError, ImportError): - from ._models import ErrorResponse, ErrorResponseException - from ._models import PolicyAssignment - from ._models import PolicyDefinition - from ._models import PolicyDefinitionReference - from ._models import PolicySetDefinition - from ._models import PolicySku -from ._paged_models import PolicyAssignmentPaged -from ._paged_models import PolicyDefinitionPaged -from ._paged_models import PolicySetDefinitionPaged + from ._models import ErrorResponse # type: ignore + from ._models import PolicyAssignment # type: ignore + from ._models import PolicyAssignmentListResult # type: ignore + from ._models import PolicyDefinition # type: ignore + from ._models import PolicyDefinitionListResult # type: ignore + from ._models import PolicyDefinitionReference # type: ignore + from ._models import PolicySetDefinition # type: ignore + from ._models import PolicySetDefinitionListResult # type: ignore + from ._models import PolicySku # type: ignore + from ._policy_client_enums import ( - PolicyType, PolicyMode, + PolicyType, ) __all__ = [ - 'ErrorResponse', 'ErrorResponseException', + 'ErrorResponse', 'PolicyAssignment', + 'PolicyAssignmentListResult', 'PolicyDefinition', + 'PolicyDefinitionListResult', 'PolicyDefinitionReference', 'PolicySetDefinition', + 'PolicySetDefinitionListResult', 'PolicySku', - 'PolicyAssignmentPaged', - 'PolicyDefinitionPaged', - 'PolicySetDefinitionPaged', - 'PolicyType', 'PolicyMode', + 'PolicyType', ] 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 daa3d4d5a3ad..f81e3e433007 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 @@ -1,29 +1,17 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.serialization import Model -from msrest.exceptions import HttpOperationError +from azure.core.exceptions import HttpResponseError +import msrest.serialization -class CloudError(Model): - """CloudError. - """ - - _attribute_map = { - } - - -class ErrorResponse(Model): - """Error response indicates Azure Resource Manager is not able to process the - incoming request. The reason is provided in the error message. +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 @@ -39,35 +27,33 @@ class ErrorResponse(Model): 'error_message': {'key': 'errorMessage', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ErrorResponse, self).__init__(**kwargs) self.http_status = kwargs.get('http_status', None) self.error_code = kwargs.get('error_code', None) self.error_message = kwargs.get('error_message', None) -class ErrorResponseException(HttpOperationError): - """Server responsed with exception of type: 'ErrorResponse'. - - :param deserialize: A deserializer - :param response: Server response to be deserialized. - """ - - def __init__(self, deserialize, response, *args): - - super(ErrorResponseException, self).__init__(deserialize, response, 'ErrorResponse', *args) - - -class PolicyAssignment(Model): +class PolicyAssignment(msrest.serialization.Model): """The policy assignment. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. + :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 + :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 assigned. + :param 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 @@ -75,20 +61,10 @@ class PolicyAssignment(Model): :type not_scopes: list[str] :param parameters: Required if a parameter is used in policy rule. :type parameters: object - :param description: This message will be part of response in case of - policy violation. + :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: object - :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 - :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 """ _validation = { @@ -98,6 +74,10 @@ class PolicyAssignment(Model): } _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'sku': {'key': 'sku', 'type': 'PolicySku'}, 'display_name': {'key': 'properties.displayName', 'type': 'str'}, 'policy_definition_id': {'key': 'properties.policyDefinitionId', 'type': 'str'}, 'scope': {'key': 'properties.scope', 'type': 'str'}, @@ -105,14 +85,17 @@ class PolicyAssignment(Model): 'parameters': {'key': 'properties.parameters', 'type': 'object'}, 'description': {'key': 'properties.description', 'type': 'str'}, 'metadata': {'key': 'properties.metadata', 'type': 'object'}, - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'PolicySku'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(PolicyAssignment, self).__init__(**kwargs) + self.id = None + self.type = None + self.name = None + self.sku = kwargs.get('sku', None) self.display_name = kwargs.get('display_name', None) self.policy_definition_id = kwargs.get('policy_definition_id', None) self.scope = kwargs.get('scope', None) @@ -120,28 +103,48 @@ def __init__(self, **kwargs): self.parameters = kwargs.get('parameters', None) self.description = kwargs.get('description', None) self.metadata = kwargs.get('metadata', None) - self.id = None - self.type = None - self.name = None - self.sku = kwargs.get('sku', None) -class PolicyDefinition(Model): +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 + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[PolicyAssignment]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(PolicyAssignmentListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class PolicyDefinition(msrest.serialization.Model): """The policy definition. - Variables are only populated by the server, and will be ignored when - sending a request. - - :param 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. Possible values include: 'NotSpecified', 'Indexed', - 'All' - :type mode: str or - ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyMode + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The ID of the policy definition. + :vartype id: str + :ivar name: The name of the policy definition. + :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, + 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. + 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. @@ -152,13 +155,6 @@ class PolicyDefinition(Model): :type metadata: object :param parameters: Required if a parameter is used in policy rule. :type parameters: object - :ivar id: The ID of the policy definition. - :vartype id: str - :ivar name: The name of the policy definition. - :vartype name: str - :ivar type: The type of the resource - (Microsoft.Authorization/policyDefinitions). - :vartype type: str """ _validation = { @@ -168,6 +164,9 @@ class PolicyDefinition(Model): } _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, 'policy_type': {'key': 'properties.policyType', 'type': 'str'}, 'mode': {'key': 'properties.mode', 'type': 'str'}, 'display_name': {'key': 'properties.displayName', 'type': 'str'}, @@ -175,13 +174,16 @@ class PolicyDefinition(Model): 'policy_rule': {'key': 'properties.policyRule', 'type': 'object'}, 'metadata': {'key': 'properties.metadata', 'type': 'object'}, 'parameters': {'key': 'properties.parameters', 'type': 'object'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(PolicyDefinition, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None self.policy_type = kwargs.get('policy_type', None) self.mode = kwargs.get('mode', None) self.display_name = kwargs.get('display_name', None) @@ -189,16 +191,35 @@ def __init__(self, **kwargs): self.policy_rule = kwargs.get('policy_rule', None) self.metadata = kwargs.get('metadata', None) self.parameters = kwargs.get('parameters', None) - self.id = None - self.name = None - self.type = None -class PolicyDefinitionReference(Model): +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 + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[PolicyDefinition]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(PolicyDefinitionListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class PolicyDefinitionReference(msrest.serialization.Model): """The policy definition reference. - :param policy_definition_id: The ID of the policy definition or policy set - definition. + :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: object @@ -209,86 +230,106 @@ class PolicyDefinitionReference(Model): 'parameters': {'key': 'parameters', 'type': 'object'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(PolicyDefinitionReference, self).__init__(**kwargs) self.policy_definition_id = kwargs.get('policy_definition_id', None) self.parameters = kwargs.get('parameters', None) -class PolicySetDefinition(Model): +class PolicySetDefinition(msrest.serialization.Model): """The policy set definition. - Variables are only populated by the server, and will be ignored when - sending a request. - - All required parameters must be populated in order to send to Azure. + Variables are only populated by the server, and will be ignored when sending a request. - :param 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 + :ivar id: The ID of the policy set definition. + :vartype id: str + :ivar name: The name of the policy set definition. + :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, + 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: object - :param parameters: The policy set definition parameters that can be used - in policy definition references. - :type parameters: object - :param policy_definitions: Required. An array of policy definition + :param parameters: The policy set definition parameters that can be used in policy definition references. + :type parameters: object + :param policy_definitions: An array of policy definition references. :type policy_definitions: list[~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinitionReference] - :ivar id: The ID of the policy set definition. - :vartype id: str - :ivar name: The name of the policy set definition. - :vartype name: str - :ivar type: The type of the resource - (Microsoft.Authorization/policySetDefinitions). - :vartype type: str """ _validation = { - 'policy_definitions': {'required': True}, 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, } _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, 'policy_type': {'key': 'properties.policyType', 'type': 'str'}, 'display_name': {'key': 'properties.displayName', 'type': 'str'}, 'description': {'key': 'properties.description', 'type': 'str'}, 'metadata': {'key': 'properties.metadata', 'type': 'object'}, 'parameters': {'key': 'properties.parameters', 'type': 'object'}, 'policy_definitions': {'key': 'properties.policyDefinitions', 'type': '[PolicyDefinitionReference]'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(PolicySetDefinition, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None self.policy_type = kwargs.get('policy_type', None) self.display_name = kwargs.get('display_name', None) self.description = kwargs.get('description', None) self.metadata = kwargs.get('metadata', None) self.parameters = kwargs.get('parameters', None) self.policy_definitions = kwargs.get('policy_definitions', None) - self.id = None - self.name = None - self.type = None -class PolicySku(Model): +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 + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[PolicySetDefinition]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(PolicySetDefinitionListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class PolicySku(msrest.serialization.Model): """The policy sku. This property is optional, obsolete, and will be ignored. 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. + :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 @@ -303,7 +344,10 @@ class PolicySku(Model): 'tier': {'key': 'tier', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(PolicySku, self).__init__(**kwargs) - self.name = kwargs.get('name', None) + 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 f0ecf1435043..557851ff26aa 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 @@ -1,29 +1,21 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.serialization import Model -from msrest.exceptions import HttpOperationError +from typing import List, Optional, Union +from azure.core.exceptions import HttpResponseError +import msrest.serialization -class CloudError(Model): - """CloudError. - """ - - _attribute_map = { - } +from ._policy_client_enums import * -class ErrorResponse(Model): - """Error response indicates Azure Resource Manager is not able to process the - incoming request. The reason is provided in the error message. +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 @@ -39,35 +31,37 @@ class ErrorResponse(Model): 'error_message': {'key': 'errorMessage', 'type': 'str'}, } - def __init__(self, *, http_status: str=None, error_code: str=None, error_message: str=None, **kwargs) -> None: + def __init__( + self, + *, + http_status: Optional[str] = None, + error_code: Optional[str] = None, + error_message: Optional[str] = None, + **kwargs + ): super(ErrorResponse, self).__init__(**kwargs) self.http_status = http_status self.error_code = error_code self.error_message = error_message -class ErrorResponseException(HttpOperationError): - """Server responsed with exception of type: 'ErrorResponse'. - - :param deserialize: A deserializer - :param response: Server response to be deserialized. - """ - - def __init__(self, deserialize, response, *args): - - super(ErrorResponseException, self).__init__(deserialize, response, 'ErrorResponse', *args) - - -class PolicyAssignment(Model): +class PolicyAssignment(msrest.serialization.Model): """The policy assignment. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. + :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 + :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 assigned. + :param 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 @@ -75,20 +69,10 @@ class PolicyAssignment(Model): :type not_scopes: list[str] :param parameters: Required if a parameter is used in policy rule. :type parameters: object - :param description: This message will be part of response in case of - policy violation. + :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: object - :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 - :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 """ _validation = { @@ -98,6 +82,10 @@ class PolicyAssignment(Model): } _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'sku': {'key': 'sku', 'type': 'PolicySku'}, 'display_name': {'key': 'properties.displayName', 'type': 'str'}, 'policy_definition_id': {'key': 'properties.policyDefinitionId', 'type': 'str'}, 'scope': {'key': 'properties.scope', 'type': 'str'}, @@ -105,14 +93,26 @@ class PolicyAssignment(Model): 'parameters': {'key': 'properties.parameters', 'type': 'object'}, 'description': {'key': 'properties.description', 'type': 'str'}, 'metadata': {'key': 'properties.metadata', 'type': 'object'}, - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'PolicySku'}, } - def __init__(self, *, display_name: str=None, policy_definition_id: str=None, scope: str=None, not_scopes=None, parameters=None, description: str=None, metadata=None, sku=None, **kwargs) -> None: + def __init__( + self, + *, + sku: Optional["PolicySku"] = None, + display_name: Optional[str] = None, + policy_definition_id: Optional[str] = None, + scope: Optional[str] = None, + not_scopes: Optional[List[str]] = None, + parameters: Optional[object] = None, + description: Optional[str] = None, + metadata: Optional[object] = None, + **kwargs + ): super(PolicyAssignment, self).__init__(**kwargs) + self.id = None + self.type = None + self.name = None + self.sku = sku self.display_name = display_name self.policy_definition_id = policy_definition_id self.scope = scope @@ -120,28 +120,51 @@ def __init__(self, *, display_name: str=None, policy_definition_id: str=None, sc self.parameters = parameters self.description = description self.metadata = metadata - self.id = None - self.type = None - self.name = None - self.sku = sku -class PolicyDefinition(Model): +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 + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[PolicyAssignment]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["PolicyAssignment"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(PolicyAssignmentListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class PolicyDefinition(msrest.serialization.Model): """The policy definition. - Variables are only populated by the server, and will be ignored when - sending a request. - - :param 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. Possible values include: 'NotSpecified', 'Indexed', - 'All' - :type mode: str or - ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyMode + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The ID of the policy definition. + :vartype id: str + :ivar name: The name of the policy definition. + :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, + 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. + 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. @@ -152,13 +175,6 @@ class PolicyDefinition(Model): :type metadata: object :param parameters: Required if a parameter is used in policy rule. :type parameters: object - :ivar id: The ID of the policy definition. - :vartype id: str - :ivar name: The name of the policy definition. - :vartype name: str - :ivar type: The type of the resource - (Microsoft.Authorization/policyDefinitions). - :vartype type: str """ _validation = { @@ -168,6 +184,9 @@ class PolicyDefinition(Model): } _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, 'policy_type': {'key': 'properties.policyType', 'type': 'str'}, 'mode': {'key': 'properties.mode', 'type': 'str'}, 'display_name': {'key': 'properties.displayName', 'type': 'str'}, @@ -175,13 +194,24 @@ class PolicyDefinition(Model): 'policy_rule': {'key': 'properties.policyRule', 'type': 'object'}, 'metadata': {'key': 'properties.metadata', 'type': 'object'}, 'parameters': {'key': 'properties.parameters', 'type': 'object'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, } - def __init__(self, *, policy_type=None, mode=None, display_name: str=None, description: str=None, policy_rule=None, metadata=None, parameters=None, **kwargs) -> None: + def __init__( + self, + *, + policy_type: Optional[Union[str, "PolicyType"]] = None, + mode: Optional[Union[str, "PolicyMode"]] = None, + display_name: Optional[str] = None, + description: Optional[str] = None, + policy_rule: Optional[object] = None, + metadata: Optional[object] = None, + parameters: Optional[object] = None, + **kwargs + ): super(PolicyDefinition, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None self.policy_type = policy_type self.mode = mode self.display_name = display_name @@ -189,16 +219,38 @@ def __init__(self, *, policy_type=None, mode=None, display_name: str=None, descr self.policy_rule = policy_rule self.metadata = metadata self.parameters = parameters - self.id = None - self.name = None - self.type = None -class PolicyDefinitionReference(Model): +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 + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[PolicyDefinition]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["PolicyDefinition"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(PolicyDefinitionListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class PolicyDefinitionReference(msrest.serialization.Model): """The policy definition reference. - :param policy_definition_id: The ID of the policy definition or policy set - definition. + :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: object @@ -209,86 +261,119 @@ class PolicyDefinitionReference(Model): 'parameters': {'key': 'parameters', 'type': 'object'}, } - def __init__(self, *, policy_definition_id: str=None, parameters=None, **kwargs) -> None: + def __init__( + self, + *, + policy_definition_id: Optional[str] = None, + parameters: Optional[object] = None, + **kwargs + ): super(PolicyDefinitionReference, self).__init__(**kwargs) self.policy_definition_id = policy_definition_id self.parameters = parameters -class PolicySetDefinition(Model): +class PolicySetDefinition(msrest.serialization.Model): """The policy set definition. - Variables are only populated by the server, and will be ignored when - sending a request. - - All required parameters must be populated in order to send to Azure. + Variables are only populated by the server, and will be ignored when sending a request. - :param 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 + :ivar id: The ID of the policy set definition. + :vartype id: str + :ivar name: The name of the policy set definition. + :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, + 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: object - :param parameters: The policy set definition parameters that can be used - in policy definition references. - :type parameters: object - :param policy_definitions: Required. An array of policy definition + :param parameters: The policy set definition parameters that can be used in policy definition references. + :type parameters: object + :param policy_definitions: An array of policy definition references. :type policy_definitions: list[~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinitionReference] - :ivar id: The ID of the policy set definition. - :vartype id: str - :ivar name: The name of the policy set definition. - :vartype name: str - :ivar type: The type of the resource - (Microsoft.Authorization/policySetDefinitions). - :vartype type: str """ _validation = { - 'policy_definitions': {'required': True}, 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, } _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, 'policy_type': {'key': 'properties.policyType', 'type': 'str'}, 'display_name': {'key': 'properties.displayName', 'type': 'str'}, 'description': {'key': 'properties.description', 'type': 'str'}, 'metadata': {'key': 'properties.metadata', 'type': 'object'}, 'parameters': {'key': 'properties.parameters', 'type': 'object'}, 'policy_definitions': {'key': 'properties.policyDefinitions', 'type': '[PolicyDefinitionReference]'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, } - def __init__(self, *, policy_definitions, policy_type=None, display_name: str=None, description: str=None, metadata=None, parameters=None, **kwargs) -> None: + def __init__( + self, + *, + policy_type: Optional[Union[str, "PolicyType"]] = None, + display_name: Optional[str] = None, + description: Optional[str] = None, + metadata: Optional[object] = None, + parameters: Optional[object] = None, + policy_definitions: Optional[List["PolicyDefinitionReference"]] = None, + **kwargs + ): super(PolicySetDefinition, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None self.policy_type = policy_type self.display_name = display_name self.description = description self.metadata = metadata self.parameters = parameters self.policy_definitions = policy_definitions - self.id = None - self.name = None - self.type = None -class PolicySku(Model): +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 + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[PolicySetDefinition]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["PolicySetDefinition"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(PolicySetDefinitionListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class PolicySku(msrest.serialization.Model): """The policy sku. This property is optional, obsolete, and will be ignored. 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. + :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 @@ -303,7 +388,13 @@ class PolicySku(Model): 'tier': {'key': 'tier', 'type': 'str'}, } - def __init__(self, *, name: str, tier: str=None, **kwargs) -> None: + def __init__( + self, + *, + name: str, + tier: Optional[str] = None, + **kwargs + ): 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/_paged_models.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/models/_paged_models.py deleted file mode 100644 index fcb95b3a70bc..000000000000 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/models/_paged_models.py +++ /dev/null @@ -1,53 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.paging import Paged - - -class PolicyAssignmentPaged(Paged): - """ - A paging container for iterating over a list of :class:`PolicyAssignment ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[PolicyAssignment]'} - } - - def __init__(self, *args, **kwargs): - - super(PolicyAssignmentPaged, self).__init__(*args, **kwargs) -class PolicyDefinitionPaged(Paged): - """ - A paging container for iterating over a list of :class:`PolicyDefinition ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[PolicyDefinition]'} - } - - def __init__(self, *args, **kwargs): - - super(PolicyDefinitionPaged, self).__init__(*args, **kwargs) -class PolicySetDefinitionPaged(Paged): - """ - A paging container for iterating over a list of :class:`PolicySetDefinition ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[PolicySetDefinition]'} - } - - def __init__(self, *args, **kwargs): - - super(PolicySetDefinitionPaged, self).__init__(*args, **kwargs) 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 a9dcf44c1e7c..65c6d02a7e1c 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 @@ -1,26 +1,25 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from enum import Enum +class PolicyMode(str, Enum): + """The policy definition mode. Possible values are NotSpecified, Indexed, and All. + """ + + not_specified = "NotSpecified" + indexed = "Indexed" + all = "All" class PolicyType(str, Enum): + """The type of policy definition. Possible values are NotSpecified, BuiltIn, and Custom. + """ not_specified = "NotSpecified" built_in = "BuiltIn" custom = "Custom" - - -class PolicyMode(str, Enum): - - not_specified = "NotSpecified" - indexed = "Indexed" - all = "All" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/operations/__init__.py index c7d7b8eb9d97..4583d62b03a4 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/operations/__init__.py @@ -1,12 +1,9 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from ._policy_assignments_operations import PolicyAssignmentsOperations 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 21ca38e5a655..e21096e99ba3 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 @@ -1,778 +1,670 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class PolicyAssignmentsOperations(object): """PolicyAssignmentsOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.policy.v2018_03_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for the operation. Constant value: "2018-03-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2018-03-01" - - self.config = config + self._config = config def delete( - self, scope, policy_assignment_name, custom_headers=None, raw=False, **operation_config): - """Deletes a policy assignment. - - This operation deletes a policy assignment, given its name and the - scope it was created in. The scope of a policy assignment is the part - of its ID preceding - '/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. - - :param scope: The scope of the policy assignment. Valid scopes are: - management group (format: - '/providers/Microsoft.Management/managementGroups/{managementGroup}'), - subscription (format: '/subscriptions/{subscriptionId}'), resource - group (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', - or resource (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' + self, + scope, # type: str + policy_assignment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyAssignment" + """This operation deletes a policy assignment, given its name and the scope it was created in. The scope of a policy assignment is the part of its ID preceding '/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + + Deletes a policy assignment. + + :param scope: The scope of the policy assignment. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. :type scope: str - :param policy_assignment_name: The name of the policy assignment to - delete. + :param policy_assignment_name: The name of the policy assignment to delete. :type policy_assignment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyAssignment or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyAssignment or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyAssignment or None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-03-01" + # Construct URL - url = self.delete.metadata['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') + 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('PolicyAssignment', response) + deserialized = self._deserialize('PolicyAssignment', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} + delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore def create( - self, scope, policy_assignment_name, parameters, custom_headers=None, raw=False, **operation_config): - """Creates or updates a policy assignment. - - This operation creates or updates a policy assignment with the given - scope and name. Policy assignments apply to all resources contained - within their scope. For example, when you assign a policy at resource - group scope, that policy applies to all resources in the group. - - :param scope: The scope of the policy assignment. Valid scopes are: - management group (format: - '/providers/Microsoft.Management/managementGroups/{managementGroup}'), - subscription (format: '/subscriptions/{subscriptionId}'), resource - group (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', - or resource (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' + self, + scope, # type: str + policy_assignment_name, # type: str + parameters, # type: "models.PolicyAssignment" + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyAssignment" + """This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + + Creates or updates a policy assignment. + + :param scope: The scope of the policy assignment. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. :type scope: str :param policy_assignment_name: The name of the policy assignment. :type policy_assignment_name: str :param parameters: Parameters for the policy assignment. - :type parameters: - ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyAssignment - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyAssignment or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyAssignment or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :type parameters: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyAssignment + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-03-01" + content_type = kwargs.pop("content_type", "application/json") + # Construct URL - url = self.create.metadata['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') + 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'PolicyAssignment') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 201: - deserialized = self._deserialize('PolicyAssignment', response) + deserialized = self._deserialize('PolicyAssignment', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} + create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore def get( - self, scope, policy_assignment_name, custom_headers=None, raw=False, **operation_config): - """Retrieves a policy assignment. - - This operation retrieves a single policy assignment, given its name and - the scope it was created at. - - :param scope: The scope of the policy assignment. Valid scopes are: - management group (format: - '/providers/Microsoft.Management/managementGroups/{managementGroup}'), - subscription (format: '/subscriptions/{subscriptionId}'), resource - group (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', - or resource (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' + self, + scope, # type: str + policy_assignment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyAssignment" + """This operation retrieves a single policy assignment, given its name and the scope it was created at. + + Retrieves a policy assignment. + + :param scope: The scope of the policy assignment. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. :type scope: str - :param policy_assignment_name: The name of the policy assignment to - get. + :param policy_assignment_name: The name of the policy assignment to get. :type policy_assignment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyAssignment or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyAssignment or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-03-01" + # Construct URL - url = self.get.metadata['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') + 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('PolicyAssignment', response) + deserialized = self._deserialize('PolicyAssignment', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} + get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore def list_for_resource_group( - self, resource_group_name, filter=None, custom_headers=None, raw=False, **operation_config): - """Retrieves all policy assignments that apply to a resource group. - - This operation retrieves the list of all policy assignments associated - with the given resource group in the given subscription that match the - optional given $filter. Valid values for $filter are: 'atScope()' or - 'policyDefinitionId eq '{value}''. If $filter is not provided, the - unfiltered list includes all policy assignments associated with the - resource group, including those that apply directly or apply from - containing scopes, as well as any applied to resources contained within - the resource group. If $filter=atScope() is provided, the returned list - includes all policy assignments that apply to the resource group, which - is everything in the unfiltered list except those applied to resources - contained within the resource group. If $filter=policyDefinitionId eq - '{value}' is provided, the returned list includes all policy - assignments of the policy definition whose id is {value} that apply to - the resource group. - - :param resource_group_name: The name of the resource group that - contains policy assignments. + self, + resource_group_name, # type: str + filter=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.PolicyAssignmentListResult"] + """This operation retrieves the list of all policy assignments associated with the given resource group in the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource group, including those that apply directly or apply from containing scopes, as well as any applied to resources contained within the resource group. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource group, which is everything in the unfiltered list except those applied to resources contained within the resource group. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource group. + + Retrieves all policy assignments that apply to a resource group. + + :param resource_group_name: The name of the resource group that contains policy assignments. :type resource_group_name: str - :param filter: The filter to apply on the operation. Valid values for - $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If - $filter is not provided, no filtering is performed. + :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()' + or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. :type filter: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of PolicyAssignment - :rtype: - ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyAssignmentPaged[~azure.mgmt.resource.policy.v2018_03_01.models.PolicyAssignment] - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-03-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_for_resource_group.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) - - return response + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.PolicyAssignmentPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list_for_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments'} + return ItemPaged( + get_next, extract_data + ) + list_for_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments'} # type: ignore def list_for_resource( - self, resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, filter=None, custom_headers=None, raw=False, **operation_config): - """Retrieves all policy assignments that apply to a resource. - - This operation retrieves the list of all policy assignments associated - with the specified resource in the given resource group and - subscription that match the optional given $filter. Valid values for - $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If - $filter is not provided, the unfiltered list includes all policy - assignments associated with the resource, including those that apply - directly or from all containing scopes, as well as any applied to - resources contained within the resource. If $filter=atScope() is - provided, the returned list includes all policy assignments that apply - to the resource, which is everything in the unfiltered list except - those applied to resources contained within the resource. If - $filter=policyDefinitionId eq '{value}' is provided, the returned list - includes all policy assignments of the policy definition whose id is - {value} that apply to the resource. Three parameters plus the resource - name are used to identify a specific resource. If the resource is not - part of a parent resource (the more common case), the parent resource - path should not be provided (or provided as ''). For example a web app - could be specified as ({resourceProviderNamespace} == 'Microsoft.Web', - {parentResourcePath} == '', {resourceType} == 'sites', {resourceName} - == 'MyWebApp'). If the resource is part of a parent resource, then all - parameters should be provided. For example a virtual machine DNS name - could be specified as ({resourceProviderNamespace} == - 'Microsoft.Compute', {parentResourcePath} == - 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames', - {resourceName} == 'MyComputerName'). A convenient alternative to - providing the namespace and type name separately is to provide both in - the {resourceType} parameter, format: ({resourceProviderNamespace} == - '', {parentResourcePath} == '', {resourceType} == - 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). - - :param resource_group_name: The name of the resource group containing - the resource. + self, + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + filter=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.PolicyAssignmentListResult"] + """This operation retrieves the list of all policy assignments associated with the specified resource in the given resource group and subscription that match the optional given $filter. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource, including those that apply directly or from all containing scopes, as well as any applied to resources contained within the resource. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource, which is everything in the unfiltered list except those applied to resources contained within the resource. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource. Three parameters plus the resource name are used to identify a specific resource. If the resource is not part of a parent resource (the more common case), the parent resource path should not be provided (or provided as ''). For example a web app could be specified as ({resourceProviderNamespace} == 'Microsoft.Web', {parentResourcePath} == '', {resourceType} == 'sites', {resourceName} == 'MyWebApp'). If the resource is part of a parent resource, then all parameters should be provided. For example a virtual machine DNS name could be specified as ({resourceProviderNamespace} == 'Microsoft.Compute', {parentResourcePath} == 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames', {resourceName} == 'MyComputerName'). A convenient alternative to providing the namespace and type name separately is to provide both in the {resourceType} parameter, format: ({resourceProviderNamespace} == '', {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). + + Retrieves all policy assignments that apply to a resource. + + :param resource_group_name: The name of the resource group containing the resource. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource - provider. For example, the namespace of a virtual machine is - Microsoft.Compute (from Microsoft.Compute/virtualMachines) + :param resource_provider_namespace: The namespace of the resource provider. For example, the + namespace of a virtual machine is Microsoft.Compute (from Microsoft.Compute/virtualMachines). :type resource_provider_namespace: str - :param parent_resource_path: The parent resource path. Use empty - string if there is none. + :param parent_resource_path: The parent resource path. Use empty string if there is none. :type parent_resource_path: str - :param resource_type: The resource type name. For example the type - name of a web app is 'sites' (from Microsoft.Web/sites). + :param resource_type: The resource type name. For example the type name of a web app is 'sites' + (from Microsoft.Web/sites). :type resource_type: str :param resource_name: The name of the resource. :type resource_name: str - :param filter: The filter to apply on the operation. Valid values for - $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If - $filter is not provided, no filtering is performed. + :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()' + or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. :type filter: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of PolicyAssignment - :rtype: - ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyAssignmentPaged[~azure.mgmt.resource.policy.v2018_03_01.models.PolicyAssignment] - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-03-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_for_resource.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.PolicyAssignmentPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_for_resource.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments'} + 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 def list( - self, filter=None, custom_headers=None, raw=False, **operation_config): - """Retrieves all policy assignments that apply to a subscription. - - This operation retrieves the list of all policy assignments associated - with the given subscription that match the optional given $filter. - Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq - '{value}''. If $filter is not provided, the unfiltered list includes - all policy assignments associated with the subscription, including - those that apply directly or from management groups that contain the - given subscription, as well as any applied to objects contained within - the subscription. If $filter=atScope() is provided, the returned list - includes all policy assignments that apply to the subscription, which - is everything in the unfiltered list except those applied to objects - contained within the subscription. If $filter=policyDefinitionId eq - '{value}' is provided, the returned list includes all policy - assignments of the policy definition whose id is {value}. - - :param filter: The filter to apply on the operation. Valid values for - $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If - $filter is not provided, no filtering is performed. + self, + filter=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.PolicyAssignmentListResult"] + """This operation retrieves the list of all policy assignments associated with the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the subscription, including those that apply directly or from management groups that contain the given subscription, as well as any applied to objects contained within the subscription. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the subscription, which is everything in the unfiltered list except those applied to objects contained within the subscription. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value}. + + Retrieves all policy assignments that apply to a subscription. + + :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()' + or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. :type filter: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of PolicyAssignment - :rtype: - ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyAssignmentPaged[~azure.mgmt.resource.policy.v2018_03_01.models.PolicyAssignment] - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-03-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['url'] + url = self.list.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_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 = {} + 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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) - - return response + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.PolicyAssignmentPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments'} # type: ignore def delete_by_id( - self, policy_assignment_id, custom_headers=None, raw=False, **operation_config): - """Deletes a policy assignment. - - This operation deletes the policy with the given ID. Policy assignment - IDs have this format: - '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. - Valid formats for {scope} are: - '/providers/Microsoft.Management/managementGroups/{managementGroup}' - (management group), '/subscriptions/{subscriptionId}' (subscription), - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' - (resource group), or - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' - (resource). - - :param policy_assignment_id: The ID of the policy assignment to - delete. Use the format + self, + policy_assignment_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyAssignment" + """This operation deletes the policy with the given ID. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid formats for {scope} are: '/providers/Microsoft.Management/managementGroups/{managementGroup}' (management group), '/subscriptions/{subscriptionId}' (subscription), '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' (resource group), or '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' (resource). + + Deletes a policy assignment. + + :param policy_assignment_id: The ID of the policy assignment to delete. Use the format '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. :type policy_assignment_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyAssignment or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyAssignment or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyAssignment or None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-03-01" + # Construct URL - url = self.delete_by_id.metadata['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) + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('PolicyAssignment', response) + deserialized = self._deserialize('PolicyAssignment', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - delete_by_id.metadata = {'url': '/{policyAssignmentId}'} + delete_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore def create_by_id( - self, policy_assignment_id, parameters, custom_headers=None, raw=False, **operation_config): - """Creates or updates a policy assignment. - - This operation creates or updates the policy assignment with the given - ID. Policy assignments made on a scope apply to all resources contained - in that scope. For example, when you assign a policy to a resource - group that policy applies to all resources in the group. Policy - assignment IDs have this format: - '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. - Valid scopes are: management group (format: - '/providers/Microsoft.Management/managementGroups/{managementGroup}'), - subscription (format: '/subscriptions/{subscriptionId}'), resource - group (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', - or resource (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. - - :param policy_assignment_id: The ID of the policy assignment to - create. Use the format + self, + policy_assignment_id, # type: str + parameters, # type: "models.PolicyAssignment" + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyAssignment" + """This operation creates or updates the policy assignment with the given ID. Policy assignments made on a scope apply to all resources contained in that scope. For example, when you assign a policy to a resource group that policy applies to all resources in the group. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + + Creates or updates a policy assignment. + + :param policy_assignment_id: The ID of the policy assignment to create. Use the format '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. :type policy_assignment_id: str :param parameters: Parameters for policy assignment. - :type parameters: - ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyAssignment - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyAssignment or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyAssignment or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :type parameters: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyAssignment + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-03-01" + content_type = kwargs.pop("content_type", "application/json") + # Construct URL - url = self.create_by_id.metadata['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) + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'PolicyAssignment') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 201: - deserialized = self._deserialize('PolicyAssignment', response) + deserialized = self._deserialize('PolicyAssignment', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create_by_id.metadata = {'url': '/{policyAssignmentId}'} + create_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore def get_by_id( - self, policy_assignment_id, custom_headers=None, raw=False, **operation_config): - """Retrieves the policy assignment with the given ID. - - The operation retrieves the policy assignment with the given ID. Policy - assignment IDs have this format: - '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. - Valid scopes are: management group (format: - '/providers/Microsoft.Management/managementGroups/{managementGroup}'), - subscription (format: '/subscriptions/{subscriptionId}'), resource - group (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', - or resource (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. - - :param policy_assignment_id: The ID of the policy assignment to get. - Use the format + self, + policy_assignment_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyAssignment" + """The operation retrieves the policy assignment with the given ID. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + + Retrieves the policy assignment with the given ID. + + :param policy_assignment_id: The ID of the policy assignment to get. Use the format '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. :type policy_assignment_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyAssignment or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyAssignment or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-03-01" + # Construct URL - url = self.get_by_id.metadata['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) + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('PolicyAssignment', response) + deserialized = self._deserialize('PolicyAssignment', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/{policyAssignmentId}'} + 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 80cd5acd0fc0..d97d88e0324e 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 @@ -1,686 +1,646 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class PolicyDefinitionsOperations(object): """PolicyDefinitionsOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.policy.v2018_03_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for the operation. Constant value: "2018-03-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2018-03-01" - - self.config = config + self._config = config def create_or_update( - self, policy_definition_name, parameters, custom_headers=None, raw=False, **operation_config): - """Creates or updates a policy definition in a subscription. + self, + policy_definition_name, # type: str + parameters, # type: "models.PolicyDefinition" + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyDefinition" + """This operation creates or updates a policy definition in the given subscription with the given name. - This operation creates or updates a policy definition in the given - subscription with the given name. + Creates or updates a policy definition in a subscription. - :param policy_definition_name: The name of the policy definition to - create. + :param policy_definition_name: The name of the policy definition to create. :type policy_definition_name: str :param parameters: The policy definition properties. - :type parameters: - ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinition - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyDefinition or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinition or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :type parameters: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinition + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-03-01" + content_type = kwargs.pop("content_type", "application/json") + # Construct URL - url = self.create_or_update.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'PolicyDefinition') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [201]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 201: - deserialized = self._deserialize('PolicyDefinition', response) + deserialized = self._deserialize('PolicyDefinition', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore def delete( - self, policy_definition_name, custom_headers=None, raw=False, **operation_config): - """Deletes a policy definition in a subscription. + self, + policy_definition_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """This operation deletes the policy definition in the given subscription with the given name. - This operation deletes the policy definition in the given subscription - with the given name. + Deletes a policy definition in a subscription. - :param policy_definition_name: The name of the policy definition to - delete. + :param policy_definition_name: The name of the policy definition to delete. :type policy_definition_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-03-01" + # Construct URL - url = self.delete.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} + delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore def get( - self, policy_definition_name, custom_headers=None, raw=False, **operation_config): - """Retrieves a policy definition in a subscription. + self, + policy_definition_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyDefinition" + """This operation retrieves the policy definition in the given subscription with the given name. - This operation retrieves the policy definition in the given - subscription with the given name. + Retrieves a policy definition in a subscription. - :param policy_definition_name: The name of the policy definition to - get. + :param policy_definition_name: The name of the policy definition to get. :type policy_definition_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyDefinition or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinition or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinition + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-03-01" + # Construct URL - url = self.get.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('PolicyDefinition', response) + deserialized = self._deserialize('PolicyDefinition', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore def get_built_in( - self, policy_definition_name, custom_headers=None, raw=False, **operation_config): - """Retrieves a built-in policy definition. + self, + policy_definition_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyDefinition" + """This operation retrieves the built-in policy definition with the given name. - This operation retrieves the built-in policy definition with the given - name. + Retrieves a built-in policy definition. - :param policy_definition_name: The name of the built-in policy - definition to get. + :param policy_definition_name: The name of the built-in policy definition to get. :type policy_definition_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyDefinition or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinition or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinition + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-03-01" + # Construct URL - url = self.get_built_in.metadata['url'] + url = self.get_built_in.metadata['url'] # type: ignore path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str') + 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('PolicyDefinition', response) + deserialized = self._deserialize('PolicyDefinition', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} + get_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore def create_or_update_at_management_group( - self, policy_definition_name, parameters, management_group_id, custom_headers=None, raw=False, **operation_config): - """Creates or updates a policy definition in a management group. - - This operation creates or updates a policy definition in the given - management group with the given name. - - :param policy_definition_name: The name of the policy definition to - create. + self, + policy_definition_name, # type: str + management_group_id, # type: str + parameters, # type: "models.PolicyDefinition" + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyDefinition" + """This operation creates or updates a policy definition in the given management group with the given name. + + Creates or updates a policy definition in a management group. + + :param policy_definition_name: The name of the policy definition to create. :type policy_definition_name: str - :param parameters: The policy definition properties. - :type parameters: - ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinition :param management_group_id: The ID of the management group. :type management_group_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyDefinition or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinition or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :param parameters: The policy definition properties. + :type parameters: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinition + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-03-01" + content_type = kwargs.pop("content_type", "application/json") + # Construct URL - url = self.create_or_update_at_management_group.metadata['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') + 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'PolicyDefinition') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [201]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 201: - deserialized = self._deserialize('PolicyDefinition', response) + deserialized = self._deserialize('PolicyDefinition', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + 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}'} + create_or_update_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore def delete_at_management_group( - self, policy_definition_name, management_group_id, custom_headers=None, raw=False, **operation_config): - """Deletes a policy definition in a management group. + self, + policy_definition_name, # type: str + management_group_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """This operation deletes the policy definition in the given management group with the given name. - This operation deletes the policy definition in the given management - group with the given name. + Deletes a policy definition in a management group. - :param policy_definition_name: The name of the policy definition to - delete. + :param policy_definition_name: The name of the policy definition to delete. :type policy_definition_name: str :param management_group_id: The ID of the management group. :type management_group_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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'] + 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') + 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} + if cls: + return cls(pipeline_response, None, {}) + + delete_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore def get_at_management_group( - self, policy_definition_name, management_group_id, custom_headers=None, raw=False, **operation_config): - """Retrieve a policy definition in a management group. + self, + policy_definition_name, # type: str + management_group_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyDefinition" + """This operation retrieves the policy definition in the given management group with the given name. - This operation retrieves the policy definition in the given management - group with the given name. + Retrieve a policy definition in a management group. - :param policy_definition_name: The name of the policy definition to - get. + :param policy_definition_name: The name of the policy definition to get. :type policy_definition_name: str :param management_group_id: The ID of the management group. :type management_group_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyDefinition or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinition or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinition + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-03-01" + # Construct URL - url = self.get_at_management_group.metadata['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') + 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('PolicyDefinition', response) + deserialized = self._deserialize('PolicyDefinition', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} + get_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore def list( - self, custom_headers=None, raw=False, **operation_config): - """Retrieves policy definitions in a subscription. - - This operation retrieves a list of all the policy definitions in a - given subscription. - - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of PolicyDefinition - :rtype: - ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinitionPaged[~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinition] - :raises: :class:`CloudError` + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.PolicyDefinitionListResult"] + """This operation retrieves a list of all the policy definitions in a given subscription. + + Retrieves policy definitions in a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-03-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['url'] + url = self.list.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyDefinitionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.PolicyDefinitionPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions'} # type: ignore def list_built_in( - self, custom_headers=None, raw=False, **operation_config): - """Retrieve built-in policy definitions. - - This operation retrieves a list of all the built-in policy definitions. - - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of PolicyDefinition - :rtype: - ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinitionPaged[~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinition] - :raises: :class:`CloudError` + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.PolicyDefinitionListResult"] + """This operation retrieves a list of all the built-in policy definitions. + + Retrieve 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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-03-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_built_in.metadata['url'] - + url = self.list_built_in.metadata['url'] # type: ignore # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyDefinitionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.PolicyDefinitionPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policyDefinitions'} + return ItemPaged( + get_next, extract_data + ) + list_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policyDefinitions'} # type: ignore def list_by_management_group( - self, management_group_id, custom_headers=None, raw=False, **operation_config): - """Retrieve policy definitions in a management group. + self, + management_group_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.PolicyDefinitionListResult"] + """This operation retrieves a list of all the policy definitions in a given management group. - This operation retrieves a list of all the policy definitions in a - given management group. + Retrieve policy definitions in a management group. :param management_group_id: The ID of the management group. :type management_group_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of PolicyDefinition - :rtype: - ~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinitionPaged[~azure.mgmt.resource.policy.v2018_03_01.models.PolicyDefinition] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-03-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_by_management_group.metadata['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') + 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyDefinitionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.PolicyDefinitionPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_by_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions'} + return ItemPaged( + get_next, extract_data + ) + list_by_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions'} # type: ignore 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 25ff8e352860..955723fe29cd 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 @@ -1,680 +1,666 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class PolicySetDefinitionsOperations(object): """PolicySetDefinitionsOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.policy.v2018_03_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for the operation. Constant value: "2018-03-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2018-03-01" - - self.config = config + self._config = config def create_or_update( - self, policy_set_definition_name, parameters, custom_headers=None, raw=False, **operation_config): - """Creates or updates a policy set definition. + self, + policy_set_definition_name, # type: str + parameters, # type: "models.PolicySetDefinition" + **kwargs # type: Any + ): + # type: (...) -> "models.PolicySetDefinition" + """This operation creates or updates a policy set definition in the given subscription with the given name. - This operation creates or updates a policy set definition in the given - subscription with the given name. + Creates or updates a policy set definition. - :param policy_set_definition_name: The name of the policy set - definition to create. + :param policy_set_definition_name: The name of the policy set definition to create. :type policy_set_definition_name: str :param parameters: The policy set definition properties. - :type parameters: - ~azure.mgmt.resource.policy.v2018_03_01.models.PolicySetDefinition - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicySetDefinition or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2018_03_01.models.PolicySetDefinition or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :type parameters: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicySetDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicySetDefinition + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicySetDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-03-01" + content_type = kwargs.pop("content_type", "application/json") + # Construct URL - url = self.create_or_update.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'PolicySetDefinition') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('PolicySetDefinition', response) + deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('PolicySetDefinition', response) + deserialized = self._deserialize('PolicySetDefinition', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore def delete( - self, policy_set_definition_name, custom_headers=None, raw=False, **operation_config): - """Deletes a policy set definition. + self, + policy_set_definition_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """This operation deletes the policy set definition in the given subscription with the given name. - This operation deletes the policy set definition in the given - subscription with the given name. + Deletes a policy set definition. - :param policy_set_definition_name: The name of the policy set - definition to delete. + :param policy_set_definition_name: The name of the policy set definition to delete. :type policy_set_definition_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-03-01" + # Construct URL - url = self.delete.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} + delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore def get( - self, policy_set_definition_name, custom_headers=None, raw=False, **operation_config): - """Retrieves a policy set definition. + self, + policy_set_definition_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.PolicySetDefinition" + """This operation retrieves the policy set definition in the given subscription with the given name. - This operation retrieves the policy set definition in the given - subscription with the given name. + Retrieves a policy set definition. - :param policy_set_definition_name: The name of the policy set - definition to get. + :param policy_set_definition_name: The name of the policy set definition to get. :type policy_set_definition_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicySetDefinition or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2018_03_01.models.PolicySetDefinition or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicySetDefinition + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicySetDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-03-01" + # Construct URL - url = self.get.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('PolicySetDefinition', response) + deserialized = self._deserialize('PolicySetDefinition', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore def get_built_in( - self, policy_set_definition_name, custom_headers=None, raw=False, **operation_config): - """Retrieves a built in policy set definition. + self, + policy_set_definition_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.PolicySetDefinition" + """This operation retrieves the built-in policy set definition with the given name. - This operation retrieves the built-in policy set definition with the - given name. + Retrieves a built in policy set definition. - :param policy_set_definition_name: The name of the policy set - definition to get. + :param policy_set_definition_name: The name of the policy set definition to get. :type policy_set_definition_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicySetDefinition or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2018_03_01.models.PolicySetDefinition or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicySetDefinition + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicySetDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-03-01" + # Construct URL - url = self.get_built_in.metadata['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') + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('PolicySetDefinition', response) + deserialized = self._deserialize('PolicySetDefinition', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} + get_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore def list( - self, custom_headers=None, raw=False, **operation_config): - """Retrieves the policy set definitions for a subscription. - - This operation retrieves a list of all the policy set definitions in - the given subscription. - - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of PolicySetDefinition - :rtype: - ~azure.mgmt.resource.policy.v2018_03_01.models.PolicySetDefinitionPaged[~azure.mgmt.resource.policy.v2018_03_01.models.PolicySetDefinition] - :raises: - :class:`ErrorResponseException` + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.PolicySetDefinitionListResult"] + """This operation retrieves a list of all the policy set definitions in the given subscription. + + Retrieves 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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-03-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['url'] + url = self.list.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('PolicySetDefinitionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) - - return response + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.PolicySetDefinitionPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions'} # type: ignore def list_built_in( - self, custom_headers=None, raw=False, **operation_config): - """Retrieves built-in policy set definitions. - - This operation retrieves a list of all the built-in policy set - definitions. - - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of PolicySetDefinition - :rtype: - ~azure.mgmt.resource.policy.v2018_03_01.models.PolicySetDefinitionPaged[~azure.mgmt.resource.policy.v2018_03_01.models.PolicySetDefinition] - :raises: - :class:`ErrorResponseException` + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.PolicySetDefinitionListResult"] + """This operation retrieves a list of all the built-in policy set definitions. + + Retrieves 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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-03-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_built_in.metadata['url'] - + url = self.list_built_in.metadata['url'] # type: ignore # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('PolicySetDefinitionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) - - return response + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.PolicySetDefinitionPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policySetDefinitions'} + return ItemPaged( + get_next, extract_data + ) + list_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policySetDefinitions'} # type: ignore def create_or_update_at_management_group( - self, policy_set_definition_name, parameters, management_group_id, custom_headers=None, raw=False, **operation_config): - """Creates or updates a policy set definition. - - This operation creates or updates a policy set definition in the given - management group with the given name. - - :param policy_set_definition_name: The name of the policy set - definition to create. + self, + policy_set_definition_name, # type: str + management_group_id, # type: str + parameters, # type: "models.PolicySetDefinition" + **kwargs # type: Any + ): + # type: (...) -> "models.PolicySetDefinition" + """This operation creates or updates a policy set definition in the given management group with the given name. + + Creates or updates a policy set definition. + + :param policy_set_definition_name: The name of the policy set definition to create. :type policy_set_definition_name: str - :param parameters: The policy set definition properties. - :type parameters: - ~azure.mgmt.resource.policy.v2018_03_01.models.PolicySetDefinition :param management_group_id: The ID of the management group. :type management_group_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicySetDefinition or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2018_03_01.models.PolicySetDefinition or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :param parameters: The policy set definition properties. + :type parameters: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicySetDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicySetDefinition + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicySetDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-03-01" + content_type = kwargs.pop("content_type", "application/json") + # Construct URL - url = self.create_or_update_at_management_group.metadata['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') + 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'PolicySetDefinition') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('PolicySetDefinition', response) + deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('PolicySetDefinition', response) + deserialized = self._deserialize('PolicySetDefinition', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + 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}'} + create_or_update_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore def delete_at_management_group( - self, policy_set_definition_name, management_group_id, custom_headers=None, raw=False, **operation_config): - """Deletes a policy set definition. + self, + policy_set_definition_name, # type: str + management_group_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """This operation deletes the policy set definition in the given management group with the given name. - This operation deletes the policy set definition in the given - management group with the given name. + Deletes a policy set definition. - :param policy_set_definition_name: The name of the policy set - definition to delete. + :param policy_set_definition_name: The name of the policy set definition to delete. :type policy_set_definition_name: str :param management_group_id: The ID of the management group. :type management_group_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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'] + 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') + 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} + delete_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore def get_at_management_group( - self, policy_set_definition_name, management_group_id, custom_headers=None, raw=False, **operation_config): - """Retrieves a policy set definition. + self, + policy_set_definition_name, # type: str + management_group_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.PolicySetDefinition" + """This operation retrieves the policy set definition in the given management group with the given name. - This operation retrieves the policy set definition in the given - management group with the given name. + Retrieves a policy set definition. - :param policy_set_definition_name: The name of the policy set - definition to get. + :param policy_set_definition_name: The name of the policy set definition to get. :type policy_set_definition_name: str :param management_group_id: The ID of the management group. :type management_group_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicySetDefinition or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2018_03_01.models.PolicySetDefinition or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_03_01.models.PolicySetDefinition + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicySetDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-03-01" + # Construct URL - url = self.get_at_management_group.metadata['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') + 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('PolicySetDefinition', response) + deserialized = self._deserialize('PolicySetDefinition', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} + get_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore def list_by_management_group( - self, management_group_id, custom_headers=None, raw=False, **operation_config): - """Retrieves all policy set definitions in management group. + self, + management_group_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.PolicySetDefinitionListResult"] + """This operation retrieves a list of all the a policy set definition in the given management group. - This operation retrieves a list of all the a policy set definition in - the given management group. + Retrieves all policy set definitions in management group. :param management_group_id: The ID of the management group. :type management_group_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of PolicySetDefinition - :rtype: - ~azure.mgmt.resource.policy.v2018_03_01.models.PolicySetDefinitionPaged[~azure.mgmt.resource.policy.v2018_03_01.models.PolicySetDefinition] - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-03-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_by_management_group.metadata['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') + 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('PolicySetDefinitionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) - - return response + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.PolicySetDefinitionPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list_by_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions'} + return ItemPaged( + get_next, extract_data + ) + list_by_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/py.typed b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file 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 deleted file mode 100644 index 89036952dd3c..000000000000 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_03_01/version.py +++ /dev/null @@ -1,13 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -VERSION = "2018-03-01" - 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 56bf47bfb9e4..e4bba9352a5c 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 @@ -1,19 +1,16 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._configuration import PolicyClientConfiguration from ._policy_client import PolicyClient -__all__ = ['PolicyClient', 'PolicyClientConfiguration'] - -from .version import VERSION - -__version__ = VERSION +__all__ = ['PolicyClient'] +try: + from ._patch import patch_sdk + patch_sdk() +except ImportError: + pass 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 ede4f42045d0..bf83bd26cce6 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 @@ -1,48 +1,69 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrestazure import AzureConfiguration -from .version import VERSION +from typing import TYPE_CHECKING +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + + from azure.core.credentials import TokenCredential + +VERSION = "unknown" + +class PolicyClientConfiguration(Configuration): + """Configuration for PolicyClient. -class PolicyClientConfiguration(AzureConfiguration): - """Configuration for PolicyClient Note that all parameters used to create this instance are saved as instance attributes. - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` + :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 """ def __init__( - self, credentials, subscription_id, base_url=None): - - if credentials is None: - raise ValueError("Parameter 'credentials' must not be None.") + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + 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.") - if not base_url: - base_url = 'https://management.azure.com' + super(PolicyClientConfiguration, self).__init__(**kwargs) - super(PolicyClientConfiguration, self).__init__(base_url) - - # Starting Autorest.Python 4.0.64, make connection pool activated by default - self.keep_alive = True - - self.add_user_agent('azure-mgmt-resource/{}'.format(VERSION)) - self.add_user_agent('Azure-SDK-For-Python') - - self.credentials = credentials + self.credential = credential self.subscription_id = subscription_id + self.api_version = "2018-05-01" + self.credential_scopes = ['https://management.azure.com/.default'] + self.credential_scopes.extend(kwargs.pop('credential_scopes', [])) + kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + 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) 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 new file mode 100644 index 000000000000..e81eff898bef --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/_metadata.json @@ -0,0 +1,55 @@ +{ + "chosen_version": "2018-05-01", + "total_api_version_list": ["2018-05-01"], + "client": { + "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." + }, + "global_parameters": { + "sync_method": { + "credential": { + "method_signature": "credential, # type: \"TokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials.TokenCredential", + "required": true + }, + "subscription_id": { + "method_signature": "subscription_id, # type: str", + "description": "The ID of the target subscription.", + "docstring_type": "str", + "required": true + } + }, + "async_method": { + "credential": { + "method_signature": "credential, # type: \"AsyncTokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + }, + "subscription_id": { + "method_signature": "subscription_id, # type: str", + "description": "The ID of the target subscription.", + "docstring_type": "str", + "required": true + } + }, + "constant": { + }, + "call": "credential, subscription_id" + }, + "config": { + "credential": true, + "credential_scopes": ["https://management.azure.com/.default"] + }, + "operation_groups": { + "policy_assignments": "PolicyAssignmentsOperations", + "policy_definitions": "PolicyDefinitionsOperations", + "policy_set_definitions": "PolicySetDefinitionsOperations" + }, + "operation_mixins": { + }, + "sync_imports": "None", + "async_imports": "None" +} \ 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 cdb7cb010f89..d88025c30a6f 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 @@ -1,16 +1,19 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.service_client import SDKClient -from msrest import Serializer, Deserializer +from typing import TYPE_CHECKING + +from azure.mgmt.core import ARMPipelineClient +from msrest import Deserializer, Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional from ._configuration import PolicyClientConfiguration from .operations import PolicyAssignmentsOperations @@ -19,41 +22,56 @@ from . import models -class PolicyClient(SDKClient): +class PolicyClient(object): """To manage and control access to your resources, you can define customized policies and assign them at a scope. - :ivar config: Configuration for client. - :vartype config: PolicyClientConfiguration - - :ivar policy_assignments: PolicyAssignments operations + :ivar policy_assignments: PolicyAssignmentsOperations operations :vartype policy_assignments: azure.mgmt.resource.policy.v2018_05_01.operations.PolicyAssignmentsOperations - :ivar policy_definitions: PolicyDefinitions operations + :ivar policy_definitions: PolicyDefinitionsOperations operations :vartype policy_definitions: azure.mgmt.resource.policy.v2018_05_01.operations.PolicyDefinitionsOperations - :ivar policy_set_definitions: PolicySetDefinitions operations + :ivar policy_set_definitions: PolicySetDefinitionsOperations operations :vartype policy_set_definitions: azure.mgmt.resource.policy.v2018_05_01.operations.PolicySetDefinitionsOperations - - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` + :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. """ def __init__( - self, credentials, subscription_id, base_url=None): - - self.config = PolicyClientConfiguration(credentials, subscription_id, base_url) - super(PolicyClient, self).__init__(self.config.credentials, self.config) + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = 'https://management.azure.com' + self._config = PolicyClientConfiguration(credential, 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.api_version = '2018-05-01' self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self.policy_assignments = PolicyAssignmentsOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.policy_definitions = PolicyDefinitionsOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.policy_set_definitions = PolicySetDefinitionsOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> PolicyClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) 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 new file mode 100644 index 000000000000..df3c0beab48a --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/aio/__init__.py @@ -0,0 +1,10 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._policy_client_async import PolicyClient +__all__ = ['PolicyClient'] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/aio/_configuration_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/aio/_configuration_async.py new file mode 100644 index 000000000000..c511caa7560c --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/aio/_configuration_async.py @@ -0,0 +1,65 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + +VERSION = "unknown" + +class PolicyClientConfiguration(Configuration): + """Configuration for PolicyClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :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 + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + 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 + self.api_version = "2018-05-01" + self.credential_scopes = ['https://management.azure.com/.default'] + self.credential_scopes.extend(kwargs.pop('credential_scopes', [])) + kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs: Any + ) -> None: + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + 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) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/aio/_policy_client_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/aio/_policy_client_async.py new file mode 100644 index 000000000000..082c7948c096 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/aio/_policy_client_async.py @@ -0,0 +1,69 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, Optional + +from azure.mgmt.core import AsyncARMPipelineClient +from msrest import Deserializer, Serializer + +from ._configuration_async import PolicyClientConfiguration +from .operations_async import PolicyAssignmentsOperations +from .operations_async import PolicyDefinitionsOperations +from .operations_async import PolicySetDefinitionsOperations +from .. import models + + +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.aio.operations_async.PolicyAssignmentsOperations + :ivar policy_definitions: PolicyDefinitionsOperations operations + :vartype policy_definitions: azure.mgmt.resource.policy.v2018_05_01.aio.operations_async.PolicyDefinitionsOperations + :ivar policy_set_definitions: PolicySetDefinitionsOperations operations + :vartype policy_set_definitions: azure.mgmt.resource.policy.v2018_05_01.aio.operations_async.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 + :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, + **kwargs: 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) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + + self.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 close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "PolicyClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/aio/operations_async/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/aio/operations_async/__init__.py new file mode 100644 index 000000000000..6a33a6888921 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/aio/operations_async/__init__.py @@ -0,0 +1,17 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._policy_assignments_operations_async import PolicyAssignmentsOperations +from ._policy_definitions_operations_async import PolicyDefinitionsOperations +from ._policy_set_definitions_operations_async import PolicySetDefinitionsOperations + +__all__ = [ + 'PolicyAssignmentsOperations', + 'PolicyDefinitionsOperations', + 'PolicySetDefinitionsOperations', +] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/aio/operations_async/_policy_assignments_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/aio/operations_async/_policy_assignments_operations_async.py new file mode 100644 index 000000000000..19574bbcd69e --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/aio/operations_async/_policy_assignments_operations_async.py @@ -0,0 +1,657 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import 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 ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class PolicyAssignmentsOperations: + """PolicyAssignmentsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.policy.v2018_05_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def delete( + self, + scope: str, + policy_assignment_name: str, + **kwargs + ) -> "models.PolicyAssignment": + """This operation deletes a policy assignment, given its name and the scope it was created in. The scope of a policy assignment is the part of its ID preceding '/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + + Deletes a policy assignment. + + :param scope: The scope of the policy assignment. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + :type scope: str + :param policy_assignment_name: The name of the policy assignment to delete. + :type policy_assignment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyAssignment or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {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 = { + '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'] = 'application/json' + + # Construct and send request + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('PolicyAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore + + async def create( + self, + scope: str, + policy_assignment_name: str, + parameters: "models.PolicyAssignment", + **kwargs + ) -> "models.PolicyAssignment": + """This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + + Creates or updates a policy assignment. + + :param scope: The scope of the policy assignment. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + :type scope: str + :param policy_assignment_name: The name of the policy assignment. + :type policy_assignment_name: str + :param parameters: Parameters for the policy assignment. + :type parameters: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyAssignment + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {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.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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore + + async def get( + self, + scope: str, + policy_assignment_name: str, + **kwargs + ) -> "models.PolicyAssignment": + """This operation retrieves a single policy assignment, given its name and the scope it was created at. + + Retrieves a policy assignment. + + :param scope: The scope of the policy assignment. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + :type scope: str + :param policy_assignment_name: The name of the policy assignment to get. + :type policy_assignment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + + # 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'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore + + def list_for_resource_group( + self, + resource_group_name: str, + filter: Optional[str] = None, + **kwargs + ) -> AsyncIterable["models.PolicyAssignmentListResult"]: + """This operation retrieves the list of all policy assignments associated with the given resource group in the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource group, including those that apply directly or apply from containing scopes, as well as any applied to resources contained within the resource group. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource group, which is everything in the unfiltered list except those applied to resources contained within the resource group. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource group. + + Retrieves all policy assignments that apply to a resource group. + + :param resource_group_name: The name of the resource group that contains policy assignments. + :type resource_group_name: str + :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()' + 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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + 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 + + def list_for_resource( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + filter: Optional[str] = None, + **kwargs + ) -> AsyncIterable["models.PolicyAssignmentListResult"]: + """This operation retrieves the list of all policy assignments associated with the specified resource in the given resource group and subscription that match the optional given $filter. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource, including those that apply directly or from all containing scopes, as well as any applied to resources contained within the resource. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource, which is everything in the unfiltered list except those applied to resources contained within the resource. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource. Three parameters plus the resource name are used to identify a specific resource. If the resource is not part of a parent resource (the more common case), the parent resource path should not be provided (or provided as ''). For example a web app could be specified as ({resourceProviderNamespace} == 'Microsoft.Web', {parentResourcePath} == '', {resourceType} == 'sites', {resourceName} == 'MyWebApp'). If the resource is part of a parent resource, then all parameters should be provided. For example a virtual machine DNS name could be specified as ({resourceProviderNamespace} == 'Microsoft.Compute', {parentResourcePath} == 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames', {resourceName} == 'MyComputerName'). A convenient alternative to providing the namespace and type name separately is to provide both in the {resourceType} parameter, format: ({resourceProviderNamespace} == '', {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). + + Retrieves all policy assignments that apply to a resource. + + :param resource_group_name: The name of the resource group containing the resource. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. For example, the + namespace of a virtual machine is Microsoft.Compute (from Microsoft.Compute/virtualMachines). + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource path. Use empty string if there is none. + :type parent_resource_path: str + :param resource_type: The resource type name. For example the type name of a web app is 'sites' + (from Microsoft.Web/sites). + :type resource_type: str + :param resource_name: The name of the resource. + :type resource_name: str + :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()' + 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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + 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 + + def list( + self, + filter: Optional[str] = None, + **kwargs + ) -> AsyncIterable["models.PolicyAssignmentListResult"]: + """This operation retrieves the list of all policy assignments associated with the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the subscription, including those that apply directly or from management groups that contain the given subscription, as well as any applied to objects contained within the subscription. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the subscription, which is everything in the unfiltered list except those applied to objects contained within the subscription. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value}. + + Retrieves all policy assignments that apply to a subscription. + + :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()' + 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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + 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 + + async def delete_by_id( + self, + policy_assignment_id: str, + **kwargs + ) -> "models.PolicyAssignment": + """This operation deletes the policy with the given ID. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid formats for {scope} are: '/providers/Microsoft.Management/managementGroups/{managementGroup}' (management group), '/subscriptions/{subscriptionId}' (subscription), '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' (resource group), or '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' (resource). + + Deletes a policy assignment. + + :param policy_assignment_id: The ID of the policy assignment to delete. Use the format + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + :type policy_assignment_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyAssignment or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + + # 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'] = 'application/json' + + # Construct and send request + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('PolicyAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + delete_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + + async def create_by_id( + self, + policy_assignment_id: str, + parameters: "models.PolicyAssignment", + **kwargs + ) -> "models.PolicyAssignment": + """This operation creates or updates the policy assignment with the given ID. Policy assignments made on a scope apply to all resources contained in that scope. For example, when you assign a policy to a resource group that policy applies to all resources in the group. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + + Creates or updates a policy assignment. + + :param policy_assignment_id: The ID of the policy assignment to create. Use the format + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + :type policy_assignment_id: str + :param parameters: Parameters for policy assignment. + :type parameters: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyAssignment + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {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.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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + + async def get_by_id( + self, + policy_assignment_id: str, + **kwargs + ) -> "models.PolicyAssignment": + """The operation retrieves the policy assignment with the given ID. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + + Retrieves the policy assignment with the given ID. + + :param policy_assignment_id: The ID of the policy assignment to get. Use the format + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + :type policy_assignment_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + + # 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'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyAssignment', pipeline_response) + + if cls: + 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_async/_policy_definitions_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/aio/operations_async/_policy_definitions_operations_async.py new file mode 100644 index 000000000000..425c4e6aa8cb --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/aio/operations_async/_policy_definitions_operations_async.py @@ -0,0 +1,632 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import 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 ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class PolicyDefinitionsOperations: + """PolicyDefinitionsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.policy.v2018_05_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def create_or_update( + self, + policy_definition_name: str, + parameters: "models.PolicyDefinition", + **kwargs + ) -> "models.PolicyDefinition": + """This operation creates or updates a policy definition in the given subscription with the given name. + + Creates or updates a policy definition in a subscription. + + :param policy_definition_name: The name of the policy definition to create. + :type policy_definition_name: str + :param parameters: The policy definition properties. + :type parameters: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyDefinition"] + error_map = {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.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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + async def delete( + self, + policy_definition_name: str, + **kwargs + ) -> None: + """This operation deletes the policy definition in the given subscription with the given name. + + Deletes a policy definition in a subscription. + + :param policy_definition_name: The name of the policy definition to delete. + :type policy_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + async def get( + self, + policy_definition_name: str, + **kwargs + ) -> "models.PolicyDefinition": + """This operation retrieves the policy definition in the given subscription with the given name. + + Retrieves a policy definition in a subscription. + + :param policy_definition_name: The name of the policy definition to get. + :type policy_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + async def get_built_in( + self, + policy_definition_name: str, + **kwargs + ) -> "models.PolicyDefinition": + """This operation retrieves the built-in policy definition with the given name. + + Retrieves a built-in policy definition. + + :param policy_definition_name: The name of the built-in policy definition to get. + :type policy_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + async def create_or_update_at_management_group( + self, + policy_definition_name: str, + management_group_id: str, + parameters: "models.PolicyDefinition", + **kwargs + ) -> "models.PolicyDefinition": + """This operation creates or updates a policy definition in the given management group with the given name. + + Creates or updates a policy definition in a management group. + + :param policy_definition_name: The name of the policy definition to create. + :type policy_definition_name: str + :param management_group_id: The ID of the management group. + :type management_group_id: str + :param parameters: The policy definition properties. + :type parameters: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyDefinition"] + error_map = {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.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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyDefinition', pipeline_response) + + if cls: + 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 + + async def delete_at_management_group( + self, + policy_definition_name: str, + management_group_id: str, + **kwargs + ) -> None: + """This operation deletes the policy definition in the given management group with the given name. + + Deletes a policy definition in a management group. + + :param policy_definition_name: The name of the policy definition to delete. + :type policy_definition_name: str + :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: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + async def get_at_management_group( + self, + policy_definition_name: str, + management_group_id: str, + **kwargs + ) -> "models.PolicyDefinition": + """This operation retrieves the policy definition in the given management group with the given name. + + Retrieve a policy definition in a management group. + + :param policy_definition_name: The name of the policy definition to get. + :type policy_definition_name: str + :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: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyDefinition', pipeline_response) + + if cls: + 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 + + def list( + self, + **kwargs + ) -> AsyncIterable["models.PolicyDefinitionListResult"]: + """This operation retrieves a list of all the policy definitions in a given subscription. + + Retrieves policy definitions in a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyDefinitionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions'} # type: ignore + + def list_built_in( + self, + **kwargs + ) -> AsyncIterable["models.PolicyDefinitionListResult"]: + """This operation retrieves a list of all the built-in policy definitions. + + Retrieve 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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyDefinitionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policyDefinitions'} # type: ignore + + def list_by_management_group( + self, + management_group_id: str, + **kwargs + ) -> AsyncIterable["models.PolicyDefinitionListResult"]: + """This operation retrieves a list of all the policy definitions in a given management group. + + Retrieve policy definitions in a 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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyDefinitionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/aio/operations_async/_policy_set_definitions_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/aio/operations_async/_policy_set_definitions_operations_async.py new file mode 100644 index 000000000000..47e6537fca34 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/aio/operations_async/_policy_set_definitions_operations_async.py @@ -0,0 +1,652 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import 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 ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class PolicySetDefinitionsOperations: + """PolicySetDefinitionsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.policy.v2018_05_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def create_or_update( + self, + policy_set_definition_name: str, + parameters: "models.PolicySetDefinition", + **kwargs + ) -> "models.PolicySetDefinition": + """This operation creates or updates a policy set definition in the given subscription with the given name. + + Creates or updates a policy set definition. + + :param policy_set_definition_name: The name of the policy set definition to create. + :type policy_set_definition_name: str + :param parameters: The policy set definition properties. + :type parameters: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicySetDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicySetDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicySetDefinition"] + error_map = {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.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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + async def delete( + self, + policy_set_definition_name: str, + **kwargs + ) -> None: + """This operation deletes the policy set definition in the given subscription with the given name. + + Deletes a policy set definition. + + :param policy_set_definition_name: The name of the policy set definition to delete. + :type policy_set_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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 = { + '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] + + # Construct and send request + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + async def get( + self, + policy_set_definition_name: str, + **kwargs + ) -> "models.PolicySetDefinition": + """This operation retrieves the policy set definition in the given subscription with the given name. + + Retrieves a policy set definition. + + :param policy_set_definition_name: The name of the policy set definition to get. + :type policy_set_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicySetDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicySetDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + + # 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'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + async def get_built_in( + self, + policy_set_definition_name: str, + **kwargs + ) -> "models.PolicySetDefinition": + """This operation retrieves the built-in policy set definition with the given name. + + Retrieves a built in policy set definition. + + :param policy_set_definition_name: The name of the policy set definition to get. + :type policy_set_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicySetDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicySetDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + + # 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'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + def list( + self, + **kwargs + ) -> AsyncIterable["models.PolicySetDefinitionListResult"]: + """This operation retrieves a list of all the policy set definitions in the given subscription. + + Retrieves 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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('PolicySetDefinitionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + 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 + + def list_built_in( + self, + **kwargs + ) -> AsyncIterable["models.PolicySetDefinitionListResult"]: + """This operation retrieves a list of all the built-in policy set definitions. + + Retrieves 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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('PolicySetDefinitionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + 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 + + async def create_or_update_at_management_group( + self, + policy_set_definition_name: str, + management_group_id: str, + parameters: "models.PolicySetDefinition", + **kwargs + ) -> "models.PolicySetDefinition": + """This operation creates or updates a policy set definition in the given management group with the given name. + + Creates or updates a policy set definition. + + :param policy_set_definition_name: The name of the policy set definition to create. + :type policy_set_definition_name: str + :param management_group_id: The ID of the management group. + :type management_group_id: str + :param parameters: The policy set definition properties. + :type parameters: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicySetDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicySetDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicySetDefinition"] + error_map = {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.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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + + if cls: + 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 + + async def delete_at_management_group( + self, + policy_set_definition_name: str, + management_group_id: str, + **kwargs + ) -> None: + """This operation deletes the policy set definition in the given management group with the given name. + + Deletes a policy set definition. + + :param policy_set_definition_name: The name of the policy set definition to delete. + :type policy_set_definition_name: str + :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: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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 = { + '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] + + # Construct and send request + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + async def get_at_management_group( + self, + policy_set_definition_name: str, + management_group_id: str, + **kwargs + ) -> "models.PolicySetDefinition": + """This operation retrieves the policy set definition in the given management group with the given name. + + Retrieves a policy set definition. + + :param policy_set_definition_name: The name of the policy set definition to get. + :type policy_set_definition_name: str + :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: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicySetDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicySetDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + + # 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'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + + if cls: + 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 + + def list_by_management_group( + self, + management_group_id: str, + **kwargs + ) -> AsyncIterable["models.PolicySetDefinitionListResult"]: + """This operation retrieves a list of all the a policy set definition in the given management group. + + Retrieves all policy set definitions in 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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('PolicySetDefinitionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/models/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/models/__init__.py index 22ef4fecfb90..3f317de2b41a 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/models/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/models/__init__.py @@ -1,51 +1,52 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- try: - from ._models_py3 import ErrorResponse, ErrorResponseException + from ._models_py3 import ErrorResponse from ._models_py3 import Identity from ._models_py3 import PolicyAssignment + from ._models_py3 import PolicyAssignmentListResult from ._models_py3 import PolicyDefinition + from ._models_py3 import PolicyDefinitionListResult from ._models_py3 import PolicyDefinitionReference from ._models_py3 import PolicySetDefinition + from ._models_py3 import PolicySetDefinitionListResult from ._models_py3 import PolicySku except (SyntaxError, ImportError): - from ._models import ErrorResponse, ErrorResponseException - from ._models import Identity - from ._models import PolicyAssignment - from ._models import PolicyDefinition - from ._models import PolicyDefinitionReference - from ._models import PolicySetDefinition - from ._models import PolicySku -from ._paged_models import PolicyAssignmentPaged -from ._paged_models import PolicyDefinitionPaged -from ._paged_models import PolicySetDefinitionPaged + from ._models import ErrorResponse # type: ignore + from ._models import Identity # type: ignore + from ._models import PolicyAssignment # type: ignore + from ._models import PolicyAssignmentListResult # type: ignore + from ._models import PolicyDefinition # type: ignore + from ._models import PolicyDefinitionListResult # type: ignore + from ._models import PolicyDefinitionReference # type: ignore + from ._models import PolicySetDefinition # type: ignore + from ._models import PolicySetDefinitionListResult # type: ignore + from ._models import PolicySku # type: ignore + from ._policy_client_enums import ( - ResourceIdentityType, - PolicyType, PolicyMode, + PolicyType, + ResourceIdentityType, ) __all__ = [ - 'ErrorResponse', 'ErrorResponseException', + 'ErrorResponse', 'Identity', 'PolicyAssignment', + 'PolicyAssignmentListResult', 'PolicyDefinition', + 'PolicyDefinitionListResult', 'PolicyDefinitionReference', 'PolicySetDefinition', + 'PolicySetDefinitionListResult', 'PolicySku', - 'PolicyAssignmentPaged', - 'PolicyDefinitionPaged', - 'PolicySetDefinitionPaged', - 'ResourceIdentityType', - 'PolicyType', 'PolicyMode', + 'PolicyType', + 'ResourceIdentityType', ] 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 1b784d1fa550..8da7c44c8322 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 @@ -1,29 +1,17 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.serialization import Model -from msrest.exceptions import HttpOperationError +from azure.core.exceptions import HttpResponseError +import msrest.serialization -class CloudError(Model): - """CloudError. - """ - - _attribute_map = { - } - - -class ErrorResponse(Model): - """Error response indicates Azure Resource Manager is not able to process the - incoming request. The reason is provided in the error message. +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 @@ -39,39 +27,27 @@ class ErrorResponse(Model): 'error_message': {'key': 'errorMessage', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ErrorResponse, self).__init__(**kwargs) self.http_status = kwargs.get('http_status', None) self.error_code = kwargs.get('error_code', None) self.error_message = kwargs.get('error_message', None) -class ErrorResponseException(HttpOperationError): - """Server responsed with exception of type: 'ErrorResponse'. - - :param deserialize: A deserializer - :param response: Server response to be deserialized. - """ - - def __init__(self, deserialize, response, *args): - - super(ErrorResponseException, self).__init__(deserialize, response, 'ErrorResponse', *args) - - -class Identity(Model): +class Identity(msrest.serialization.Model): """Identity for the resource. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar principal_id: The principal ID of the resource identity. :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 + :param type: The identity type. Possible values include: "SystemAssigned", "None". + :type type: str or ~azure.mgmt.resource.policy.v2018_05_01.models.ResourceIdentityType """ _validation = { @@ -82,26 +58,41 @@ class Identity(Model): _attribute_map = { 'principal_id': {'key': 'principalId', 'type': 'str'}, 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'ResourceIdentityType'}, + 'type': {'key': 'type', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Identity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None self.type = kwargs.get('type', None) -class PolicyAssignment(Model): +class PolicyAssignment(msrest.serialization.Model): """The policy assignment. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. + :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 + :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 + 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 assigned. + :param 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 @@ -109,26 +100,10 @@ class PolicyAssignment(Model): :type not_scopes: list[str] :param parameters: Required if a parameter is used in policy rule. :type parameters: object - :param description: This message will be part of response in case of - policy violation. + :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: object - :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 - :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 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 """ _validation = { @@ -138,6 +113,12 @@ class PolicyAssignment(Model): } _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'sku': {'key': 'sku', 'type': 'PolicySku'}, + 'location': {'key': 'location', 'type': 'str'}, + 'identity': {'key': 'identity', 'type': 'Identity'}, 'display_name': {'key': 'properties.displayName', 'type': 'str'}, 'policy_definition_id': {'key': 'properties.policyDefinitionId', 'type': 'str'}, 'scope': {'key': 'properties.scope', 'type': 'str'}, @@ -145,16 +126,19 @@ class PolicyAssignment(Model): 'parameters': {'key': 'properties.parameters', 'type': 'object'}, 'description': {'key': 'properties.description', 'type': 'str'}, 'metadata': {'key': 'properties.metadata', 'type': 'object'}, - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'PolicySku'}, - 'location': {'key': 'location', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(PolicyAssignment, self).__init__(**kwargs) + self.id = None + self.type = None + self.name = None + self.sku = kwargs.get('sku', None) + self.location = kwargs.get('location', None) + self.identity = kwargs.get('identity', None) self.display_name = kwargs.get('display_name', None) self.policy_definition_id = kwargs.get('policy_definition_id', None) self.scope = kwargs.get('scope', None) @@ -162,30 +146,48 @@ def __init__(self, **kwargs): self.parameters = kwargs.get('parameters', None) self.description = kwargs.get('description', None) self.metadata = kwargs.get('metadata', None) - self.id = None - self.type = None - self.name = None - self.sku = kwargs.get('sku', None) - self.location = kwargs.get('location', None) - self.identity = kwargs.get('identity', None) -class PolicyDefinition(Model): +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 + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[PolicyAssignment]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(PolicyAssignmentListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class PolicyDefinition(msrest.serialization.Model): """The policy definition. - Variables are only populated by the server, and will be ignored when - sending a request. - - :param 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. Possible values include: 'NotSpecified', 'Indexed', - 'All' - :type mode: str or - ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyMode + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The ID of the policy definition. + :vartype id: str + :ivar name: The name of the policy definition. + :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, + 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. + 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. @@ -196,13 +198,6 @@ class PolicyDefinition(Model): :type metadata: object :param parameters: Required if a parameter is used in policy rule. :type parameters: object - :ivar id: The ID of the policy definition. - :vartype id: str - :ivar name: The name of the policy definition. - :vartype name: str - :ivar type: The type of the resource - (Microsoft.Authorization/policyDefinitions). - :vartype type: str """ _validation = { @@ -212,6 +207,9 @@ class PolicyDefinition(Model): } _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, 'policy_type': {'key': 'properties.policyType', 'type': 'str'}, 'mode': {'key': 'properties.mode', 'type': 'str'}, 'display_name': {'key': 'properties.displayName', 'type': 'str'}, @@ -219,13 +217,16 @@ class PolicyDefinition(Model): 'policy_rule': {'key': 'properties.policyRule', 'type': 'object'}, 'metadata': {'key': 'properties.metadata', 'type': 'object'}, 'parameters': {'key': 'properties.parameters', 'type': 'object'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(PolicyDefinition, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None self.policy_type = kwargs.get('policy_type', None) self.mode = kwargs.get('mode', None) self.display_name = kwargs.get('display_name', None) @@ -233,16 +234,35 @@ def __init__(self, **kwargs): self.policy_rule = kwargs.get('policy_rule', None) self.metadata = kwargs.get('metadata', None) self.parameters = kwargs.get('parameters', None) - self.id = None - self.name = None - self.type = None -class PolicyDefinitionReference(Model): +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 + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[PolicyDefinition]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(PolicyDefinitionListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class PolicyDefinitionReference(msrest.serialization.Model): """The policy definition reference. - :param policy_definition_id: The ID of the policy definition or policy set - definition. + :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: object @@ -253,86 +273,106 @@ class PolicyDefinitionReference(Model): 'parameters': {'key': 'parameters', 'type': 'object'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(PolicyDefinitionReference, self).__init__(**kwargs) self.policy_definition_id = kwargs.get('policy_definition_id', None) self.parameters = kwargs.get('parameters', None) -class PolicySetDefinition(Model): +class PolicySetDefinition(msrest.serialization.Model): """The policy set definition. - Variables are only populated by the server, and will be ignored when - sending a request. - - All required parameters must be populated in order to send to Azure. + Variables are only populated by the server, and will be ignored when sending a request. - :param 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 + :ivar id: The ID of the policy set definition. + :vartype id: str + :ivar name: The name of the policy set definition. + :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, + 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: object - :param parameters: The policy set definition parameters that can be used - in policy definition references. - :type parameters: object - :param policy_definitions: Required. An array of policy definition + :param parameters: The policy set definition parameters that can be used in policy definition references. + :type parameters: object + :param policy_definitions: An array of policy definition references. :type policy_definitions: list[~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinitionReference] - :ivar id: The ID of the policy set definition. - :vartype id: str - :ivar name: The name of the policy set definition. - :vartype name: str - :ivar type: The type of the resource - (Microsoft.Authorization/policySetDefinitions). - :vartype type: str """ _validation = { - 'policy_definitions': {'required': True}, 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, } _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, 'policy_type': {'key': 'properties.policyType', 'type': 'str'}, 'display_name': {'key': 'properties.displayName', 'type': 'str'}, 'description': {'key': 'properties.description', 'type': 'str'}, 'metadata': {'key': 'properties.metadata', 'type': 'object'}, 'parameters': {'key': 'properties.parameters', 'type': 'object'}, 'policy_definitions': {'key': 'properties.policyDefinitions', 'type': '[PolicyDefinitionReference]'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(PolicySetDefinition, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None self.policy_type = kwargs.get('policy_type', None) self.display_name = kwargs.get('display_name', None) self.description = kwargs.get('description', None) self.metadata = kwargs.get('metadata', None) self.parameters = kwargs.get('parameters', None) self.policy_definitions = kwargs.get('policy_definitions', None) - self.id = None - self.name = None - self.type = None -class PolicySku(Model): +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 + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[PolicySetDefinition]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(PolicySetDefinitionListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class PolicySku(msrest.serialization.Model): """The policy sku. This property is optional, obsolete, and will be ignored. 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. + :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 @@ -347,7 +387,10 @@ class PolicySku(Model): 'tier': {'key': 'tier', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(PolicySku, self).__init__(**kwargs) - self.name = kwargs.get('name', None) + 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 2b25ec9b1135..b4acced4df96 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 @@ -1,29 +1,21 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.serialization import Model -from msrest.exceptions import HttpOperationError +from typing import List, Optional, Union +from azure.core.exceptions import HttpResponseError +import msrest.serialization -class CloudError(Model): - """CloudError. - """ - - _attribute_map = { - } +from ._policy_client_enums import * -class ErrorResponse(Model): - """Error response indicates Azure Resource Manager is not able to process the - incoming request. The reason is provided in the error message. +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 @@ -39,39 +31,31 @@ class ErrorResponse(Model): 'error_message': {'key': 'errorMessage', 'type': 'str'}, } - def __init__(self, *, http_status: str=None, error_code: str=None, error_message: str=None, **kwargs) -> None: + def __init__( + self, + *, + http_status: Optional[str] = None, + error_code: Optional[str] = None, + error_message: Optional[str] = None, + **kwargs + ): super(ErrorResponse, self).__init__(**kwargs) self.http_status = http_status self.error_code = error_code self.error_message = error_message -class ErrorResponseException(HttpOperationError): - """Server responsed with exception of type: 'ErrorResponse'. - - :param deserialize: A deserializer - :param response: Server response to be deserialized. - """ - - def __init__(self, deserialize, response, *args): - - super(ErrorResponseException, self).__init__(deserialize, response, 'ErrorResponse', *args) - - -class Identity(Model): +class Identity(msrest.serialization.Model): """Identity for the resource. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar principal_id: The principal ID of the resource identity. :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 + :param type: The identity type. Possible values include: "SystemAssigned", "None". + :type type: str or ~azure.mgmt.resource.policy.v2018_05_01.models.ResourceIdentityType """ _validation = { @@ -82,26 +66,43 @@ class Identity(Model): _attribute_map = { 'principal_id': {'key': 'principalId', 'type': 'str'}, 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'ResourceIdentityType'}, + 'type': {'key': 'type', 'type': 'str'}, } - def __init__(self, *, type=None, **kwargs) -> None: + def __init__( + self, + *, + type: Optional[Union[str, "ResourceIdentityType"]] = None, + **kwargs + ): super(Identity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None self.type = type -class PolicyAssignment(Model): +class PolicyAssignment(msrest.serialization.Model): """The policy assignment. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. + :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 + :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 + 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 assigned. + :param 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 @@ -109,26 +110,10 @@ class PolicyAssignment(Model): :type not_scopes: list[str] :param parameters: Required if a parameter is used in policy rule. :type parameters: object - :param description: This message will be part of response in case of - policy violation. + :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: object - :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 - :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 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 """ _validation = { @@ -138,6 +123,12 @@ class PolicyAssignment(Model): } _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'sku': {'key': 'sku', 'type': 'PolicySku'}, + 'location': {'key': 'location', 'type': 'str'}, + 'identity': {'key': 'identity', 'type': 'Identity'}, 'display_name': {'key': 'properties.displayName', 'type': 'str'}, 'policy_definition_id': {'key': 'properties.policyDefinitionId', 'type': 'str'}, 'scope': {'key': 'properties.scope', 'type': 'str'}, @@ -145,16 +136,30 @@ class PolicyAssignment(Model): 'parameters': {'key': 'properties.parameters', 'type': 'object'}, 'description': {'key': 'properties.description', 'type': 'str'}, 'metadata': {'key': 'properties.metadata', 'type': 'object'}, - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'PolicySku'}, - 'location': {'key': 'location', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, } - def __init__(self, *, display_name: str=None, policy_definition_id: str=None, scope: str=None, not_scopes=None, parameters=None, description: str=None, metadata=None, sku=None, location: str=None, identity=None, **kwargs) -> None: + def __init__( + self, + *, + sku: Optional["PolicySku"] = None, + location: Optional[str] = None, + identity: Optional["Identity"] = None, + display_name: Optional[str] = None, + policy_definition_id: Optional[str] = None, + scope: Optional[str] = None, + not_scopes: Optional[List[str]] = None, + parameters: Optional[object] = None, + description: Optional[str] = None, + metadata: Optional[object] = None, + **kwargs + ): super(PolicyAssignment, self).__init__(**kwargs) + self.id = None + self.type = None + self.name = None + self.sku = sku + self.location = location + self.identity = identity self.display_name = display_name self.policy_definition_id = policy_definition_id self.scope = scope @@ -162,30 +167,51 @@ def __init__(self, *, display_name: str=None, policy_definition_id: str=None, sc self.parameters = parameters self.description = description self.metadata = metadata - self.id = None - self.type = None - self.name = None - self.sku = sku - self.location = location - self.identity = identity -class PolicyDefinition(Model): +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 + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[PolicyAssignment]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["PolicyAssignment"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(PolicyAssignmentListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class PolicyDefinition(msrest.serialization.Model): """The policy definition. - Variables are only populated by the server, and will be ignored when - sending a request. - - :param 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. Possible values include: 'NotSpecified', 'Indexed', - 'All' - :type mode: str or - ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyMode + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The ID of the policy definition. + :vartype id: str + :ivar name: The name of the policy definition. + :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, + 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. + 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. @@ -196,13 +222,6 @@ class PolicyDefinition(Model): :type metadata: object :param parameters: Required if a parameter is used in policy rule. :type parameters: object - :ivar id: The ID of the policy definition. - :vartype id: str - :ivar name: The name of the policy definition. - :vartype name: str - :ivar type: The type of the resource - (Microsoft.Authorization/policyDefinitions). - :vartype type: str """ _validation = { @@ -212,6 +231,9 @@ class PolicyDefinition(Model): } _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, 'policy_type': {'key': 'properties.policyType', 'type': 'str'}, 'mode': {'key': 'properties.mode', 'type': 'str'}, 'display_name': {'key': 'properties.displayName', 'type': 'str'}, @@ -219,13 +241,24 @@ class PolicyDefinition(Model): 'policy_rule': {'key': 'properties.policyRule', 'type': 'object'}, 'metadata': {'key': 'properties.metadata', 'type': 'object'}, 'parameters': {'key': 'properties.parameters', 'type': 'object'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, } - def __init__(self, *, policy_type=None, mode=None, display_name: str=None, description: str=None, policy_rule=None, metadata=None, parameters=None, **kwargs) -> None: + def __init__( + self, + *, + policy_type: Optional[Union[str, "PolicyType"]] = None, + mode: Optional[Union[str, "PolicyMode"]] = None, + display_name: Optional[str] = None, + description: Optional[str] = None, + policy_rule: Optional[object] = None, + metadata: Optional[object] = None, + parameters: Optional[object] = None, + **kwargs + ): super(PolicyDefinition, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None self.policy_type = policy_type self.mode = mode self.display_name = display_name @@ -233,16 +266,38 @@ def __init__(self, *, policy_type=None, mode=None, display_name: str=None, descr self.policy_rule = policy_rule self.metadata = metadata self.parameters = parameters - self.id = None - self.name = None - self.type = None -class PolicyDefinitionReference(Model): +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 + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[PolicyDefinition]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["PolicyDefinition"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(PolicyDefinitionListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class PolicyDefinitionReference(msrest.serialization.Model): """The policy definition reference. - :param policy_definition_id: The ID of the policy definition or policy set - definition. + :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: object @@ -253,86 +308,119 @@ class PolicyDefinitionReference(Model): 'parameters': {'key': 'parameters', 'type': 'object'}, } - def __init__(self, *, policy_definition_id: str=None, parameters=None, **kwargs) -> None: + def __init__( + self, + *, + policy_definition_id: Optional[str] = None, + parameters: Optional[object] = None, + **kwargs + ): super(PolicyDefinitionReference, self).__init__(**kwargs) self.policy_definition_id = policy_definition_id self.parameters = parameters -class PolicySetDefinition(Model): +class PolicySetDefinition(msrest.serialization.Model): """The policy set definition. - Variables are only populated by the server, and will be ignored when - sending a request. - - All required parameters must be populated in order to send to Azure. + Variables are only populated by the server, and will be ignored when sending a request. - :param 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 + :ivar id: The ID of the policy set definition. + :vartype id: str + :ivar name: The name of the policy set definition. + :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, + 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: object - :param parameters: The policy set definition parameters that can be used - in policy definition references. - :type parameters: object - :param policy_definitions: Required. An array of policy definition + :param parameters: The policy set definition parameters that can be used in policy definition references. + :type parameters: object + :param policy_definitions: An array of policy definition references. :type policy_definitions: list[~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinitionReference] - :ivar id: The ID of the policy set definition. - :vartype id: str - :ivar name: The name of the policy set definition. - :vartype name: str - :ivar type: The type of the resource - (Microsoft.Authorization/policySetDefinitions). - :vartype type: str """ _validation = { - 'policy_definitions': {'required': True}, 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, } _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, 'policy_type': {'key': 'properties.policyType', 'type': 'str'}, 'display_name': {'key': 'properties.displayName', 'type': 'str'}, 'description': {'key': 'properties.description', 'type': 'str'}, 'metadata': {'key': 'properties.metadata', 'type': 'object'}, 'parameters': {'key': 'properties.parameters', 'type': 'object'}, 'policy_definitions': {'key': 'properties.policyDefinitions', 'type': '[PolicyDefinitionReference]'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, } - def __init__(self, *, policy_definitions, policy_type=None, display_name: str=None, description: str=None, metadata=None, parameters=None, **kwargs) -> None: + def __init__( + self, + *, + policy_type: Optional[Union[str, "PolicyType"]] = None, + display_name: Optional[str] = None, + description: Optional[str] = None, + metadata: Optional[object] = None, + parameters: Optional[object] = None, + policy_definitions: Optional[List["PolicyDefinitionReference"]] = None, + **kwargs + ): super(PolicySetDefinition, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None self.policy_type = policy_type self.display_name = display_name self.description = description self.metadata = metadata self.parameters = parameters self.policy_definitions = policy_definitions - self.id = None - self.name = None - self.type = None -class PolicySku(Model): +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 + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[PolicySetDefinition]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["PolicySetDefinition"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(PolicySetDefinitionListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class PolicySku(msrest.serialization.Model): """The policy sku. This property is optional, obsolete, and will be ignored. 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. + :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 @@ -347,7 +435,13 @@ class PolicySku(Model): 'tier': {'key': 'tier', 'type': 'str'}, } - def __init__(self, *, name: str, tier: str=None, **kwargs) -> None: + def __init__( + self, + *, + name: str, + tier: Optional[str] = None, + **kwargs + ): 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/_paged_models.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/models/_paged_models.py deleted file mode 100644 index f73a93f354db..000000000000 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/models/_paged_models.py +++ /dev/null @@ -1,53 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.paging import Paged - - -class PolicyAssignmentPaged(Paged): - """ - A paging container for iterating over a list of :class:`PolicyAssignment ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[PolicyAssignment]'} - } - - def __init__(self, *args, **kwargs): - - super(PolicyAssignmentPaged, self).__init__(*args, **kwargs) -class PolicyDefinitionPaged(Paged): - """ - A paging container for iterating over a list of :class:`PolicyDefinition ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[PolicyDefinition]'} - } - - def __init__(self, *args, **kwargs): - - super(PolicyDefinitionPaged, self).__init__(*args, **kwargs) -class PolicySetDefinitionPaged(Paged): - """ - A paging container for iterating over a list of :class:`PolicySetDefinition ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[PolicySetDefinition]'} - } - - def __init__(self, *args, **kwargs): - - super(PolicySetDefinitionPaged, self).__init__(*args, **kwargs) 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 f42fa2ecfcf9..1332dec1b945 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 @@ -1,32 +1,32 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from enum import Enum +class PolicyMode(str, Enum): + """The policy definition mode. Possible values are NotSpecified, Indexed, and All. + """ -class ResourceIdentityType(str, Enum): - - system_assigned = "SystemAssigned" - none = "None" - + not_specified = "NotSpecified" + indexed = "Indexed" + all = "All" class PolicyType(str, Enum): + """The type of policy definition. Possible values are NotSpecified, BuiltIn, and Custom. + """ not_specified = "NotSpecified" built_in = "BuiltIn" custom = "Custom" +class ResourceIdentityType(str, Enum): + """The identity type. + """ -class PolicyMode(str, Enum): - - not_specified = "NotSpecified" - indexed = "Indexed" - all = "All" + system_assigned = "SystemAssigned" + none = "None" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/operations/__init__.py index c7d7b8eb9d97..4583d62b03a4 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/operations/__init__.py @@ -1,12 +1,9 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from ._policy_assignments_operations import PolicyAssignmentsOperations 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 5f15fa54a000..5fc582d3007b 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 @@ -1,778 +1,670 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class PolicyAssignmentsOperations(object): """PolicyAssignmentsOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.policy.v2018_05_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for the operation. Constant value: "2018-05-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2018-05-01" - - self.config = config + self._config = config def delete( - self, scope, policy_assignment_name, custom_headers=None, raw=False, **operation_config): - """Deletes a policy assignment. - - This operation deletes a policy assignment, given its name and the - scope it was created in. The scope of a policy assignment is the part - of its ID preceding - '/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. - - :param scope: The scope of the policy assignment. Valid scopes are: - management group (format: - '/providers/Microsoft.Management/managementGroups/{managementGroup}'), - subscription (format: '/subscriptions/{subscriptionId}'), resource - group (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', - or resource (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' + self, + scope, # type: str + policy_assignment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyAssignment" + """This operation deletes a policy assignment, given its name and the scope it was created in. The scope of a policy assignment is the part of its ID preceding '/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + + Deletes a policy assignment. + + :param scope: The scope of the policy assignment. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. :type scope: str - :param policy_assignment_name: The name of the policy assignment to - delete. + :param policy_assignment_name: The name of the policy assignment to delete. :type policy_assignment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyAssignment or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyAssignment or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyAssignment or None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + # Construct URL - url = self.delete.metadata['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') + 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('PolicyAssignment', response) + deserialized = self._deserialize('PolicyAssignment', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} + delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore def create( - self, scope, policy_assignment_name, parameters, custom_headers=None, raw=False, **operation_config): - """Creates or updates a policy assignment. - - This operation creates or updates a policy assignment with the given - scope and name. Policy assignments apply to all resources contained - within their scope. For example, when you assign a policy at resource - group scope, that policy applies to all resources in the group. - - :param scope: The scope of the policy assignment. Valid scopes are: - management group (format: - '/providers/Microsoft.Management/managementGroups/{managementGroup}'), - subscription (format: '/subscriptions/{subscriptionId}'), resource - group (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', - or resource (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' + self, + scope, # type: str + policy_assignment_name, # type: str + parameters, # type: "models.PolicyAssignment" + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyAssignment" + """This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + + Creates or updates a policy assignment. + + :param scope: The scope of the policy assignment. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. :type scope: str :param policy_assignment_name: The name of the policy assignment. :type policy_assignment_name: str :param parameters: Parameters for the policy assignment. - :type parameters: - ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyAssignment - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyAssignment or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyAssignment or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :type parameters: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyAssignment + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {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.create.metadata['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') + 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'PolicyAssignment') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 201: - deserialized = self._deserialize('PolicyAssignment', response) + deserialized = self._deserialize('PolicyAssignment', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} + create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore def get( - self, scope, policy_assignment_name, custom_headers=None, raw=False, **operation_config): - """Retrieves a policy assignment. - - This operation retrieves a single policy assignment, given its name and - the scope it was created at. - - :param scope: The scope of the policy assignment. Valid scopes are: - management group (format: - '/providers/Microsoft.Management/managementGroups/{managementGroup}'), - subscription (format: '/subscriptions/{subscriptionId}'), resource - group (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', - or resource (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' + self, + scope, # type: str + policy_assignment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyAssignment" + """This operation retrieves a single policy assignment, given its name and the scope it was created at. + + Retrieves a policy assignment. + + :param scope: The scope of the policy assignment. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. :type scope: str - :param policy_assignment_name: The name of the policy assignment to - get. + :param policy_assignment_name: The name of the policy assignment to get. :type policy_assignment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyAssignment or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyAssignment or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + # Construct URL - url = self.get.metadata['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') + 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('PolicyAssignment', response) + deserialized = self._deserialize('PolicyAssignment', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} + get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore def list_for_resource_group( - self, resource_group_name, filter=None, custom_headers=None, raw=False, **operation_config): - """Retrieves all policy assignments that apply to a resource group. - - This operation retrieves the list of all policy assignments associated - with the given resource group in the given subscription that match the - optional given $filter. Valid values for $filter are: 'atScope()' or - 'policyDefinitionId eq '{value}''. If $filter is not provided, the - unfiltered list includes all policy assignments associated with the - resource group, including those that apply directly or apply from - containing scopes, as well as any applied to resources contained within - the resource group. If $filter=atScope() is provided, the returned list - includes all policy assignments that apply to the resource group, which - is everything in the unfiltered list except those applied to resources - contained within the resource group. If $filter=policyDefinitionId eq - '{value}' is provided, the returned list includes all policy - assignments of the policy definition whose id is {value} that apply to - the resource group. - - :param resource_group_name: The name of the resource group that - contains policy assignments. + self, + resource_group_name, # type: str + filter=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.PolicyAssignmentListResult"] + """This operation retrieves the list of all policy assignments associated with the given resource group in the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource group, including those that apply directly or apply from containing scopes, as well as any applied to resources contained within the resource group. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource group, which is everything in the unfiltered list except those applied to resources contained within the resource group. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource group. + + Retrieves all policy assignments that apply to a resource group. + + :param resource_group_name: The name of the resource group that contains policy assignments. :type resource_group_name: str - :param filter: The filter to apply on the operation. Valid values for - $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If - $filter is not provided, no filtering is performed. + :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()' + or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. :type filter: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of PolicyAssignment - :rtype: - ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyAssignmentPaged[~azure.mgmt.resource.policy.v2018_05_01.models.PolicyAssignment] - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_for_resource_group.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) - - return response + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.PolicyAssignmentPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list_for_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments'} + return ItemPaged( + get_next, extract_data + ) + list_for_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments'} # type: ignore def list_for_resource( - self, resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, filter=None, custom_headers=None, raw=False, **operation_config): - """Retrieves all policy assignments that apply to a resource. - - This operation retrieves the list of all policy assignments associated - with the specified resource in the given resource group and - subscription that match the optional given $filter. Valid values for - $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If - $filter is not provided, the unfiltered list includes all policy - assignments associated with the resource, including those that apply - directly or from all containing scopes, as well as any applied to - resources contained within the resource. If $filter=atScope() is - provided, the returned list includes all policy assignments that apply - to the resource, which is everything in the unfiltered list except - those applied to resources contained within the resource. If - $filter=policyDefinitionId eq '{value}' is provided, the returned list - includes all policy assignments of the policy definition whose id is - {value} that apply to the resource. Three parameters plus the resource - name are used to identify a specific resource. If the resource is not - part of a parent resource (the more common case), the parent resource - path should not be provided (or provided as ''). For example a web app - could be specified as ({resourceProviderNamespace} == 'Microsoft.Web', - {parentResourcePath} == '', {resourceType} == 'sites', {resourceName} - == 'MyWebApp'). If the resource is part of a parent resource, then all - parameters should be provided. For example a virtual machine DNS name - could be specified as ({resourceProviderNamespace} == - 'Microsoft.Compute', {parentResourcePath} == - 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames', - {resourceName} == 'MyComputerName'). A convenient alternative to - providing the namespace and type name separately is to provide both in - the {resourceType} parameter, format: ({resourceProviderNamespace} == - '', {parentResourcePath} == '', {resourceType} == - 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). - - :param resource_group_name: The name of the resource group containing - the resource. + self, + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + filter=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.PolicyAssignmentListResult"] + """This operation retrieves the list of all policy assignments associated with the specified resource in the given resource group and subscription that match the optional given $filter. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource, including those that apply directly or from all containing scopes, as well as any applied to resources contained within the resource. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource, which is everything in the unfiltered list except those applied to resources contained within the resource. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource. Three parameters plus the resource name are used to identify a specific resource. If the resource is not part of a parent resource (the more common case), the parent resource path should not be provided (or provided as ''). For example a web app could be specified as ({resourceProviderNamespace} == 'Microsoft.Web', {parentResourcePath} == '', {resourceType} == 'sites', {resourceName} == 'MyWebApp'). If the resource is part of a parent resource, then all parameters should be provided. For example a virtual machine DNS name could be specified as ({resourceProviderNamespace} == 'Microsoft.Compute', {parentResourcePath} == 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames', {resourceName} == 'MyComputerName'). A convenient alternative to providing the namespace and type name separately is to provide both in the {resourceType} parameter, format: ({resourceProviderNamespace} == '', {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). + + Retrieves all policy assignments that apply to a resource. + + :param resource_group_name: The name of the resource group containing the resource. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource - provider. For example, the namespace of a virtual machine is - Microsoft.Compute (from Microsoft.Compute/virtualMachines) + :param resource_provider_namespace: The namespace of the resource provider. For example, the + namespace of a virtual machine is Microsoft.Compute (from Microsoft.Compute/virtualMachines). :type resource_provider_namespace: str - :param parent_resource_path: The parent resource path. Use empty - string if there is none. + :param parent_resource_path: The parent resource path. Use empty string if there is none. :type parent_resource_path: str - :param resource_type: The resource type name. For example the type - name of a web app is 'sites' (from Microsoft.Web/sites). + :param resource_type: The resource type name. For example the type name of a web app is 'sites' + (from Microsoft.Web/sites). :type resource_type: str :param resource_name: The name of the resource. :type resource_name: str - :param filter: The filter to apply on the operation. Valid values for - $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If - $filter is not provided, no filtering is performed. + :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()' + or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. :type filter: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of PolicyAssignment - :rtype: - ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyAssignmentPaged[~azure.mgmt.resource.policy.v2018_05_01.models.PolicyAssignment] - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_for_resource.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.PolicyAssignmentPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_for_resource.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments'} + 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 def list( - self, filter=None, custom_headers=None, raw=False, **operation_config): - """Retrieves all policy assignments that apply to a subscription. - - This operation retrieves the list of all policy assignments associated - with the given subscription that match the optional given $filter. - Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq - '{value}''. If $filter is not provided, the unfiltered list includes - all policy assignments associated with the subscription, including - those that apply directly or from management groups that contain the - given subscription, as well as any applied to objects contained within - the subscription. If $filter=atScope() is provided, the returned list - includes all policy assignments that apply to the subscription, which - is everything in the unfiltered list except those applied to objects - contained within the subscription. If $filter=policyDefinitionId eq - '{value}' is provided, the returned list includes all policy - assignments of the policy definition whose id is {value}. - - :param filter: The filter to apply on the operation. Valid values for - $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If - $filter is not provided, no filtering is performed. + self, + filter=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.PolicyAssignmentListResult"] + """This operation retrieves the list of all policy assignments associated with the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the subscription, including those that apply directly or from management groups that contain the given subscription, as well as any applied to objects contained within the subscription. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the subscription, which is everything in the unfiltered list except those applied to objects contained within the subscription. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value}. + + Retrieves all policy assignments that apply to a subscription. + + :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()' + or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. :type filter: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of PolicyAssignment - :rtype: - ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyAssignmentPaged[~azure.mgmt.resource.policy.v2018_05_01.models.PolicyAssignment] - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['url'] + url = self.list.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_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 = {} + 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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) - - return response + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.PolicyAssignmentPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments'} # type: ignore def delete_by_id( - self, policy_assignment_id, custom_headers=None, raw=False, **operation_config): - """Deletes a policy assignment. - - This operation deletes the policy with the given ID. Policy assignment - IDs have this format: - '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. - Valid formats for {scope} are: - '/providers/Microsoft.Management/managementGroups/{managementGroup}' - (management group), '/subscriptions/{subscriptionId}' (subscription), - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' - (resource group), or - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' - (resource). - - :param policy_assignment_id: The ID of the policy assignment to - delete. Use the format + self, + policy_assignment_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyAssignment" + """This operation deletes the policy with the given ID. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid formats for {scope} are: '/providers/Microsoft.Management/managementGroups/{managementGroup}' (management group), '/subscriptions/{subscriptionId}' (subscription), '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' (resource group), or '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' (resource). + + Deletes a policy assignment. + + :param policy_assignment_id: The ID of the policy assignment to delete. Use the format '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. :type policy_assignment_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyAssignment or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyAssignment or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyAssignment or None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + # Construct URL - url = self.delete_by_id.metadata['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) + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('PolicyAssignment', response) + deserialized = self._deserialize('PolicyAssignment', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - delete_by_id.metadata = {'url': '/{policyAssignmentId}'} + delete_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore def create_by_id( - self, policy_assignment_id, parameters, custom_headers=None, raw=False, **operation_config): - """Creates or updates a policy assignment. - - This operation creates or updates the policy assignment with the given - ID. Policy assignments made on a scope apply to all resources contained - in that scope. For example, when you assign a policy to a resource - group that policy applies to all resources in the group. Policy - assignment IDs have this format: - '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. - Valid scopes are: management group (format: - '/providers/Microsoft.Management/managementGroups/{managementGroup}'), - subscription (format: '/subscriptions/{subscriptionId}'), resource - group (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', - or resource (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. - - :param policy_assignment_id: The ID of the policy assignment to - create. Use the format + self, + policy_assignment_id, # type: str + parameters, # type: "models.PolicyAssignment" + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyAssignment" + """This operation creates or updates the policy assignment with the given ID. Policy assignments made on a scope apply to all resources contained in that scope. For example, when you assign a policy to a resource group that policy applies to all resources in the group. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + + Creates or updates a policy assignment. + + :param policy_assignment_id: The ID of the policy assignment to create. Use the format '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. :type policy_assignment_id: str :param parameters: Parameters for policy assignment. - :type parameters: - ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyAssignment - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyAssignment or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyAssignment or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :type parameters: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyAssignment + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {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.create_by_id.metadata['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) + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'PolicyAssignment') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 201: - deserialized = self._deserialize('PolicyAssignment', response) + deserialized = self._deserialize('PolicyAssignment', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create_by_id.metadata = {'url': '/{policyAssignmentId}'} + create_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore def get_by_id( - self, policy_assignment_id, custom_headers=None, raw=False, **operation_config): - """Retrieves the policy assignment with the given ID. - - The operation retrieves the policy assignment with the given ID. Policy - assignment IDs have this format: - '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. - Valid scopes are: management group (format: - '/providers/Microsoft.Management/managementGroups/{managementGroup}'), - subscription (format: '/subscriptions/{subscriptionId}'), resource - group (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', - or resource (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. - - :param policy_assignment_id: The ID of the policy assignment to get. - Use the format + self, + policy_assignment_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyAssignment" + """The operation retrieves the policy assignment with the given ID. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + + Retrieves the policy assignment with the given ID. + + :param policy_assignment_id: The ID of the policy assignment to get. Use the format '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. :type policy_assignment_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyAssignment or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyAssignment or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + # Construct URL - url = self.get_by_id.metadata['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) + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('PolicyAssignment', response) + deserialized = self._deserialize('PolicyAssignment', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/{policyAssignmentId}'} + 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 dd9410192449..7048c08bbcc1 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 @@ -1,686 +1,646 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class PolicyDefinitionsOperations(object): """PolicyDefinitionsOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.policy.v2018_05_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for the operation. Constant value: "2018-05-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2018-05-01" - - self.config = config + self._config = config def create_or_update( - self, policy_definition_name, parameters, custom_headers=None, raw=False, **operation_config): - """Creates or updates a policy definition in a subscription. + self, + policy_definition_name, # type: str + parameters, # type: "models.PolicyDefinition" + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyDefinition" + """This operation creates or updates a policy definition in the given subscription with the given name. - This operation creates or updates a policy definition in the given - subscription with the given name. + Creates or updates a policy definition in a subscription. - :param policy_definition_name: The name of the policy definition to - create. + :param policy_definition_name: The name of the policy definition to create. :type policy_definition_name: str :param parameters: The policy definition properties. - :type parameters: - ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinition - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyDefinition or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinition or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :type parameters: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinition + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyDefinition"] + error_map = {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.create_or_update.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'PolicyDefinition') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [201]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 201: - deserialized = self._deserialize('PolicyDefinition', response) + deserialized = self._deserialize('PolicyDefinition', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore def delete( - self, policy_definition_name, custom_headers=None, raw=False, **operation_config): - """Deletes a policy definition in a subscription. + self, + policy_definition_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """This operation deletes the policy definition in the given subscription with the given name. - This operation deletes the policy definition in the given subscription - with the given name. + Deletes a policy definition in a subscription. - :param policy_definition_name: The name of the policy definition to - delete. + :param policy_definition_name: The name of the policy definition to delete. :type policy_definition_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + # Construct URL - url = self.delete.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} + delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore def get( - self, policy_definition_name, custom_headers=None, raw=False, **operation_config): - """Retrieves a policy definition in a subscription. + self, + policy_definition_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyDefinition" + """This operation retrieves the policy definition in the given subscription with the given name. - This operation retrieves the policy definition in the given - subscription with the given name. + Retrieves a policy definition in a subscription. - :param policy_definition_name: The name of the policy definition to - get. + :param policy_definition_name: The name of the policy definition to get. :type policy_definition_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyDefinition or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinition or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinition + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + # Construct URL - url = self.get.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('PolicyDefinition', response) + deserialized = self._deserialize('PolicyDefinition', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore def get_built_in( - self, policy_definition_name, custom_headers=None, raw=False, **operation_config): - """Retrieves a built-in policy definition. + self, + policy_definition_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyDefinition" + """This operation retrieves the built-in policy definition with the given name. - This operation retrieves the built-in policy definition with the given - name. + Retrieves a built-in policy definition. - :param policy_definition_name: The name of the built-in policy - definition to get. + :param policy_definition_name: The name of the built-in policy definition to get. :type policy_definition_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyDefinition or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinition or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinition + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + # Construct URL - url = self.get_built_in.metadata['url'] + url = self.get_built_in.metadata['url'] # type: ignore path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str') + 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('PolicyDefinition', response) + deserialized = self._deserialize('PolicyDefinition', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} + get_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore def create_or_update_at_management_group( - self, policy_definition_name, parameters, management_group_id, custom_headers=None, raw=False, **operation_config): - """Creates or updates a policy definition in a management group. - - This operation creates or updates a policy definition in the given - management group with the given name. - - :param policy_definition_name: The name of the policy definition to - create. + self, + policy_definition_name, # type: str + management_group_id, # type: str + parameters, # type: "models.PolicyDefinition" + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyDefinition" + """This operation creates or updates a policy definition in the given management group with the given name. + + Creates or updates a policy definition in a management group. + + :param policy_definition_name: The name of the policy definition to create. :type policy_definition_name: str - :param parameters: The policy definition properties. - :type parameters: - ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinition :param management_group_id: The ID of the management group. :type management_group_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyDefinition or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinition or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :param parameters: The policy definition properties. + :type parameters: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinition + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyDefinition"] + error_map = {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.create_or_update_at_management_group.metadata['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') + 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'PolicyDefinition') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [201]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 201: - deserialized = self._deserialize('PolicyDefinition', response) + deserialized = self._deserialize('PolicyDefinition', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + 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}'} + create_or_update_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore def delete_at_management_group( - self, policy_definition_name, management_group_id, custom_headers=None, raw=False, **operation_config): - """Deletes a policy definition in a management group. + self, + policy_definition_name, # type: str + management_group_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """This operation deletes the policy definition in the given management group with the given name. - This operation deletes the policy definition in the given management - group with the given name. + Deletes a policy definition in a management group. - :param policy_definition_name: The name of the policy definition to - delete. + :param policy_definition_name: The name of the policy definition to delete. :type policy_definition_name: str :param management_group_id: The ID of the management group. :type management_group_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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'] + 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') + 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} + if cls: + return cls(pipeline_response, None, {}) + + delete_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore def get_at_management_group( - self, policy_definition_name, management_group_id, custom_headers=None, raw=False, **operation_config): - """Retrieve a policy definition in a management group. + self, + policy_definition_name, # type: str + management_group_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyDefinition" + """This operation retrieves the policy definition in the given management group with the given name. - This operation retrieves the policy definition in the given management - group with the given name. + Retrieve a policy definition in a management group. - :param policy_definition_name: The name of the policy definition to - get. + :param policy_definition_name: The name of the policy definition to get. :type policy_definition_name: str :param management_group_id: The ID of the management group. :type management_group_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyDefinition or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinition or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinition + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + # Construct URL - url = self.get_at_management_group.metadata['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') + 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('PolicyDefinition', response) + deserialized = self._deserialize('PolicyDefinition', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} + get_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore def list( - self, custom_headers=None, raw=False, **operation_config): - """Retrieves policy definitions in a subscription. - - This operation retrieves a list of all the policy definitions in a - given subscription. - - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of PolicyDefinition - :rtype: - ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinitionPaged[~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinition] - :raises: :class:`CloudError` + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.PolicyDefinitionListResult"] + """This operation retrieves a list of all the policy definitions in a given subscription. + + Retrieves policy definitions in a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['url'] + url = self.list.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyDefinitionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.PolicyDefinitionPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions'} # type: ignore def list_built_in( - self, custom_headers=None, raw=False, **operation_config): - """Retrieve built-in policy definitions. - - This operation retrieves a list of all the built-in policy definitions. - - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of PolicyDefinition - :rtype: - ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinitionPaged[~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinition] - :raises: :class:`CloudError` + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.PolicyDefinitionListResult"] + """This operation retrieves a list of all the built-in policy definitions. + + Retrieve 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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_built_in.metadata['url'] - + url = self.list_built_in.metadata['url'] # type: ignore # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyDefinitionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.PolicyDefinitionPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policyDefinitions'} + return ItemPaged( + get_next, extract_data + ) + list_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policyDefinitions'} # type: ignore def list_by_management_group( - self, management_group_id, custom_headers=None, raw=False, **operation_config): - """Retrieve policy definitions in a management group. + self, + management_group_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.PolicyDefinitionListResult"] + """This operation retrieves a list of all the policy definitions in a given management group. - This operation retrieves a list of all the policy definitions in a - given management group. + Retrieve policy definitions in a management group. :param management_group_id: The ID of the management group. :type management_group_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of PolicyDefinition - :rtype: - ~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinitionPaged[~azure.mgmt.resource.policy.v2018_05_01.models.PolicyDefinition] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_by_management_group.metadata['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') + 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyDefinitionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.PolicyDefinitionPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_by_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions'} + return ItemPaged( + get_next, extract_data + ) + list_by_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions'} # type: ignore 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 eaa9f9c3e00b..0d41ef50d5f0 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 @@ -1,680 +1,666 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class PolicySetDefinitionsOperations(object): """PolicySetDefinitionsOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.policy.v2018_05_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for the operation. Constant value: "2018-05-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2018-05-01" - - self.config = config + self._config = config def create_or_update( - self, policy_set_definition_name, parameters, custom_headers=None, raw=False, **operation_config): - """Creates or updates a policy set definition. + self, + policy_set_definition_name, # type: str + parameters, # type: "models.PolicySetDefinition" + **kwargs # type: Any + ): + # type: (...) -> "models.PolicySetDefinition" + """This operation creates or updates a policy set definition in the given subscription with the given name. - This operation creates or updates a policy set definition in the given - subscription with the given name. + Creates or updates a policy set definition. - :param policy_set_definition_name: The name of the policy set - definition to create. + :param policy_set_definition_name: The name of the policy set definition to create. :type policy_set_definition_name: str :param parameters: The policy set definition properties. - :type parameters: - ~azure.mgmt.resource.policy.v2018_05_01.models.PolicySetDefinition - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicySetDefinition or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2018_05_01.models.PolicySetDefinition or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :type parameters: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicySetDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicySetDefinition + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicySetDefinition"] + error_map = {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.create_or_update.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'PolicySetDefinition') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('PolicySetDefinition', response) + deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('PolicySetDefinition', response) + deserialized = self._deserialize('PolicySetDefinition', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore def delete( - self, policy_set_definition_name, custom_headers=None, raw=False, **operation_config): - """Deletes a policy set definition. + self, + policy_set_definition_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """This operation deletes the policy set definition in the given subscription with the given name. - This operation deletes the policy set definition in the given - subscription with the given name. + Deletes a policy set definition. - :param policy_set_definition_name: The name of the policy set - definition to delete. + :param policy_set_definition_name: The name of the policy set definition to delete. :type policy_set_definition_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + # Construct URL - url = self.delete.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} + delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore def get( - self, policy_set_definition_name, custom_headers=None, raw=False, **operation_config): - """Retrieves a policy set definition. + self, + policy_set_definition_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.PolicySetDefinition" + """This operation retrieves the policy set definition in the given subscription with the given name. - This operation retrieves the policy set definition in the given - subscription with the given name. + Retrieves a policy set definition. - :param policy_set_definition_name: The name of the policy set - definition to get. + :param policy_set_definition_name: The name of the policy set definition to get. :type policy_set_definition_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicySetDefinition or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2018_05_01.models.PolicySetDefinition or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicySetDefinition + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicySetDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + # Construct URL - url = self.get.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('PolicySetDefinition', response) + deserialized = self._deserialize('PolicySetDefinition', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore def get_built_in( - self, policy_set_definition_name, custom_headers=None, raw=False, **operation_config): - """Retrieves a built in policy set definition. + self, + policy_set_definition_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.PolicySetDefinition" + """This operation retrieves the built-in policy set definition with the given name. - This operation retrieves the built-in policy set definition with the - given name. + Retrieves a built in policy set definition. - :param policy_set_definition_name: The name of the policy set - definition to get. + :param policy_set_definition_name: The name of the policy set definition to get. :type policy_set_definition_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicySetDefinition or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2018_05_01.models.PolicySetDefinition or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicySetDefinition + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicySetDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + # Construct URL - url = self.get_built_in.metadata['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') + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('PolicySetDefinition', response) + deserialized = self._deserialize('PolicySetDefinition', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} + get_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore def list( - self, custom_headers=None, raw=False, **operation_config): - """Retrieves the policy set definitions for a subscription. - - This operation retrieves a list of all the policy set definitions in - the given subscription. - - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of PolicySetDefinition - :rtype: - ~azure.mgmt.resource.policy.v2018_05_01.models.PolicySetDefinitionPaged[~azure.mgmt.resource.policy.v2018_05_01.models.PolicySetDefinition] - :raises: - :class:`ErrorResponseException` + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.PolicySetDefinitionListResult"] + """This operation retrieves a list of all the policy set definitions in the given subscription. + + Retrieves 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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['url'] + url = self.list.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('PolicySetDefinitionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) - - return response + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.PolicySetDefinitionPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions'} # type: ignore def list_built_in( - self, custom_headers=None, raw=False, **operation_config): - """Retrieves built-in policy set definitions. - - This operation retrieves a list of all the built-in policy set - definitions. - - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of PolicySetDefinition - :rtype: - ~azure.mgmt.resource.policy.v2018_05_01.models.PolicySetDefinitionPaged[~azure.mgmt.resource.policy.v2018_05_01.models.PolicySetDefinition] - :raises: - :class:`ErrorResponseException` + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.PolicySetDefinitionListResult"] + """This operation retrieves a list of all the built-in policy set definitions. + + Retrieves 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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_built_in.metadata['url'] - + url = self.list_built_in.metadata['url'] # type: ignore # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('PolicySetDefinitionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) - - return response + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.PolicySetDefinitionPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policySetDefinitions'} + return ItemPaged( + get_next, extract_data + ) + list_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policySetDefinitions'} # type: ignore def create_or_update_at_management_group( - self, policy_set_definition_name, parameters, management_group_id, custom_headers=None, raw=False, **operation_config): - """Creates or updates a policy set definition. - - This operation creates or updates a policy set definition in the given - management group with the given name. - - :param policy_set_definition_name: The name of the policy set - definition to create. + self, + policy_set_definition_name, # type: str + management_group_id, # type: str + parameters, # type: "models.PolicySetDefinition" + **kwargs # type: Any + ): + # type: (...) -> "models.PolicySetDefinition" + """This operation creates or updates a policy set definition in the given management group with the given name. + + Creates or updates a policy set definition. + + :param policy_set_definition_name: The name of the policy set definition to create. :type policy_set_definition_name: str - :param parameters: The policy set definition properties. - :type parameters: - ~azure.mgmt.resource.policy.v2018_05_01.models.PolicySetDefinition :param management_group_id: The ID of the management group. :type management_group_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicySetDefinition or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2018_05_01.models.PolicySetDefinition or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :param parameters: The policy set definition properties. + :type parameters: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicySetDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicySetDefinition + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicySetDefinition"] + error_map = {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.create_or_update_at_management_group.metadata['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') + 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'PolicySetDefinition') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('PolicySetDefinition', response) + deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('PolicySetDefinition', response) + deserialized = self._deserialize('PolicySetDefinition', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + 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}'} + create_or_update_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore def delete_at_management_group( - self, policy_set_definition_name, management_group_id, custom_headers=None, raw=False, **operation_config): - """Deletes a policy set definition. + self, + policy_set_definition_name, # type: str + management_group_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """This operation deletes the policy set definition in the given management group with the given name. - This operation deletes the policy set definition in the given - management group with the given name. + Deletes a policy set definition. - :param policy_set_definition_name: The name of the policy set - definition to delete. + :param policy_set_definition_name: The name of the policy set definition to delete. :type policy_set_definition_name: str :param management_group_id: The ID of the management group. :type management_group_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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'] + 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') + 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} + delete_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore def get_at_management_group( - self, policy_set_definition_name, management_group_id, custom_headers=None, raw=False, **operation_config): - """Retrieves a policy set definition. + self, + policy_set_definition_name, # type: str + management_group_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.PolicySetDefinition" + """This operation retrieves the policy set definition in the given management group with the given name. - This operation retrieves the policy set definition in the given - management group with the given name. + Retrieves a policy set definition. - :param policy_set_definition_name: The name of the policy set - definition to get. + :param policy_set_definition_name: The name of the policy set definition to get. :type policy_set_definition_name: str :param management_group_id: The ID of the management group. :type management_group_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicySetDefinition or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2018_05_01.models.PolicySetDefinition or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2018_05_01.models.PolicySetDefinition + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicySetDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + # Construct URL - url = self.get_at_management_group.metadata['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') + 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('PolicySetDefinition', response) + deserialized = self._deserialize('PolicySetDefinition', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} + get_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore def list_by_management_group( - self, management_group_id, custom_headers=None, raw=False, **operation_config): - """Retrieves all policy set definitions in management group. + self, + management_group_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.PolicySetDefinitionListResult"] + """This operation retrieves a list of all the a policy set definition in the given management group. - This operation retrieves a list of all the a policy set definition in - the given management group. + Retrieves all policy set definitions in management group. :param management_group_id: The ID of the management group. :type management_group_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of PolicySetDefinition - :rtype: - ~azure.mgmt.resource.policy.v2018_05_01.models.PolicySetDefinitionPaged[~azure.mgmt.resource.policy.v2018_05_01.models.PolicySetDefinition] - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_by_management_group.metadata['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') + 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('PolicySetDefinitionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) - - return response + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.PolicySetDefinitionPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list_by_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions'} + return ItemPaged( + get_next, extract_data + ) + list_by_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/py.typed b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file 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 deleted file mode 100644 index 5bfc801ce220..000000000000 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2018_05_01/version.py +++ /dev/null @@ -1,13 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -VERSION = "2018-05-01" - 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 56bf47bfb9e4..e4bba9352a5c 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 @@ -1,19 +1,16 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._configuration import PolicyClientConfiguration from ._policy_client import PolicyClient -__all__ = ['PolicyClient', 'PolicyClientConfiguration'] - -from .version import VERSION - -__version__ = VERSION +__all__ = ['PolicyClient'] +try: + from ._patch import patch_sdk + patch_sdk() +except ImportError: + pass 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 ede4f42045d0..c994ab13e018 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 @@ -1,48 +1,69 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrestazure import AzureConfiguration -from .version import VERSION +from typing import TYPE_CHECKING +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + + from azure.core.credentials import TokenCredential + +VERSION = "unknown" + +class PolicyClientConfiguration(Configuration): + """Configuration for PolicyClient. -class PolicyClientConfiguration(AzureConfiguration): - """Configuration for PolicyClient Note that all parameters used to create this instance are saved as instance attributes. - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` + :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 """ def __init__( - self, credentials, subscription_id, base_url=None): - - if credentials is None: - raise ValueError("Parameter 'credentials' must not be None.") + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + 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.") - if not base_url: - base_url = 'https://management.azure.com' + super(PolicyClientConfiguration, self).__init__(**kwargs) - super(PolicyClientConfiguration, self).__init__(base_url) - - # Starting Autorest.Python 4.0.64, make connection pool activated by default - self.keep_alive = True - - self.add_user_agent('azure-mgmt-resource/{}'.format(VERSION)) - self.add_user_agent('Azure-SDK-For-Python') - - self.credentials = credentials + self.credential = credential self.subscription_id = subscription_id + self.api_version = "2019-01-01" + self.credential_scopes = ['https://management.azure.com/.default'] + self.credential_scopes.extend(kwargs.pop('credential_scopes', [])) + kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + 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) 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 new file mode 100644 index 000000000000..68584dcd8955 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/_metadata.json @@ -0,0 +1,55 @@ +{ + "chosen_version": "2019-01-01", + "total_api_version_list": ["2019-01-01"], + "client": { + "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." + }, + "global_parameters": { + "sync_method": { + "credential": { + "method_signature": "credential, # type: \"TokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials.TokenCredential", + "required": true + }, + "subscription_id": { + "method_signature": "subscription_id, # type: str", + "description": "The ID of the target subscription.", + "docstring_type": "str", + "required": true + } + }, + "async_method": { + "credential": { + "method_signature": "credential, # type: \"AsyncTokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + }, + "subscription_id": { + "method_signature": "subscription_id, # type: str", + "description": "The ID of the target subscription.", + "docstring_type": "str", + "required": true + } + }, + "constant": { + }, + "call": "credential, subscription_id" + }, + "config": { + "credential": true, + "credential_scopes": ["https://management.azure.com/.default"] + }, + "operation_groups": { + "policy_assignments": "PolicyAssignmentsOperations", + "policy_definitions": "PolicyDefinitionsOperations", + "policy_set_definitions": "PolicySetDefinitionsOperations" + }, + "operation_mixins": { + }, + "sync_imports": "None", + "async_imports": "None" +} \ 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 062f287daae4..cb40c1a6ad4e 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 @@ -1,16 +1,19 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.service_client import SDKClient -from msrest import Serializer, Deserializer +from typing import TYPE_CHECKING + +from azure.mgmt.core import ARMPipelineClient +from msrest import Deserializer, Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional from ._configuration import PolicyClientConfiguration from .operations import PolicyAssignmentsOperations @@ -19,41 +22,56 @@ from . import models -class PolicyClient(SDKClient): +class PolicyClient(object): """To manage and control access to your resources, you can define customized policies and assign them at a scope. - :ivar config: Configuration for client. - :vartype config: PolicyClientConfiguration - - :ivar policy_assignments: PolicyAssignments operations + :ivar policy_assignments: PolicyAssignmentsOperations operations :vartype policy_assignments: azure.mgmt.resource.policy.v2019_01_01.operations.PolicyAssignmentsOperations - :ivar policy_definitions: PolicyDefinitions operations + :ivar policy_definitions: PolicyDefinitionsOperations operations :vartype policy_definitions: azure.mgmt.resource.policy.v2019_01_01.operations.PolicyDefinitionsOperations - :ivar policy_set_definitions: PolicySetDefinitions operations + :ivar policy_set_definitions: PolicySetDefinitionsOperations operations :vartype policy_set_definitions: azure.mgmt.resource.policy.v2019_01_01.operations.PolicySetDefinitionsOperations - - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` + :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. """ def __init__( - self, credentials, subscription_id, base_url=None): - - self.config = PolicyClientConfiguration(credentials, subscription_id, base_url) - super(PolicyClient, self).__init__(self.config.credentials, self.config) + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = 'https://management.azure.com' + self._config = PolicyClientConfiguration(credential, 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.api_version = '2019-01-01' self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self.policy_assignments = PolicyAssignmentsOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.policy_definitions = PolicyDefinitionsOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.policy_set_definitions = PolicySetDefinitionsOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> PolicyClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) 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 new file mode 100644 index 000000000000..df3c0beab48a --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/aio/__init__.py @@ -0,0 +1,10 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._policy_client_async import PolicyClient +__all__ = ['PolicyClient'] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/aio/_configuration_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/aio/_configuration_async.py new file mode 100644 index 000000000000..759b56db4a32 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/aio/_configuration_async.py @@ -0,0 +1,65 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + +VERSION = "unknown" + +class PolicyClientConfiguration(Configuration): + """Configuration for PolicyClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :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 + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + 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 + self.api_version = "2019-01-01" + self.credential_scopes = ['https://management.azure.com/.default'] + self.credential_scopes.extend(kwargs.pop('credential_scopes', [])) + kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs: Any + ) -> None: + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + 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) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/aio/_policy_client_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/aio/_policy_client_async.py new file mode 100644 index 000000000000..efae259474ce --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/aio/_policy_client_async.py @@ -0,0 +1,69 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, Optional + +from azure.mgmt.core import AsyncARMPipelineClient +from msrest import Deserializer, Serializer + +from ._configuration_async import PolicyClientConfiguration +from .operations_async import PolicyAssignmentsOperations +from .operations_async import PolicyDefinitionsOperations +from .operations_async import PolicySetDefinitionsOperations +from .. import models + + +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.aio.operations_async.PolicyAssignmentsOperations + :ivar policy_definitions: PolicyDefinitionsOperations operations + :vartype policy_definitions: azure.mgmt.resource.policy.v2019_01_01.aio.operations_async.PolicyDefinitionsOperations + :ivar policy_set_definitions: PolicySetDefinitionsOperations operations + :vartype policy_set_definitions: azure.mgmt.resource.policy.v2019_01_01.aio.operations_async.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 + :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, + **kwargs: 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) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + + self.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 close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "PolicyClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/aio/operations_async/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/aio/operations_async/__init__.py new file mode 100644 index 000000000000..6a33a6888921 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/aio/operations_async/__init__.py @@ -0,0 +1,17 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._policy_assignments_operations_async import PolicyAssignmentsOperations +from ._policy_definitions_operations_async import PolicyDefinitionsOperations +from ._policy_set_definitions_operations_async import PolicySetDefinitionsOperations + +__all__ = [ + 'PolicyAssignmentsOperations', + 'PolicyDefinitionsOperations', + 'PolicySetDefinitionsOperations', +] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/aio/operations_async/_policy_assignments_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/aio/operations_async/_policy_assignments_operations_async.py new file mode 100644 index 000000000000..c8274213dc01 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/aio/operations_async/_policy_assignments_operations_async.py @@ -0,0 +1,657 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import 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 ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class PolicyAssignmentsOperations: + """PolicyAssignmentsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.policy.v2019_01_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def delete( + self, + scope: str, + policy_assignment_name: str, + **kwargs + ) -> "models.PolicyAssignment": + """This operation deletes a policy assignment, given its name and the scope it was created in. The scope of a policy assignment is the part of its ID preceding '/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + + Deletes a policy assignment. + + :param scope: The scope of the policy assignment. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + :type scope: str + :param policy_assignment_name: The name of the policy assignment to delete. + :type policy_assignment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyAssignment or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {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 = { + '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'] = 'application/json' + + # Construct and send request + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('PolicyAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore + + async def create( + self, + scope: str, + policy_assignment_name: str, + parameters: "models.PolicyAssignment", + **kwargs + ) -> "models.PolicyAssignment": + """This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + + Creates or updates a policy assignment. + + :param scope: The scope of the policy assignment. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + :type scope: str + :param policy_assignment_name: The name of the policy assignment. + :type policy_assignment_name: str + :param parameters: Parameters for the policy assignment. + :type parameters: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyAssignment + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-01-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore + + async def get( + self, + scope: str, + policy_assignment_name: str, + **kwargs + ) -> "models.PolicyAssignment": + """This operation retrieves a single policy assignment, given its name and the scope it was created at. + + Retrieves a policy assignment. + + :param scope: The scope of the policy assignment. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + :type scope: str + :param policy_assignment_name: The name of the policy assignment to get. + :type policy_assignment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-01-01" + + # 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'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore + + def list_for_resource_group( + self, + resource_group_name: str, + filter: Optional[str] = None, + **kwargs + ) -> AsyncIterable["models.PolicyAssignmentListResult"]: + """This operation retrieves the list of all policy assignments associated with the given resource group in the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource group, including those that apply directly or apply from containing scopes, as well as any applied to resources contained within the resource group. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource group, which is everything in the unfiltered list except those applied to resources contained within the resource group. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource group. + + Retrieves all policy assignments that apply to a resource group. + + :param resource_group_name: The name of the resource group that contains policy assignments. + :type resource_group_name: str + :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()' + 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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-01-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + 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 + + def list_for_resource( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + filter: Optional[str] = None, + **kwargs + ) -> AsyncIterable["models.PolicyAssignmentListResult"]: + """This operation retrieves the list of all policy assignments associated with the specified resource in the given resource group and subscription that match the optional given $filter. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource, including those that apply directly or from all containing scopes, as well as any applied to resources contained within the resource. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource, which is everything in the unfiltered list except those applied to resources contained within the resource. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource. Three parameters plus the resource name are used to identify a specific resource. If the resource is not part of a parent resource (the more common case), the parent resource path should not be provided (or provided as ''). For example a web app could be specified as ({resourceProviderNamespace} == 'Microsoft.Web', {parentResourcePath} == '', {resourceType} == 'sites', {resourceName} == 'MyWebApp'). If the resource is part of a parent resource, then all parameters should be provided. For example a virtual machine DNS name could be specified as ({resourceProviderNamespace} == 'Microsoft.Compute', {parentResourcePath} == 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames', {resourceName} == 'MyComputerName'). A convenient alternative to providing the namespace and type name separately is to provide both in the {resourceType} parameter, format: ({resourceProviderNamespace} == '', {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). + + Retrieves all policy assignments that apply to a resource. + + :param resource_group_name: The name of the resource group containing the resource. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. For example, the + namespace of a virtual machine is Microsoft.Compute (from Microsoft.Compute/virtualMachines). + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource path. Use empty string if there is none. + :type parent_resource_path: str + :param resource_type: The resource type name. For example the type name of a web app is 'sites' + (from Microsoft.Web/sites). + :type resource_type: str + :param resource_name: The name of the resource. + :type resource_name: str + :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()' + 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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-01-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + 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 + + def list( + self, + filter: Optional[str] = None, + **kwargs + ) -> AsyncIterable["models.PolicyAssignmentListResult"]: + """This operation retrieves the list of all policy assignments associated with the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the subscription, including those that apply directly or from management groups that contain the given subscription, as well as any applied to objects contained within the subscription. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the subscription, which is everything in the unfiltered list except those applied to objects contained within the subscription. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value}. + + Retrieves all policy assignments that apply to a subscription. + + :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()' + 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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-01-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + 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 + + async def delete_by_id( + self, + policy_assignment_id: str, + **kwargs + ) -> "models.PolicyAssignment": + """This operation deletes the policy with the given ID. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid formats for {scope} are: '/providers/Microsoft.Management/managementGroups/{managementGroup}' (management group), '/subscriptions/{subscriptionId}' (subscription), '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' (resource group), or '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' (resource). + + Deletes a policy assignment. + + :param policy_assignment_id: The ID of the policy assignment to delete. Use the format + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + :type policy_assignment_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyAssignment or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-01-01" + + # 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'] = 'application/json' + + # Construct and send request + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('PolicyAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + delete_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + + async def create_by_id( + self, + policy_assignment_id: str, + parameters: "models.PolicyAssignment", + **kwargs + ) -> "models.PolicyAssignment": + """This operation creates or updates the policy assignment with the given ID. Policy assignments made on a scope apply to all resources contained in that scope. For example, when you assign a policy to a resource group that policy applies to all resources in the group. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + + Creates or updates a policy assignment. + + :param policy_assignment_id: The ID of the policy assignment to create. Use the format + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + :type policy_assignment_id: str + :param parameters: Parameters for policy assignment. + :type parameters: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyAssignment + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-01-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + + async def get_by_id( + self, + policy_assignment_id: str, + **kwargs + ) -> "models.PolicyAssignment": + """The operation retrieves the policy assignment with the given ID. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + + Retrieves the policy assignment with the given ID. + + :param policy_assignment_id: The ID of the policy assignment to get. Use the format + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + :type policy_assignment_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-01-01" + + # 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'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyAssignment', pipeline_response) + + if cls: + 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_async/_policy_definitions_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/aio/operations_async/_policy_definitions_operations_async.py new file mode 100644 index 000000000000..08687b3f4eac --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/aio/operations_async/_policy_definitions_operations_async.py @@ -0,0 +1,632 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import 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 ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class PolicyDefinitionsOperations: + """PolicyDefinitionsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.policy.v2019_01_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def create_or_update( + self, + policy_definition_name: str, + parameters: "models.PolicyDefinition", + **kwargs + ) -> "models.PolicyDefinition": + """This operation creates or updates a policy definition in the given subscription with the given name. + + Creates or updates a policy definition in a subscription. + + :param policy_definition_name: The name of the policy definition to create. + :type policy_definition_name: str + :param parameters: The policy definition properties. + :type parameters: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-01-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + async def delete( + self, + policy_definition_name: str, + **kwargs + ) -> None: + """This operation deletes the policy definition in the given subscription with the given name. + + Deletes a policy definition in a subscription. + + :param policy_definition_name: The name of the policy definition to delete. + :type policy_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + async def get( + self, + policy_definition_name: str, + **kwargs + ) -> "models.PolicyDefinition": + """This operation retrieves the policy definition in the given subscription with the given name. + + Retrieves a policy definition in a subscription. + + :param policy_definition_name: The name of the policy definition to get. + :type policy_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-01-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + async def get_built_in( + self, + policy_definition_name: str, + **kwargs + ) -> "models.PolicyDefinition": + """This operation retrieves the built-in policy definition with the given name. + + Retrieves a built-in policy definition. + + :param policy_definition_name: The name of the built-in policy definition to get. + :type policy_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-01-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + async def create_or_update_at_management_group( + self, + policy_definition_name: str, + management_group_id: str, + parameters: "models.PolicyDefinition", + **kwargs + ) -> "models.PolicyDefinition": + """This operation creates or updates a policy definition in the given management group with the given name. + + Creates or updates a policy definition in a management group. + + :param policy_definition_name: The name of the policy definition to create. + :type policy_definition_name: str + :param management_group_id: The ID of the management group. + :type management_group_id: str + :param parameters: The policy definition properties. + :type parameters: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-01-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyDefinition', pipeline_response) + + if cls: + 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 + + async def delete_at_management_group( + self, + policy_definition_name: str, + management_group_id: str, + **kwargs + ) -> None: + """This operation deletes the policy definition in the given management group with the given name. + + Deletes a policy definition in a management group. + + :param policy_definition_name: The name of the policy definition to delete. + :type policy_definition_name: str + :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: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + async def get_at_management_group( + self, + policy_definition_name: str, + management_group_id: str, + **kwargs + ) -> "models.PolicyDefinition": + """This operation retrieves the policy definition in the given management group with the given name. + + Retrieve a policy definition in a management group. + + :param policy_definition_name: The name of the policy definition to get. + :type policy_definition_name: str + :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: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-01-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyDefinition', pipeline_response) + + if cls: + 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 + + def list( + self, + **kwargs + ) -> AsyncIterable["models.PolicyDefinitionListResult"]: + """This operation retrieves a list of all the policy definitions in a given subscription. + + Retrieves policy definitions in a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-01-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyDefinitionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions'} # type: ignore + + def list_built_in( + self, + **kwargs + ) -> AsyncIterable["models.PolicyDefinitionListResult"]: + """This operation retrieves a list of all the built-in policy definitions. + + Retrieve 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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-01-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyDefinitionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policyDefinitions'} # type: ignore + + def list_by_management_group( + self, + management_group_id: str, + **kwargs + ) -> AsyncIterable["models.PolicyDefinitionListResult"]: + """This operation retrieves a list of all the policy definitions in a given management group. + + Retrieve policy definitions in a 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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-01-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyDefinitionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/aio/operations_async/_policy_set_definitions_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/aio/operations_async/_policy_set_definitions_operations_async.py new file mode 100644 index 000000000000..4b6fc193bf92 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/aio/operations_async/_policy_set_definitions_operations_async.py @@ -0,0 +1,652 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import 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 ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class PolicySetDefinitionsOperations: + """PolicySetDefinitionsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.policy.v2019_01_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def create_or_update( + self, + policy_set_definition_name: str, + parameters: "models.PolicySetDefinition", + **kwargs + ) -> "models.PolicySetDefinition": + """This operation creates or updates a policy set definition in the given subscription with the given name. + + Creates or updates a policy set definition. + + :param policy_set_definition_name: The name of the policy set definition to create. + :type policy_set_definition_name: str + :param parameters: The policy set definition properties. + :type parameters: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicySetDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicySetDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicySetDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-01-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + async def delete( + self, + policy_set_definition_name: str, + **kwargs + ) -> None: + """This operation deletes the policy set definition in the given subscription with the given name. + + Deletes a policy set definition. + + :param policy_set_definition_name: The name of the policy set definition to delete. + :type policy_set_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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 = { + '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] + + # Construct and send request + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + async def get( + self, + policy_set_definition_name: str, + **kwargs + ) -> "models.PolicySetDefinition": + """This operation retrieves the policy set definition in the given subscription with the given name. + + Retrieves a policy set definition. + + :param policy_set_definition_name: The name of the policy set definition to get. + :type policy_set_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicySetDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicySetDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-01-01" + + # 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'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + async def get_built_in( + self, + policy_set_definition_name: str, + **kwargs + ) -> "models.PolicySetDefinition": + """This operation retrieves the built-in policy set definition with the given name. + + Retrieves a built in policy set definition. + + :param policy_set_definition_name: The name of the policy set definition to get. + :type policy_set_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicySetDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicySetDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-01-01" + + # 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'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + def list( + self, + **kwargs + ) -> AsyncIterable["models.PolicySetDefinitionListResult"]: + """This operation retrieves a list of all the policy set definitions in the given subscription. + + Retrieves 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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-01-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('PolicySetDefinitionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + 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 + + def list_built_in( + self, + **kwargs + ) -> AsyncIterable["models.PolicySetDefinitionListResult"]: + """This operation retrieves a list of all the built-in policy set definitions. + + Retrieves 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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-01-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('PolicySetDefinitionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + 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 + + async def create_or_update_at_management_group( + self, + policy_set_definition_name: str, + management_group_id: str, + parameters: "models.PolicySetDefinition", + **kwargs + ) -> "models.PolicySetDefinition": + """This operation creates or updates a policy set definition in the given management group with the given name. + + Creates or updates a policy set definition. + + :param policy_set_definition_name: The name of the policy set definition to create. + :type policy_set_definition_name: str + :param management_group_id: The ID of the management group. + :type management_group_id: str + :param parameters: The policy set definition properties. + :type parameters: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicySetDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicySetDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicySetDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-01-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + + if cls: + 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 + + async def delete_at_management_group( + self, + policy_set_definition_name: str, + management_group_id: str, + **kwargs + ) -> None: + """This operation deletes the policy set definition in the given management group with the given name. + + Deletes a policy set definition. + + :param policy_set_definition_name: The name of the policy set definition to delete. + :type policy_set_definition_name: str + :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: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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 = { + '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] + + # Construct and send request + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + async def get_at_management_group( + self, + policy_set_definition_name: str, + management_group_id: str, + **kwargs + ) -> "models.PolicySetDefinition": + """This operation retrieves the policy set definition in the given management group with the given name. + + Retrieves a policy set definition. + + :param policy_set_definition_name: The name of the policy set definition to get. + :type policy_set_definition_name: str + :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: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicySetDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicySetDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-01-01" + + # 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'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + + if cls: + 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 + + def list_by_management_group( + self, + management_group_id: str, + **kwargs + ) -> AsyncIterable["models.PolicySetDefinitionListResult"]: + """This operation retrieves a list of all the a policy set definition in the given management group. + + Retrieves all policy set definitions in 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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-01-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('PolicySetDefinitionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/models/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/models/__init__.py index e263f75db407..ef1404d38958 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/models/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/models/__init__.py @@ -1,49 +1,50 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- try: - from ._models_py3 import ErrorResponse, ErrorResponseException + from ._models_py3 import ErrorResponse from ._models_py3 import Identity from ._models_py3 import PolicyAssignment + from ._models_py3 import PolicyAssignmentListResult from ._models_py3 import PolicyDefinition + from ._models_py3 import PolicyDefinitionListResult from ._models_py3 import PolicyDefinitionReference from ._models_py3 import PolicySetDefinition + from ._models_py3 import PolicySetDefinitionListResult from ._models_py3 import PolicySku except (SyntaxError, ImportError): - from ._models import ErrorResponse, ErrorResponseException - from ._models import Identity - from ._models import PolicyAssignment - from ._models import PolicyDefinition - from ._models import PolicyDefinitionReference - from ._models import PolicySetDefinition - from ._models import PolicySku -from ._paged_models import PolicyAssignmentPaged -from ._paged_models import PolicyDefinitionPaged -from ._paged_models import PolicySetDefinitionPaged + from ._models import ErrorResponse # type: ignore + from ._models import Identity # type: ignore + from ._models import PolicyAssignment # type: ignore + from ._models import PolicyAssignmentListResult # type: ignore + from ._models import PolicyDefinition # type: ignore + from ._models import PolicyDefinitionListResult # type: ignore + from ._models import PolicyDefinitionReference # type: ignore + from ._models import PolicySetDefinition # type: ignore + from ._models import PolicySetDefinitionListResult # type: ignore + from ._models import PolicySku # type: ignore + from ._policy_client_enums import ( - ResourceIdentityType, PolicyType, + ResourceIdentityType, ) __all__ = [ - 'ErrorResponse', 'ErrorResponseException', + 'ErrorResponse', 'Identity', 'PolicyAssignment', + 'PolicyAssignmentListResult', 'PolicyDefinition', + 'PolicyDefinitionListResult', 'PolicyDefinitionReference', 'PolicySetDefinition', + 'PolicySetDefinitionListResult', 'PolicySku', - 'PolicyAssignmentPaged', - 'PolicyDefinitionPaged', - 'PolicySetDefinitionPaged', - 'ResourceIdentityType', 'PolicyType', + 'ResourceIdentityType', ] 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 1347248f9367..cedd91815a71 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 @@ -1,29 +1,17 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.serialization import Model -from msrest.exceptions import HttpOperationError +from azure.core.exceptions import HttpResponseError +import msrest.serialization -class CloudError(Model): - """CloudError. - """ - - _attribute_map = { - } - - -class ErrorResponse(Model): - """Error response indicates Azure Resource Manager is not able to process the - incoming request. The reason is provided in the error message. +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 @@ -39,39 +27,27 @@ class ErrorResponse(Model): 'error_message': {'key': 'errorMessage', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ErrorResponse, self).__init__(**kwargs) self.http_status = kwargs.get('http_status', None) self.error_code = kwargs.get('error_code', None) self.error_message = kwargs.get('error_message', None) -class ErrorResponseException(HttpOperationError): - """Server responsed with exception of type: 'ErrorResponse'. - - :param deserialize: A deserializer - :param response: Server response to be deserialized. - """ - - def __init__(self, deserialize, response, *args): - - super(ErrorResponseException, self).__init__(deserialize, response, 'ErrorResponse', *args) - - -class Identity(Model): +class Identity(msrest.serialization.Model): """Identity for the resource. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar principal_id: The principal ID of the resource identity. :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 + :param type: The identity type. Possible values include: "SystemAssigned", "None". + :type type: str or ~azure.mgmt.resource.policy.v2019_01_01.models.ResourceIdentityType """ _validation = { @@ -82,26 +58,41 @@ class Identity(Model): _attribute_map = { 'principal_id': {'key': 'principalId', 'type': 'str'}, 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'ResourceIdentityType'}, + 'type': {'key': 'type', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Identity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None self.type = kwargs.get('type', None) -class PolicyAssignment(Model): +class PolicyAssignment(msrest.serialization.Model): """The policy assignment. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. + :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 + :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 + 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 assigned. + :param 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 @@ -109,26 +100,10 @@ class PolicyAssignment(Model): :type not_scopes: list[str] :param parameters: Required if a parameter is used in policy rule. :type parameters: object - :param description: This message will be part of response in case of - policy violation. + :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: object - :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 - :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 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 """ _validation = { @@ -138,6 +113,12 @@ class PolicyAssignment(Model): } _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'sku': {'key': 'sku', 'type': 'PolicySku'}, + 'location': {'key': 'location', 'type': 'str'}, + 'identity': {'key': 'identity', 'type': 'Identity'}, 'display_name': {'key': 'properties.displayName', 'type': 'str'}, 'policy_definition_id': {'key': 'properties.policyDefinitionId', 'type': 'str'}, 'scope': {'key': 'properties.scope', 'type': 'str'}, @@ -145,16 +126,19 @@ class PolicyAssignment(Model): 'parameters': {'key': 'properties.parameters', 'type': 'object'}, 'description': {'key': 'properties.description', 'type': 'str'}, 'metadata': {'key': 'properties.metadata', 'type': 'object'}, - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'PolicySku'}, - 'location': {'key': 'location', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(PolicyAssignment, self).__init__(**kwargs) + self.id = None + self.type = None + self.name = None + self.sku = kwargs.get('sku', None) + self.location = kwargs.get('location', None) + self.identity = kwargs.get('identity', None) self.display_name = kwargs.get('display_name', None) self.policy_definition_id = kwargs.get('policy_definition_id', None) self.scope = kwargs.get('scope', None) @@ -162,25 +146,45 @@ def __init__(self, **kwargs): self.parameters = kwargs.get('parameters', None) self.description = kwargs.get('description', None) self.metadata = kwargs.get('metadata', None) - self.id = None - self.type = None - self.name = None - self.sku = kwargs.get('sku', None) - self.location = kwargs.get('location', None) - self.identity = kwargs.get('identity', None) -class PolicyDefinition(Model): +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 + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[PolicyAssignment]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(PolicyAssignmentListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class PolicyDefinition(msrest.serialization.Model): """The policy definition. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :param 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 + :ivar id: The ID of the policy definition. + :vartype id: str + :ivar name: The name of the policy definition. + :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, + 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, Microsoft.KeyVault.Data. :type mode: str @@ -194,13 +198,6 @@ class PolicyDefinition(Model): :type metadata: object :param parameters: Required if a parameter is used in policy rule. :type parameters: object - :ivar id: The ID of the policy definition. - :vartype id: str - :ivar name: The name of the policy definition. - :vartype name: str - :ivar type: The type of the resource - (Microsoft.Authorization/policyDefinitions). - :vartype type: str """ _validation = { @@ -210,6 +207,9 @@ class PolicyDefinition(Model): } _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, 'policy_type': {'key': 'properties.policyType', 'type': 'str'}, 'mode': {'key': 'properties.mode', 'type': 'str'}, 'display_name': {'key': 'properties.displayName', 'type': 'str'}, @@ -217,13 +217,16 @@ class PolicyDefinition(Model): 'policy_rule': {'key': 'properties.policyRule', 'type': 'object'}, 'metadata': {'key': 'properties.metadata', 'type': 'object'}, 'parameters': {'key': 'properties.parameters', 'type': 'object'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(PolicyDefinition, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None self.policy_type = kwargs.get('policy_type', None) self.mode = kwargs.get('mode', None) self.display_name = kwargs.get('display_name', None) @@ -231,16 +234,35 @@ def __init__(self, **kwargs): self.policy_rule = kwargs.get('policy_rule', None) self.metadata = kwargs.get('metadata', None) self.parameters = kwargs.get('parameters', None) - self.id = None - self.name = None - self.type = None -class PolicyDefinitionReference(Model): +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 + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[PolicyDefinition]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(PolicyDefinitionListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class PolicyDefinitionReference(msrest.serialization.Model): """The policy definition reference. - :param policy_definition_id: The ID of the policy definition or policy set - definition. + :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: object @@ -251,86 +273,106 @@ class PolicyDefinitionReference(Model): 'parameters': {'key': 'parameters', 'type': 'object'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(PolicyDefinitionReference, self).__init__(**kwargs) self.policy_definition_id = kwargs.get('policy_definition_id', None) self.parameters = kwargs.get('parameters', None) -class PolicySetDefinition(Model): +class PolicySetDefinition(msrest.serialization.Model): """The policy set definition. - Variables are only populated by the server, and will be ignored when - sending a request. - - All required parameters must be populated in order to send to Azure. + Variables are only populated by the server, and will be ignored when sending a request. - :param 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 + :ivar id: The ID of the policy set definition. + :vartype id: str + :ivar name: The name of the policy set definition. + :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, + 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: object - :param parameters: The policy set definition parameters that can be used - in policy definition references. - :type parameters: object - :param policy_definitions: Required. An array of policy definition + :param parameters: The policy set definition parameters that can be used in policy definition references. + :type parameters: object + :param policy_definitions: An array of policy definition references. :type policy_definitions: list[~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinitionReference] - :ivar id: The ID of the policy set definition. - :vartype id: str - :ivar name: The name of the policy set definition. - :vartype name: str - :ivar type: The type of the resource - (Microsoft.Authorization/policySetDefinitions). - :vartype type: str """ _validation = { - 'policy_definitions': {'required': True}, 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, } _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, 'policy_type': {'key': 'properties.policyType', 'type': 'str'}, 'display_name': {'key': 'properties.displayName', 'type': 'str'}, 'description': {'key': 'properties.description', 'type': 'str'}, 'metadata': {'key': 'properties.metadata', 'type': 'object'}, 'parameters': {'key': 'properties.parameters', 'type': 'object'}, 'policy_definitions': {'key': 'properties.policyDefinitions', 'type': '[PolicyDefinitionReference]'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(PolicySetDefinition, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None self.policy_type = kwargs.get('policy_type', None) self.display_name = kwargs.get('display_name', None) self.description = kwargs.get('description', None) self.metadata = kwargs.get('metadata', None) self.parameters = kwargs.get('parameters', None) self.policy_definitions = kwargs.get('policy_definitions', None) - self.id = None - self.name = None - self.type = None -class PolicySku(Model): +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 + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[PolicySetDefinition]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(PolicySetDefinitionListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class PolicySku(msrest.serialization.Model): """The policy sku. This property is optional, obsolete, and will be ignored. 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. + :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 @@ -345,7 +387,10 @@ class PolicySku(Model): 'tier': {'key': 'tier', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(PolicySku, self).__init__(**kwargs) - self.name = kwargs.get('name', None) + 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 6fd937e0bc05..c44338142d08 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 @@ -1,29 +1,21 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.serialization import Model -from msrest.exceptions import HttpOperationError +from typing import List, Optional, Union +from azure.core.exceptions import HttpResponseError +import msrest.serialization -class CloudError(Model): - """CloudError. - """ - - _attribute_map = { - } +from ._policy_client_enums import * -class ErrorResponse(Model): - """Error response indicates Azure Resource Manager is not able to process the - incoming request. The reason is provided in the error message. +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 @@ -39,39 +31,31 @@ class ErrorResponse(Model): 'error_message': {'key': 'errorMessage', 'type': 'str'}, } - def __init__(self, *, http_status: str=None, error_code: str=None, error_message: str=None, **kwargs) -> None: + def __init__( + self, + *, + http_status: Optional[str] = None, + error_code: Optional[str] = None, + error_message: Optional[str] = None, + **kwargs + ): super(ErrorResponse, self).__init__(**kwargs) self.http_status = http_status self.error_code = error_code self.error_message = error_message -class ErrorResponseException(HttpOperationError): - """Server responsed with exception of type: 'ErrorResponse'. - - :param deserialize: A deserializer - :param response: Server response to be deserialized. - """ - - def __init__(self, deserialize, response, *args): - - super(ErrorResponseException, self).__init__(deserialize, response, 'ErrorResponse', *args) - - -class Identity(Model): +class Identity(msrest.serialization.Model): """Identity for the resource. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar principal_id: The principal ID of the resource identity. :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 + :param type: The identity type. Possible values include: "SystemAssigned", "None". + :type type: str or ~azure.mgmt.resource.policy.v2019_01_01.models.ResourceIdentityType """ _validation = { @@ -82,26 +66,43 @@ class Identity(Model): _attribute_map = { 'principal_id': {'key': 'principalId', 'type': 'str'}, 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'ResourceIdentityType'}, + 'type': {'key': 'type', 'type': 'str'}, } - def __init__(self, *, type=None, **kwargs) -> None: + def __init__( + self, + *, + type: Optional[Union[str, "ResourceIdentityType"]] = None, + **kwargs + ): super(Identity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None self.type = type -class PolicyAssignment(Model): +class PolicyAssignment(msrest.serialization.Model): """The policy assignment. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. + :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 + :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 + 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 assigned. + :param 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 @@ -109,26 +110,10 @@ class PolicyAssignment(Model): :type not_scopes: list[str] :param parameters: Required if a parameter is used in policy rule. :type parameters: object - :param description: This message will be part of response in case of - policy violation. + :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: object - :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 - :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 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 """ _validation = { @@ -138,6 +123,12 @@ class PolicyAssignment(Model): } _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'sku': {'key': 'sku', 'type': 'PolicySku'}, + 'location': {'key': 'location', 'type': 'str'}, + 'identity': {'key': 'identity', 'type': 'Identity'}, 'display_name': {'key': 'properties.displayName', 'type': 'str'}, 'policy_definition_id': {'key': 'properties.policyDefinitionId', 'type': 'str'}, 'scope': {'key': 'properties.scope', 'type': 'str'}, @@ -145,16 +136,30 @@ class PolicyAssignment(Model): 'parameters': {'key': 'properties.parameters', 'type': 'object'}, 'description': {'key': 'properties.description', 'type': 'str'}, 'metadata': {'key': 'properties.metadata', 'type': 'object'}, - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'PolicySku'}, - 'location': {'key': 'location', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, } - def __init__(self, *, display_name: str=None, policy_definition_id: str=None, scope: str=None, not_scopes=None, parameters=None, description: str=None, metadata=None, sku=None, location: str=None, identity=None, **kwargs) -> None: + def __init__( + self, + *, + sku: Optional["PolicySku"] = None, + location: Optional[str] = None, + identity: Optional["Identity"] = None, + display_name: Optional[str] = None, + policy_definition_id: Optional[str] = None, + scope: Optional[str] = None, + not_scopes: Optional[List[str]] = None, + parameters: Optional[object] = None, + description: Optional[str] = None, + metadata: Optional[object] = None, + **kwargs + ): super(PolicyAssignment, self).__init__(**kwargs) + self.id = None + self.type = None + self.name = None + self.sku = sku + self.location = location + self.identity = identity self.display_name = display_name self.policy_definition_id = policy_definition_id self.scope = scope @@ -162,25 +167,48 @@ def __init__(self, *, display_name: str=None, policy_definition_id: str=None, sc self.parameters = parameters self.description = description self.metadata = metadata - self.id = None - self.type = None - self.name = None - self.sku = sku - self.location = location - self.identity = identity -class PolicyDefinition(Model): +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 + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[PolicyAssignment]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["PolicyAssignment"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(PolicyAssignmentListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class PolicyDefinition(msrest.serialization.Model): """The policy definition. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :param 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 + :ivar id: The ID of the policy definition. + :vartype id: str + :ivar name: The name of the policy definition. + :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, + 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, Microsoft.KeyVault.Data. :type mode: str @@ -194,13 +222,6 @@ class PolicyDefinition(Model): :type metadata: object :param parameters: Required if a parameter is used in policy rule. :type parameters: object - :ivar id: The ID of the policy definition. - :vartype id: str - :ivar name: The name of the policy definition. - :vartype name: str - :ivar type: The type of the resource - (Microsoft.Authorization/policyDefinitions). - :vartype type: str """ _validation = { @@ -210,6 +231,9 @@ class PolicyDefinition(Model): } _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, 'policy_type': {'key': 'properties.policyType', 'type': 'str'}, 'mode': {'key': 'properties.mode', 'type': 'str'}, 'display_name': {'key': 'properties.displayName', 'type': 'str'}, @@ -217,13 +241,24 @@ class PolicyDefinition(Model): 'policy_rule': {'key': 'properties.policyRule', 'type': 'object'}, 'metadata': {'key': 'properties.metadata', 'type': 'object'}, 'parameters': {'key': 'properties.parameters', 'type': 'object'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, } - def __init__(self, *, policy_type=None, mode: str=None, display_name: str=None, description: str=None, policy_rule=None, metadata=None, parameters=None, **kwargs) -> None: + def __init__( + self, + *, + policy_type: Optional[Union[str, "PolicyType"]] = None, + mode: Optional[str] = None, + display_name: Optional[str] = None, + description: Optional[str] = None, + policy_rule: Optional[object] = None, + metadata: Optional[object] = None, + parameters: Optional[object] = None, + **kwargs + ): super(PolicyDefinition, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None self.policy_type = policy_type self.mode = mode self.display_name = display_name @@ -231,16 +266,38 @@ def __init__(self, *, policy_type=None, mode: str=None, display_name: str=None, self.policy_rule = policy_rule self.metadata = metadata self.parameters = parameters - self.id = None - self.name = None - self.type = None -class PolicyDefinitionReference(Model): +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 + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[PolicyDefinition]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["PolicyDefinition"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(PolicyDefinitionListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class PolicyDefinitionReference(msrest.serialization.Model): """The policy definition reference. - :param policy_definition_id: The ID of the policy definition or policy set - definition. + :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: object @@ -251,86 +308,119 @@ class PolicyDefinitionReference(Model): 'parameters': {'key': 'parameters', 'type': 'object'}, } - def __init__(self, *, policy_definition_id: str=None, parameters=None, **kwargs) -> None: + def __init__( + self, + *, + policy_definition_id: Optional[str] = None, + parameters: Optional[object] = None, + **kwargs + ): super(PolicyDefinitionReference, self).__init__(**kwargs) self.policy_definition_id = policy_definition_id self.parameters = parameters -class PolicySetDefinition(Model): +class PolicySetDefinition(msrest.serialization.Model): """The policy set definition. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. - - :param 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 + :ivar id: The ID of the policy set definition. + :vartype id: str + :ivar name: The name of the policy set definition. + :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, + 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: object - :param parameters: The policy set definition parameters that can be used - in policy definition references. - :type parameters: object - :param policy_definitions: Required. An array of policy definition + :param parameters: The policy set definition parameters that can be used in policy definition references. + :type parameters: object + :param policy_definitions: An array of policy definition references. :type policy_definitions: list[~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinitionReference] - :ivar id: The ID of the policy set definition. - :vartype id: str - :ivar name: The name of the policy set definition. - :vartype name: str - :ivar type: The type of the resource - (Microsoft.Authorization/policySetDefinitions). - :vartype type: str """ _validation = { - 'policy_definitions': {'required': True}, 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, } _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, 'policy_type': {'key': 'properties.policyType', 'type': 'str'}, 'display_name': {'key': 'properties.displayName', 'type': 'str'}, 'description': {'key': 'properties.description', 'type': 'str'}, 'metadata': {'key': 'properties.metadata', 'type': 'object'}, 'parameters': {'key': 'properties.parameters', 'type': 'object'}, 'policy_definitions': {'key': 'properties.policyDefinitions', 'type': '[PolicyDefinitionReference]'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, } - def __init__(self, *, policy_definitions, policy_type=None, display_name: str=None, description: str=None, metadata=None, parameters=None, **kwargs) -> None: + def __init__( + self, + *, + policy_type: Optional[Union[str, "PolicyType"]] = None, + display_name: Optional[str] = None, + description: Optional[str] = None, + metadata: Optional[object] = None, + parameters: Optional[object] = None, + policy_definitions: Optional[List["PolicyDefinitionReference"]] = None, + **kwargs + ): super(PolicySetDefinition, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None self.policy_type = policy_type self.display_name = display_name self.description = description self.metadata = metadata self.parameters = parameters self.policy_definitions = policy_definitions - self.id = None - self.name = None - self.type = None -class PolicySku(Model): +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 + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[PolicySetDefinition]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["PolicySetDefinition"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(PolicySetDefinitionListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class PolicySku(msrest.serialization.Model): """The policy sku. This property is optional, obsolete, and will be ignored. 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. + :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 @@ -345,7 +435,13 @@ class PolicySku(Model): 'tier': {'key': 'tier', 'type': 'str'}, } - def __init__(self, *, name: str, tier: str=None, **kwargs) -> None: + def __init__( + self, + *, + name: str, + tier: Optional[str] = None, + **kwargs + ): 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/_paged_models.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/models/_paged_models.py deleted file mode 100644 index fb28fb12d73d..000000000000 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/models/_paged_models.py +++ /dev/null @@ -1,53 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.paging import Paged - - -class PolicyAssignmentPaged(Paged): - """ - A paging container for iterating over a list of :class:`PolicyAssignment ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[PolicyAssignment]'} - } - - def __init__(self, *args, **kwargs): - - super(PolicyAssignmentPaged, self).__init__(*args, **kwargs) -class PolicyDefinitionPaged(Paged): - """ - A paging container for iterating over a list of :class:`PolicyDefinition ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[PolicyDefinition]'} - } - - def __init__(self, *args, **kwargs): - - super(PolicyDefinitionPaged, self).__init__(*args, **kwargs) -class PolicySetDefinitionPaged(Paged): - """ - A paging container for iterating over a list of :class:`PolicySetDefinition ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[PolicySetDefinition]'} - } - - def __init__(self, *args, **kwargs): - - super(PolicySetDefinitionPaged, self).__init__(*args, **kwargs) 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 89e5d656693e..b0d8f22a5903 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 @@ -1,25 +1,24 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from enum import Enum - -class ResourceIdentityType(str, Enum): - - system_assigned = "SystemAssigned" - none = "None" - - class PolicyType(str, Enum): + """The type of policy definition. Possible values are NotSpecified, BuiltIn, and Custom. + """ not_specified = "NotSpecified" built_in = "BuiltIn" custom = "Custom" + +class ResourceIdentityType(str, Enum): + """The identity type. + """ + + system_assigned = "SystemAssigned" + none = "None" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/operations/__init__.py index c7d7b8eb9d97..4583d62b03a4 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/operations/__init__.py @@ -1,12 +1,9 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from ._policy_assignments_operations import PolicyAssignmentsOperations 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 1fbfb2f15193..7b6d383b8ba1 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 @@ -1,778 +1,670 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class PolicyAssignmentsOperations(object): """PolicyAssignmentsOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.policy.v2019_01_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for the operation. Constant value: "2019-01-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-01-01" - - self.config = config + self._config = config def delete( - self, scope, policy_assignment_name, custom_headers=None, raw=False, **operation_config): - """Deletes a policy assignment. - - This operation deletes a policy assignment, given its name and the - scope it was created in. The scope of a policy assignment is the part - of its ID preceding - '/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. - - :param scope: The scope of the policy assignment. Valid scopes are: - management group (format: - '/providers/Microsoft.Management/managementGroups/{managementGroup}'), - subscription (format: '/subscriptions/{subscriptionId}'), resource - group (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', - or resource (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' + self, + scope, # type: str + policy_assignment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyAssignment" + """This operation deletes a policy assignment, given its name and the scope it was created in. The scope of a policy assignment is the part of its ID preceding '/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + + Deletes a policy assignment. + + :param scope: The scope of the policy assignment. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. :type scope: str - :param policy_assignment_name: The name of the policy assignment to - delete. + :param policy_assignment_name: The name of the policy assignment to delete. :type policy_assignment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyAssignment or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyAssignment or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyAssignment or None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-01-01" + # Construct URL - url = self.delete.metadata['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') + 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('PolicyAssignment', response) + deserialized = self._deserialize('PolicyAssignment', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} + delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore def create( - self, scope, policy_assignment_name, parameters, custom_headers=None, raw=False, **operation_config): - """Creates or updates a policy assignment. - - This operation creates or updates a policy assignment with the given - scope and name. Policy assignments apply to all resources contained - within their scope. For example, when you assign a policy at resource - group scope, that policy applies to all resources in the group. - - :param scope: The scope of the policy assignment. Valid scopes are: - management group (format: - '/providers/Microsoft.Management/managementGroups/{managementGroup}'), - subscription (format: '/subscriptions/{subscriptionId}'), resource - group (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', - or resource (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' + self, + scope, # type: str + policy_assignment_name, # type: str + parameters, # type: "models.PolicyAssignment" + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyAssignment" + """This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + + Creates or updates a policy assignment. + + :param scope: The scope of the policy assignment. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. :type scope: str :param policy_assignment_name: The name of the policy assignment. :type policy_assignment_name: str :param parameters: Parameters for the policy assignment. - :type parameters: - ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyAssignment - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyAssignment or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyAssignment or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :type parameters: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyAssignment + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-01-01" + content_type = kwargs.pop("content_type", "application/json") + # Construct URL - url = self.create.metadata['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') + 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'PolicyAssignment') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 201: - deserialized = self._deserialize('PolicyAssignment', response) + deserialized = self._deserialize('PolicyAssignment', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} + create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore def get( - self, scope, policy_assignment_name, custom_headers=None, raw=False, **operation_config): - """Retrieves a policy assignment. - - This operation retrieves a single policy assignment, given its name and - the scope it was created at. - - :param scope: The scope of the policy assignment. Valid scopes are: - management group (format: - '/providers/Microsoft.Management/managementGroups/{managementGroup}'), - subscription (format: '/subscriptions/{subscriptionId}'), resource - group (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', - or resource (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' + self, + scope, # type: str + policy_assignment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyAssignment" + """This operation retrieves a single policy assignment, given its name and the scope it was created at. + + Retrieves a policy assignment. + + :param scope: The scope of the policy assignment. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. :type scope: str - :param policy_assignment_name: The name of the policy assignment to - get. + :param policy_assignment_name: The name of the policy assignment to get. :type policy_assignment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyAssignment or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyAssignment or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-01-01" + # Construct URL - url = self.get.metadata['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') + 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('PolicyAssignment', response) + deserialized = self._deserialize('PolicyAssignment', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} + get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore def list_for_resource_group( - self, resource_group_name, filter=None, custom_headers=None, raw=False, **operation_config): - """Retrieves all policy assignments that apply to a resource group. - - This operation retrieves the list of all policy assignments associated - with the given resource group in the given subscription that match the - optional given $filter. Valid values for $filter are: 'atScope()' or - 'policyDefinitionId eq '{value}''. If $filter is not provided, the - unfiltered list includes all policy assignments associated with the - resource group, including those that apply directly or apply from - containing scopes, as well as any applied to resources contained within - the resource group. If $filter=atScope() is provided, the returned list - includes all policy assignments that apply to the resource group, which - is everything in the unfiltered list except those applied to resources - contained within the resource group. If $filter=policyDefinitionId eq - '{value}' is provided, the returned list includes all policy - assignments of the policy definition whose id is {value} that apply to - the resource group. - - :param resource_group_name: The name of the resource group that - contains policy assignments. + self, + resource_group_name, # type: str + filter=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.PolicyAssignmentListResult"] + """This operation retrieves the list of all policy assignments associated with the given resource group in the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource group, including those that apply directly or apply from containing scopes, as well as any applied to resources contained within the resource group. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource group, which is everything in the unfiltered list except those applied to resources contained within the resource group. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource group. + + Retrieves all policy assignments that apply to a resource group. + + :param resource_group_name: The name of the resource group that contains policy assignments. :type resource_group_name: str - :param filter: The filter to apply on the operation. Valid values for - $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If - $filter is not provided, no filtering is performed. + :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()' + or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. :type filter: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of PolicyAssignment - :rtype: - ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyAssignmentPaged[~azure.mgmt.resource.policy.v2019_01_01.models.PolicyAssignment] - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-01-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_for_resource_group.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) - - return response + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.PolicyAssignmentPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list_for_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments'} + return ItemPaged( + get_next, extract_data + ) + list_for_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments'} # type: ignore def list_for_resource( - self, resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, filter=None, custom_headers=None, raw=False, **operation_config): - """Retrieves all policy assignments that apply to a resource. - - This operation retrieves the list of all policy assignments associated - with the specified resource in the given resource group and - subscription that match the optional given $filter. Valid values for - $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If - $filter is not provided, the unfiltered list includes all policy - assignments associated with the resource, including those that apply - directly or from all containing scopes, as well as any applied to - resources contained within the resource. If $filter=atScope() is - provided, the returned list includes all policy assignments that apply - to the resource, which is everything in the unfiltered list except - those applied to resources contained within the resource. If - $filter=policyDefinitionId eq '{value}' is provided, the returned list - includes all policy assignments of the policy definition whose id is - {value} that apply to the resource. Three parameters plus the resource - name are used to identify a specific resource. If the resource is not - part of a parent resource (the more common case), the parent resource - path should not be provided (or provided as ''). For example a web app - could be specified as ({resourceProviderNamespace} == 'Microsoft.Web', - {parentResourcePath} == '', {resourceType} == 'sites', {resourceName} - == 'MyWebApp'). If the resource is part of a parent resource, then all - parameters should be provided. For example a virtual machine DNS name - could be specified as ({resourceProviderNamespace} == - 'Microsoft.Compute', {parentResourcePath} == - 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames', - {resourceName} == 'MyComputerName'). A convenient alternative to - providing the namespace and type name separately is to provide both in - the {resourceType} parameter, format: ({resourceProviderNamespace} == - '', {parentResourcePath} == '', {resourceType} == - 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). - - :param resource_group_name: The name of the resource group containing - the resource. + self, + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + filter=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.PolicyAssignmentListResult"] + """This operation retrieves the list of all policy assignments associated with the specified resource in the given resource group and subscription that match the optional given $filter. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource, including those that apply directly or from all containing scopes, as well as any applied to resources contained within the resource. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource, which is everything in the unfiltered list except those applied to resources contained within the resource. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource. Three parameters plus the resource name are used to identify a specific resource. If the resource is not part of a parent resource (the more common case), the parent resource path should not be provided (or provided as ''). For example a web app could be specified as ({resourceProviderNamespace} == 'Microsoft.Web', {parentResourcePath} == '', {resourceType} == 'sites', {resourceName} == 'MyWebApp'). If the resource is part of a parent resource, then all parameters should be provided. For example a virtual machine DNS name could be specified as ({resourceProviderNamespace} == 'Microsoft.Compute', {parentResourcePath} == 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames', {resourceName} == 'MyComputerName'). A convenient alternative to providing the namespace and type name separately is to provide both in the {resourceType} parameter, format: ({resourceProviderNamespace} == '', {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). + + Retrieves all policy assignments that apply to a resource. + + :param resource_group_name: The name of the resource group containing the resource. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource - provider. For example, the namespace of a virtual machine is - Microsoft.Compute (from Microsoft.Compute/virtualMachines) + :param resource_provider_namespace: The namespace of the resource provider. For example, the + namespace of a virtual machine is Microsoft.Compute (from Microsoft.Compute/virtualMachines). :type resource_provider_namespace: str - :param parent_resource_path: The parent resource path. Use empty - string if there is none. + :param parent_resource_path: The parent resource path. Use empty string if there is none. :type parent_resource_path: str - :param resource_type: The resource type name. For example the type - name of a web app is 'sites' (from Microsoft.Web/sites). + :param resource_type: The resource type name. For example the type name of a web app is 'sites' + (from Microsoft.Web/sites). :type resource_type: str :param resource_name: The name of the resource. :type resource_name: str - :param filter: The filter to apply on the operation. Valid values for - $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If - $filter is not provided, no filtering is performed. + :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()' + or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. :type filter: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of PolicyAssignment - :rtype: - ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyAssignmentPaged[~azure.mgmt.resource.policy.v2019_01_01.models.PolicyAssignment] - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-01-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_for_resource.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.PolicyAssignmentPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_for_resource.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments'} + 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 def list( - self, filter=None, custom_headers=None, raw=False, **operation_config): - """Retrieves all policy assignments that apply to a subscription. - - This operation retrieves the list of all policy assignments associated - with the given subscription that match the optional given $filter. - Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq - '{value}''. If $filter is not provided, the unfiltered list includes - all policy assignments associated with the subscription, including - those that apply directly or from management groups that contain the - given subscription, as well as any applied to objects contained within - the subscription. If $filter=atScope() is provided, the returned list - includes all policy assignments that apply to the subscription, which - is everything in the unfiltered list except those applied to objects - contained within the subscription. If $filter=policyDefinitionId eq - '{value}' is provided, the returned list includes all policy - assignments of the policy definition whose id is {value}. - - :param filter: The filter to apply on the operation. Valid values for - $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If - $filter is not provided, no filtering is performed. + self, + filter=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.PolicyAssignmentListResult"] + """This operation retrieves the list of all policy assignments associated with the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the subscription, including those that apply directly or from management groups that contain the given subscription, as well as any applied to objects contained within the subscription. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the subscription, which is everything in the unfiltered list except those applied to objects contained within the subscription. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value}. + + Retrieves all policy assignments that apply to a subscription. + + :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()' + or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. :type filter: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of PolicyAssignment - :rtype: - ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyAssignmentPaged[~azure.mgmt.resource.policy.v2019_01_01.models.PolicyAssignment] - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-01-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['url'] + url = self.list.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_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 = {} + 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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) - - return response + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.PolicyAssignmentPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments'} # type: ignore def delete_by_id( - self, policy_assignment_id, custom_headers=None, raw=False, **operation_config): - """Deletes a policy assignment. - - This operation deletes the policy with the given ID. Policy assignment - IDs have this format: - '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. - Valid formats for {scope} are: - '/providers/Microsoft.Management/managementGroups/{managementGroup}' - (management group), '/subscriptions/{subscriptionId}' (subscription), - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' - (resource group), or - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' - (resource). - - :param policy_assignment_id: The ID of the policy assignment to - delete. Use the format + self, + policy_assignment_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyAssignment" + """This operation deletes the policy with the given ID. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid formats for {scope} are: '/providers/Microsoft.Management/managementGroups/{managementGroup}' (management group), '/subscriptions/{subscriptionId}' (subscription), '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' (resource group), or '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' (resource). + + Deletes a policy assignment. + + :param policy_assignment_id: The ID of the policy assignment to delete. Use the format '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. :type policy_assignment_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyAssignment or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyAssignment or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyAssignment or None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-01-01" + # Construct URL - url = self.delete_by_id.metadata['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) + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('PolicyAssignment', response) + deserialized = self._deserialize('PolicyAssignment', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - delete_by_id.metadata = {'url': '/{policyAssignmentId}'} + delete_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore def create_by_id( - self, policy_assignment_id, parameters, custom_headers=None, raw=False, **operation_config): - """Creates or updates a policy assignment. - - This operation creates or updates the policy assignment with the given - ID. Policy assignments made on a scope apply to all resources contained - in that scope. For example, when you assign a policy to a resource - group that policy applies to all resources in the group. Policy - assignment IDs have this format: - '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. - Valid scopes are: management group (format: - '/providers/Microsoft.Management/managementGroups/{managementGroup}'), - subscription (format: '/subscriptions/{subscriptionId}'), resource - group (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', - or resource (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. - - :param policy_assignment_id: The ID of the policy assignment to - create. Use the format + self, + policy_assignment_id, # type: str + parameters, # type: "models.PolicyAssignment" + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyAssignment" + """This operation creates or updates the policy assignment with the given ID. Policy assignments made on a scope apply to all resources contained in that scope. For example, when you assign a policy to a resource group that policy applies to all resources in the group. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + + Creates or updates a policy assignment. + + :param policy_assignment_id: The ID of the policy assignment to create. Use the format '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. :type policy_assignment_id: str :param parameters: Parameters for policy assignment. - :type parameters: - ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyAssignment - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyAssignment or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyAssignment or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :type parameters: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyAssignment + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-01-01" + content_type = kwargs.pop("content_type", "application/json") + # Construct URL - url = self.create_by_id.metadata['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) + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'PolicyAssignment') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 201: - deserialized = self._deserialize('PolicyAssignment', response) + deserialized = self._deserialize('PolicyAssignment', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create_by_id.metadata = {'url': '/{policyAssignmentId}'} + create_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore def get_by_id( - self, policy_assignment_id, custom_headers=None, raw=False, **operation_config): - """Retrieves the policy assignment with the given ID. - - The operation retrieves the policy assignment with the given ID. Policy - assignment IDs have this format: - '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. - Valid scopes are: management group (format: - '/providers/Microsoft.Management/managementGroups/{managementGroup}'), - subscription (format: '/subscriptions/{subscriptionId}'), resource - group (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', - or resource (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. - - :param policy_assignment_id: The ID of the policy assignment to get. - Use the format + self, + policy_assignment_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyAssignment" + """The operation retrieves the policy assignment with the given ID. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + + Retrieves the policy assignment with the given ID. + + :param policy_assignment_id: The ID of the policy assignment to get. Use the format '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. :type policy_assignment_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyAssignment or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyAssignment or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-01-01" + # Construct URL - url = self.get_by_id.metadata['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) + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('PolicyAssignment', response) + deserialized = self._deserialize('PolicyAssignment', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/{policyAssignmentId}'} + 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 c9c78d2e5e0b..827782023335 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 @@ -1,686 +1,646 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class PolicyDefinitionsOperations(object): """PolicyDefinitionsOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.policy.v2019_01_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for the operation. Constant value: "2019-01-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-01-01" - - self.config = config + self._config = config def create_or_update( - self, policy_definition_name, parameters, custom_headers=None, raw=False, **operation_config): - """Creates or updates a policy definition in a subscription. + self, + policy_definition_name, # type: str + parameters, # type: "models.PolicyDefinition" + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyDefinition" + """This operation creates or updates a policy definition in the given subscription with the given name. - This operation creates or updates a policy definition in the given - subscription with the given name. + Creates or updates a policy definition in a subscription. - :param policy_definition_name: The name of the policy definition to - create. + :param policy_definition_name: The name of the policy definition to create. :type policy_definition_name: str :param parameters: The policy definition properties. - :type parameters: - ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinition - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyDefinition or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinition or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :type parameters: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinition + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-01-01" + content_type = kwargs.pop("content_type", "application/json") + # Construct URL - url = self.create_or_update.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'PolicyDefinition') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [201]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 201: - deserialized = self._deserialize('PolicyDefinition', response) + deserialized = self._deserialize('PolicyDefinition', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore def delete( - self, policy_definition_name, custom_headers=None, raw=False, **operation_config): - """Deletes a policy definition in a subscription. + self, + policy_definition_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """This operation deletes the policy definition in the given subscription with the given name. - This operation deletes the policy definition in the given subscription - with the given name. + Deletes a policy definition in a subscription. - :param policy_definition_name: The name of the policy definition to - delete. + :param policy_definition_name: The name of the policy definition to delete. :type policy_definition_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-01-01" + # Construct URL - url = self.delete.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} + delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore def get( - self, policy_definition_name, custom_headers=None, raw=False, **operation_config): - """Retrieves a policy definition in a subscription. + self, + policy_definition_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyDefinition" + """This operation retrieves the policy definition in the given subscription with the given name. - This operation retrieves the policy definition in the given - subscription with the given name. + Retrieves a policy definition in a subscription. - :param policy_definition_name: The name of the policy definition to - get. + :param policy_definition_name: The name of the policy definition to get. :type policy_definition_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyDefinition or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinition or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinition + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-01-01" + # Construct URL - url = self.get.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('PolicyDefinition', response) + deserialized = self._deserialize('PolicyDefinition', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore def get_built_in( - self, policy_definition_name, custom_headers=None, raw=False, **operation_config): - """Retrieves a built-in policy definition. + self, + policy_definition_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyDefinition" + """This operation retrieves the built-in policy definition with the given name. - This operation retrieves the built-in policy definition with the given - name. + Retrieves a built-in policy definition. - :param policy_definition_name: The name of the built-in policy - definition to get. + :param policy_definition_name: The name of the built-in policy definition to get. :type policy_definition_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyDefinition or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinition or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinition + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-01-01" + # Construct URL - url = self.get_built_in.metadata['url'] + url = self.get_built_in.metadata['url'] # type: ignore path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str') + 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('PolicyDefinition', response) + deserialized = self._deserialize('PolicyDefinition', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} + get_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore def create_or_update_at_management_group( - self, policy_definition_name, parameters, management_group_id, custom_headers=None, raw=False, **operation_config): - """Creates or updates a policy definition in a management group. - - This operation creates or updates a policy definition in the given - management group with the given name. - - :param policy_definition_name: The name of the policy definition to - create. + self, + policy_definition_name, # type: str + management_group_id, # type: str + parameters, # type: "models.PolicyDefinition" + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyDefinition" + """This operation creates or updates a policy definition in the given management group with the given name. + + Creates or updates a policy definition in a management group. + + :param policy_definition_name: The name of the policy definition to create. :type policy_definition_name: str - :param parameters: The policy definition properties. - :type parameters: - ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinition :param management_group_id: The ID of the management group. :type management_group_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyDefinition or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinition or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :param parameters: The policy definition properties. + :type parameters: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinition + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-01-01" + content_type = kwargs.pop("content_type", "application/json") + # Construct URL - url = self.create_or_update_at_management_group.metadata['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') + 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'PolicyDefinition') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [201]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 201: - deserialized = self._deserialize('PolicyDefinition', response) + deserialized = self._deserialize('PolicyDefinition', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + 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}'} + create_or_update_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore def delete_at_management_group( - self, policy_definition_name, management_group_id, custom_headers=None, raw=False, **operation_config): - """Deletes a policy definition in a management group. + self, + policy_definition_name, # type: str + management_group_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """This operation deletes the policy definition in the given management group with the given name. - This operation deletes the policy definition in the given management - group with the given name. + Deletes a policy definition in a management group. - :param policy_definition_name: The name of the policy definition to - delete. + :param policy_definition_name: The name of the policy definition to delete. :type policy_definition_name: str :param management_group_id: The ID of the management group. :type management_group_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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'] + 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') + 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} + if cls: + return cls(pipeline_response, None, {}) + + delete_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore def get_at_management_group( - self, policy_definition_name, management_group_id, custom_headers=None, raw=False, **operation_config): - """Retrieve a policy definition in a management group. + self, + policy_definition_name, # type: str + management_group_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyDefinition" + """This operation retrieves the policy definition in the given management group with the given name. - This operation retrieves the policy definition in the given management - group with the given name. + Retrieve a policy definition in a management group. - :param policy_definition_name: The name of the policy definition to - get. + :param policy_definition_name: The name of the policy definition to get. :type policy_definition_name: str :param management_group_id: The ID of the management group. :type management_group_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyDefinition or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinition or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinition + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-01-01" + # Construct URL - url = self.get_at_management_group.metadata['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') + 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('PolicyDefinition', response) + deserialized = self._deserialize('PolicyDefinition', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} + get_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore def list( - self, custom_headers=None, raw=False, **operation_config): - """Retrieves policy definitions in a subscription. - - This operation retrieves a list of all the policy definitions in a - given subscription. - - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of PolicyDefinition - :rtype: - ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinitionPaged[~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinition] - :raises: :class:`CloudError` + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.PolicyDefinitionListResult"] + """This operation retrieves a list of all the policy definitions in a given subscription. + + Retrieves policy definitions in a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-01-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['url'] + url = self.list.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyDefinitionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.PolicyDefinitionPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions'} # type: ignore def list_built_in( - self, custom_headers=None, raw=False, **operation_config): - """Retrieve built-in policy definitions. - - This operation retrieves a list of all the built-in policy definitions. - - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of PolicyDefinition - :rtype: - ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinitionPaged[~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinition] - :raises: :class:`CloudError` + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.PolicyDefinitionListResult"] + """This operation retrieves a list of all the built-in policy definitions. + + Retrieve 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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-01-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_built_in.metadata['url'] - + url = self.list_built_in.metadata['url'] # type: ignore # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyDefinitionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.PolicyDefinitionPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policyDefinitions'} + return ItemPaged( + get_next, extract_data + ) + list_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policyDefinitions'} # type: ignore def list_by_management_group( - self, management_group_id, custom_headers=None, raw=False, **operation_config): - """Retrieve policy definitions in a management group. + self, + management_group_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.PolicyDefinitionListResult"] + """This operation retrieves a list of all the policy definitions in a given management group. - This operation retrieves a list of all the policy definitions in a - given management group. + Retrieve policy definitions in a management group. :param management_group_id: The ID of the management group. :type management_group_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of PolicyDefinition - :rtype: - ~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinitionPaged[~azure.mgmt.resource.policy.v2019_01_01.models.PolicyDefinition] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-01-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_by_management_group.metadata['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') + 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyDefinitionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.PolicyDefinitionPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_by_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions'} + return ItemPaged( + get_next, extract_data + ) + list_by_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions'} # type: ignore 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 35d7a5530de2..8fcc87129b25 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 @@ -1,680 +1,666 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class PolicySetDefinitionsOperations(object): """PolicySetDefinitionsOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.policy.v2019_01_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for the operation. Constant value: "2019-01-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-01-01" - - self.config = config + self._config = config def create_or_update( - self, policy_set_definition_name, parameters, custom_headers=None, raw=False, **operation_config): - """Creates or updates a policy set definition. + self, + policy_set_definition_name, # type: str + parameters, # type: "models.PolicySetDefinition" + **kwargs # type: Any + ): + # type: (...) -> "models.PolicySetDefinition" + """This operation creates or updates a policy set definition in the given subscription with the given name. - This operation creates or updates a policy set definition in the given - subscription with the given name. + Creates or updates a policy set definition. - :param policy_set_definition_name: The name of the policy set - definition to create. + :param policy_set_definition_name: The name of the policy set definition to create. :type policy_set_definition_name: str :param parameters: The policy set definition properties. - :type parameters: - ~azure.mgmt.resource.policy.v2019_01_01.models.PolicySetDefinition - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicySetDefinition or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2019_01_01.models.PolicySetDefinition or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :type parameters: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicySetDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicySetDefinition + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicySetDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-01-01" + content_type = kwargs.pop("content_type", "application/json") + # Construct URL - url = self.create_or_update.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'PolicySetDefinition') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('PolicySetDefinition', response) + deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('PolicySetDefinition', response) + deserialized = self._deserialize('PolicySetDefinition', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore def delete( - self, policy_set_definition_name, custom_headers=None, raw=False, **operation_config): - """Deletes a policy set definition. + self, + policy_set_definition_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """This operation deletes the policy set definition in the given subscription with the given name. - This operation deletes the policy set definition in the given - subscription with the given name. + Deletes a policy set definition. - :param policy_set_definition_name: The name of the policy set - definition to delete. + :param policy_set_definition_name: The name of the policy set definition to delete. :type policy_set_definition_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-01-01" + # Construct URL - url = self.delete.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} + delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore def get( - self, policy_set_definition_name, custom_headers=None, raw=False, **operation_config): - """Retrieves a policy set definition. + self, + policy_set_definition_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.PolicySetDefinition" + """This operation retrieves the policy set definition in the given subscription with the given name. - This operation retrieves the policy set definition in the given - subscription with the given name. + Retrieves a policy set definition. - :param policy_set_definition_name: The name of the policy set - definition to get. + :param policy_set_definition_name: The name of the policy set definition to get. :type policy_set_definition_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicySetDefinition or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2019_01_01.models.PolicySetDefinition or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicySetDefinition + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicySetDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-01-01" + # Construct URL - url = self.get.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('PolicySetDefinition', response) + deserialized = self._deserialize('PolicySetDefinition', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore def get_built_in( - self, policy_set_definition_name, custom_headers=None, raw=False, **operation_config): - """Retrieves a built in policy set definition. + self, + policy_set_definition_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.PolicySetDefinition" + """This operation retrieves the built-in policy set definition with the given name. - This operation retrieves the built-in policy set definition with the - given name. + Retrieves a built in policy set definition. - :param policy_set_definition_name: The name of the policy set - definition to get. + :param policy_set_definition_name: The name of the policy set definition to get. :type policy_set_definition_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicySetDefinition or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2019_01_01.models.PolicySetDefinition or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicySetDefinition + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicySetDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-01-01" + # Construct URL - url = self.get_built_in.metadata['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') + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('PolicySetDefinition', response) + deserialized = self._deserialize('PolicySetDefinition', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} + get_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore def list( - self, custom_headers=None, raw=False, **operation_config): - """Retrieves the policy set definitions for a subscription. - - This operation retrieves a list of all the policy set definitions in - the given subscription. - - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of PolicySetDefinition - :rtype: - ~azure.mgmt.resource.policy.v2019_01_01.models.PolicySetDefinitionPaged[~azure.mgmt.resource.policy.v2019_01_01.models.PolicySetDefinition] - :raises: - :class:`ErrorResponseException` + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.PolicySetDefinitionListResult"] + """This operation retrieves a list of all the policy set definitions in the given subscription. + + Retrieves 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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-01-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['url'] + url = self.list.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('PolicySetDefinitionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) - - return response + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.PolicySetDefinitionPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions'} # type: ignore def list_built_in( - self, custom_headers=None, raw=False, **operation_config): - """Retrieves built-in policy set definitions. - - This operation retrieves a list of all the built-in policy set - definitions. - - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of PolicySetDefinition - :rtype: - ~azure.mgmt.resource.policy.v2019_01_01.models.PolicySetDefinitionPaged[~azure.mgmt.resource.policy.v2019_01_01.models.PolicySetDefinition] - :raises: - :class:`ErrorResponseException` + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.PolicySetDefinitionListResult"] + """This operation retrieves a list of all the built-in policy set definitions. + + Retrieves 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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-01-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_built_in.metadata['url'] - + url = self.list_built_in.metadata['url'] # type: ignore # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('PolicySetDefinitionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) - - return response + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.PolicySetDefinitionPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policySetDefinitions'} + return ItemPaged( + get_next, extract_data + ) + list_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policySetDefinitions'} # type: ignore def create_or_update_at_management_group( - self, policy_set_definition_name, parameters, management_group_id, custom_headers=None, raw=False, **operation_config): - """Creates or updates a policy set definition. - - This operation creates or updates a policy set definition in the given - management group with the given name. - - :param policy_set_definition_name: The name of the policy set - definition to create. + self, + policy_set_definition_name, # type: str + management_group_id, # type: str + parameters, # type: "models.PolicySetDefinition" + **kwargs # type: Any + ): + # type: (...) -> "models.PolicySetDefinition" + """This operation creates or updates a policy set definition in the given management group with the given name. + + Creates or updates a policy set definition. + + :param policy_set_definition_name: The name of the policy set definition to create. :type policy_set_definition_name: str - :param parameters: The policy set definition properties. - :type parameters: - ~azure.mgmt.resource.policy.v2019_01_01.models.PolicySetDefinition :param management_group_id: The ID of the management group. :type management_group_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicySetDefinition or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2019_01_01.models.PolicySetDefinition or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :param parameters: The policy set definition properties. + :type parameters: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicySetDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicySetDefinition + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicySetDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-01-01" + content_type = kwargs.pop("content_type", "application/json") + # Construct URL - url = self.create_or_update_at_management_group.metadata['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') + 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'PolicySetDefinition') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('PolicySetDefinition', response) + deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('PolicySetDefinition', response) + deserialized = self._deserialize('PolicySetDefinition', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + 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}'} + create_or_update_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore def delete_at_management_group( - self, policy_set_definition_name, management_group_id, custom_headers=None, raw=False, **operation_config): - """Deletes a policy set definition. + self, + policy_set_definition_name, # type: str + management_group_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """This operation deletes the policy set definition in the given management group with the given name. - This operation deletes the policy set definition in the given - management group with the given name. + Deletes a policy set definition. - :param policy_set_definition_name: The name of the policy set - definition to delete. + :param policy_set_definition_name: The name of the policy set definition to delete. :type policy_set_definition_name: str :param management_group_id: The ID of the management group. :type management_group_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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'] + 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') + 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} + delete_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore def get_at_management_group( - self, policy_set_definition_name, management_group_id, custom_headers=None, raw=False, **operation_config): - """Retrieves a policy set definition. + self, + policy_set_definition_name, # type: str + management_group_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.PolicySetDefinition" + """This operation retrieves the policy set definition in the given management group with the given name. - This operation retrieves the policy set definition in the given - management group with the given name. + Retrieves a policy set definition. - :param policy_set_definition_name: The name of the policy set - definition to get. + :param policy_set_definition_name: The name of the policy set definition to get. :type policy_set_definition_name: str :param management_group_id: The ID of the management group. :type management_group_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicySetDefinition or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2019_01_01.models.PolicySetDefinition or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_01_01.models.PolicySetDefinition + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicySetDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-01-01" + # Construct URL - url = self.get_at_management_group.metadata['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') + 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('PolicySetDefinition', response) + deserialized = self._deserialize('PolicySetDefinition', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} + get_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore def list_by_management_group( - self, management_group_id, custom_headers=None, raw=False, **operation_config): - """Retrieves all policy set definitions in management group. + self, + management_group_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.PolicySetDefinitionListResult"] + """This operation retrieves a list of all the a policy set definition in the given management group. - This operation retrieves a list of all the a policy set definition in - the given management group. + Retrieves all policy set definitions in management group. :param management_group_id: The ID of the management group. :type management_group_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of PolicySetDefinition - :rtype: - ~azure.mgmt.resource.policy.v2019_01_01.models.PolicySetDefinitionPaged[~azure.mgmt.resource.policy.v2019_01_01.models.PolicySetDefinition] - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-01-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_by_management_group.metadata['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') + 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('PolicySetDefinitionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) - - return response + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.PolicySetDefinitionPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list_by_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions'} + return ItemPaged( + get_next, extract_data + ) + list_by_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/py.typed b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file 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 deleted file mode 100644 index 600856a7069e..000000000000 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_01_01/version.py +++ /dev/null @@ -1,13 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -VERSION = "2019-01-01" - 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 56bf47bfb9e4..e4bba9352a5c 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 @@ -1,19 +1,16 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._configuration import PolicyClientConfiguration from ._policy_client import PolicyClient -__all__ = ['PolicyClient', 'PolicyClientConfiguration'] - -from .version import VERSION - -__version__ = VERSION +__all__ = ['PolicyClient'] +try: + from ._patch import patch_sdk + patch_sdk() +except ImportError: + pass 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 ede4f42045d0..ae86ecf23c7c 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 @@ -1,48 +1,69 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrestazure import AzureConfiguration -from .version import VERSION +from typing import TYPE_CHECKING +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + + from azure.core.credentials import TokenCredential + +VERSION = "unknown" + +class PolicyClientConfiguration(Configuration): + """Configuration for PolicyClient. -class PolicyClientConfiguration(AzureConfiguration): - """Configuration for PolicyClient Note that all parameters used to create this instance are saved as instance attributes. - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` + :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 """ def __init__( - self, credentials, subscription_id, base_url=None): - - if credentials is None: - raise ValueError("Parameter 'credentials' must not be None.") + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + 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.") - if not base_url: - base_url = 'https://management.azure.com' + super(PolicyClientConfiguration, self).__init__(**kwargs) - super(PolicyClientConfiguration, self).__init__(base_url) - - # Starting Autorest.Python 4.0.64, make connection pool activated by default - self.keep_alive = True - - self.add_user_agent('azure-mgmt-resource/{}'.format(VERSION)) - self.add_user_agent('Azure-SDK-For-Python') - - self.credentials = credentials + self.credential = credential self.subscription_id = subscription_id + self.api_version = "2019-06-01" + self.credential_scopes = ['https://management.azure.com/.default'] + self.credential_scopes.extend(kwargs.pop('credential_scopes', [])) + kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + 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) 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 new file mode 100644 index 000000000000..79db95095194 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/_metadata.json @@ -0,0 +1,55 @@ +{ + "chosen_version": "2019-06-01", + "total_api_version_list": ["2019-06-01"], + "client": { + "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." + }, + "global_parameters": { + "sync_method": { + "credential": { + "method_signature": "credential, # type: \"TokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials.TokenCredential", + "required": true + }, + "subscription_id": { + "method_signature": "subscription_id, # type: str", + "description": "The ID of the target subscription.", + "docstring_type": "str", + "required": true + } + }, + "async_method": { + "credential": { + "method_signature": "credential, # type: \"AsyncTokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + }, + "subscription_id": { + "method_signature": "subscription_id, # type: str", + "description": "The ID of the target subscription.", + "docstring_type": "str", + "required": true + } + }, + "constant": { + }, + "call": "credential, subscription_id" + }, + "config": { + "credential": true, + "credential_scopes": ["https://management.azure.com/.default"] + }, + "operation_groups": { + "policy_assignments": "PolicyAssignmentsOperations", + "policy_definitions": "PolicyDefinitionsOperations", + "policy_set_definitions": "PolicySetDefinitionsOperations" + }, + "operation_mixins": { + }, + "sync_imports": "None", + "async_imports": "None" +} \ 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 9becba788cc5..12caddb615c7 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 @@ -1,16 +1,19 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.service_client import SDKClient -from msrest import Serializer, Deserializer +from typing import TYPE_CHECKING + +from azure.mgmt.core import ARMPipelineClient +from msrest import Deserializer, Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional from ._configuration import PolicyClientConfiguration from .operations import PolicyAssignmentsOperations @@ -19,41 +22,56 @@ from . import models -class PolicyClient(SDKClient): +class PolicyClient(object): """To manage and control access to your resources, you can define customized policies and assign them at a scope. - :ivar config: Configuration for client. - :vartype config: PolicyClientConfiguration - - :ivar policy_assignments: PolicyAssignments operations + :ivar policy_assignments: PolicyAssignmentsOperations operations :vartype policy_assignments: azure.mgmt.resource.policy.v2019_06_01.operations.PolicyAssignmentsOperations - :ivar policy_definitions: PolicyDefinitions operations + :ivar policy_definitions: PolicyDefinitionsOperations operations :vartype policy_definitions: azure.mgmt.resource.policy.v2019_06_01.operations.PolicyDefinitionsOperations - :ivar policy_set_definitions: PolicySetDefinitions operations + :ivar policy_set_definitions: PolicySetDefinitionsOperations operations :vartype policy_set_definitions: azure.mgmt.resource.policy.v2019_06_01.operations.PolicySetDefinitionsOperations - - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` + :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. """ def __init__( - self, credentials, subscription_id, base_url=None): - - self.config = PolicyClientConfiguration(credentials, subscription_id, base_url) - super(PolicyClient, self).__init__(self.config.credentials, self.config) + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = 'https://management.azure.com' + self._config = PolicyClientConfiguration(credential, 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.api_version = '2019-06-01' self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self.policy_assignments = PolicyAssignmentsOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.policy_definitions = PolicyDefinitionsOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.policy_set_definitions = PolicySetDefinitionsOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> PolicyClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) 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 new file mode 100644 index 000000000000..df3c0beab48a --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/aio/__init__.py @@ -0,0 +1,10 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._policy_client_async import PolicyClient +__all__ = ['PolicyClient'] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/aio/_configuration_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/aio/_configuration_async.py new file mode 100644 index 000000000000..ed9b557c90ec --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/aio/_configuration_async.py @@ -0,0 +1,65 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + +VERSION = "unknown" + +class PolicyClientConfiguration(Configuration): + """Configuration for PolicyClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :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 + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + 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 + self.api_version = "2019-06-01" + self.credential_scopes = ['https://management.azure.com/.default'] + self.credential_scopes.extend(kwargs.pop('credential_scopes', [])) + kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs: Any + ) -> None: + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + 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) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/aio/_policy_client_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/aio/_policy_client_async.py new file mode 100644 index 000000000000..b0d2e35602de --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/aio/_policy_client_async.py @@ -0,0 +1,69 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, Optional + +from azure.mgmt.core import AsyncARMPipelineClient +from msrest import Deserializer, Serializer + +from ._configuration_async import PolicyClientConfiguration +from .operations_async import PolicyAssignmentsOperations +from .operations_async import PolicyDefinitionsOperations +from .operations_async import PolicySetDefinitionsOperations +from .. import models + + +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.aio.operations_async.PolicyAssignmentsOperations + :ivar policy_definitions: PolicyDefinitionsOperations operations + :vartype policy_definitions: azure.mgmt.resource.policy.v2019_06_01.aio.operations_async.PolicyDefinitionsOperations + :ivar policy_set_definitions: PolicySetDefinitionsOperations operations + :vartype policy_set_definitions: azure.mgmt.resource.policy.v2019_06_01.aio.operations_async.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 + :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, + **kwargs: 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) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + + self.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 close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "PolicyClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/aio/operations_async/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/aio/operations_async/__init__.py new file mode 100644 index 000000000000..6a33a6888921 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/aio/operations_async/__init__.py @@ -0,0 +1,17 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._policy_assignments_operations_async import PolicyAssignmentsOperations +from ._policy_definitions_operations_async import PolicyDefinitionsOperations +from ._policy_set_definitions_operations_async import PolicySetDefinitionsOperations + +__all__ = [ + 'PolicyAssignmentsOperations', + 'PolicyDefinitionsOperations', + 'PolicySetDefinitionsOperations', +] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/aio/operations_async/_policy_assignments_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/aio/operations_async/_policy_assignments_operations_async.py new file mode 100644 index 000000000000..e3e36a4e04db --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/aio/operations_async/_policy_assignments_operations_async.py @@ -0,0 +1,657 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import 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 ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class PolicyAssignmentsOperations: + """PolicyAssignmentsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.policy.v2019_06_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def delete( + self, + scope: str, + policy_assignment_name: str, + **kwargs + ) -> "models.PolicyAssignment": + """This operation deletes a policy assignment, given its name and the scope it was created in. The scope of a policy assignment is the part of its ID preceding '/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + + Deletes a policy assignment. + + :param scope: The scope of the policy assignment. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + :type scope: str + :param policy_assignment_name: The name of the policy assignment to delete. + :type policy_assignment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignment or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {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 = { + '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'] = 'application/json' + + # Construct and send request + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('PolicyAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore + + async def create( + self, + scope: str, + policy_assignment_name: str, + parameters: "models.PolicyAssignment", + **kwargs + ) -> "models.PolicyAssignment": + """This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + + Creates or updates a policy assignment. + + :param scope: The scope of the policy assignment. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + :type scope: str + :param policy_assignment_name: The name of the policy assignment. + :type policy_assignment_name: str + :param parameters: Parameters for the policy assignment. + :type parameters: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignment + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore + + async def get( + self, + scope: str, + policy_assignment_name: str, + **kwargs + ) -> "models.PolicyAssignment": + """This operation retrieves a single policy assignment, given its name and the scope it was created at. + + Retrieves a policy assignment. + + :param scope: The scope of the policy assignment. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + :type scope: str + :param policy_assignment_name: The name of the policy assignment to get. + :type policy_assignment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + + # 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'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore + + def list_for_resource_group( + self, + resource_group_name: str, + filter: Optional[str] = None, + **kwargs + ) -> AsyncIterable["models.PolicyAssignmentListResult"]: + """This operation retrieves the list of all policy assignments associated with the given resource group in the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource group, including those that apply directly or apply from containing scopes, as well as any applied to resources contained within the resource group. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource group, which is everything in the unfiltered list except those applied to resources contained within the resource group. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource group. + + Retrieves all policy assignments that apply to a resource group. + + :param resource_group_name: The name of the resource group that contains policy assignments. + :type resource_group_name: str + :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()' + 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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + 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 + + def list_for_resource( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + filter: Optional[str] = None, + **kwargs + ) -> AsyncIterable["models.PolicyAssignmentListResult"]: + """This operation retrieves the list of all policy assignments associated with the specified resource in the given resource group and subscription that match the optional given $filter. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource, including those that apply directly or from all containing scopes, as well as any applied to resources contained within the resource. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource, which is everything in the unfiltered list except those applied to resources contained within the resource. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource. Three parameters plus the resource name are used to identify a specific resource. If the resource is not part of a parent resource (the more common case), the parent resource path should not be provided (or provided as ''). For example a web app could be specified as ({resourceProviderNamespace} == 'Microsoft.Web', {parentResourcePath} == '', {resourceType} == 'sites', {resourceName} == 'MyWebApp'). If the resource is part of a parent resource, then all parameters should be provided. For example a virtual machine DNS name could be specified as ({resourceProviderNamespace} == 'Microsoft.Compute', {parentResourcePath} == 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames', {resourceName} == 'MyComputerName'). A convenient alternative to providing the namespace and type name separately is to provide both in the {resourceType} parameter, format: ({resourceProviderNamespace} == '', {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). + + Retrieves all policy assignments that apply to a resource. + + :param resource_group_name: The name of the resource group containing the resource. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. For example, the + namespace of a virtual machine is Microsoft.Compute (from Microsoft.Compute/virtualMachines). + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource path. Use empty string if there is none. + :type parent_resource_path: str + :param resource_type: The resource type name. For example the type name of a web app is 'sites' + (from Microsoft.Web/sites). + :type resource_type: str + :param resource_name: The name of the resource. + :type resource_name: str + :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()' + 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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + 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 + + def list( + self, + filter: Optional[str] = None, + **kwargs + ) -> AsyncIterable["models.PolicyAssignmentListResult"]: + """This operation retrieves the list of all policy assignments associated with the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the subscription, including those that apply directly or from management groups that contain the given subscription, as well as any applied to objects contained within the subscription. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the subscription, which is everything in the unfiltered list except those applied to objects contained within the subscription. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value}. + + Retrieves all policy assignments that apply to a subscription. + + :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()' + 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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + 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 + + async def delete_by_id( + self, + policy_assignment_id: str, + **kwargs + ) -> "models.PolicyAssignment": + """This operation deletes the policy with the given ID. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid formats for {scope} are: '/providers/Microsoft.Management/managementGroups/{managementGroup}' (management group), '/subscriptions/{subscriptionId}' (subscription), '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' (resource group), or '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' (resource). + + Deletes a policy assignment. + + :param policy_assignment_id: The ID of the policy assignment to delete. Use the format + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + :type policy_assignment_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignment or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + + # 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'] = 'application/json' + + # Construct and send request + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('PolicyAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + delete_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + + async def create_by_id( + self, + policy_assignment_id: str, + parameters: "models.PolicyAssignment", + **kwargs + ) -> "models.PolicyAssignment": + """This operation creates or updates the policy assignment with the given ID. Policy assignments made on a scope apply to all resources contained in that scope. For example, when you assign a policy to a resource group that policy applies to all resources in the group. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + + Creates or updates a policy assignment. + + :param policy_assignment_id: The ID of the policy assignment to create. Use the format + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + :type policy_assignment_id: str + :param parameters: Parameters for policy assignment. + :type parameters: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignment + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + + async def get_by_id( + self, + policy_assignment_id: str, + **kwargs + ) -> "models.PolicyAssignment": + """The operation retrieves the policy assignment with the given ID. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + + Retrieves the policy assignment with the given ID. + + :param policy_assignment_id: The ID of the policy assignment to get. Use the format + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + :type policy_assignment_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + + # 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'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyAssignment', pipeline_response) + + if cls: + 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_async/_policy_definitions_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/aio/operations_async/_policy_definitions_operations_async.py new file mode 100644 index 000000000000..a12a7a30da77 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/aio/operations_async/_policy_definitions_operations_async.py @@ -0,0 +1,632 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import 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 ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class PolicyDefinitionsOperations: + """PolicyDefinitionsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.policy.v2019_06_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def create_or_update( + self, + policy_definition_name: str, + parameters: "models.PolicyDefinition", + **kwargs + ) -> "models.PolicyDefinition": + """This operation creates or updates a policy definition in the given subscription with the given name. + + Creates or updates a policy definition in a subscription. + + :param policy_definition_name: The name of the policy definition to create. + :type policy_definition_name: str + :param parameters: The policy definition properties. + :type parameters: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + async def delete( + self, + policy_definition_name: str, + **kwargs + ) -> None: + """This operation deletes the policy definition in the given subscription with the given name. + + Deletes a policy definition in a subscription. + + :param policy_definition_name: The name of the policy definition to delete. + :type policy_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + async def get( + self, + policy_definition_name: str, + **kwargs + ) -> "models.PolicyDefinition": + """This operation retrieves the policy definition in the given subscription with the given name. + + Retrieves a policy definition in a subscription. + + :param policy_definition_name: The name of the policy definition to get. + :type policy_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + async def get_built_in( + self, + policy_definition_name: str, + **kwargs + ) -> "models.PolicyDefinition": + """This operation retrieves the built-in policy definition with the given name. + + Retrieves a built-in policy definition. + + :param policy_definition_name: The name of the built-in policy definition to get. + :type policy_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + async def create_or_update_at_management_group( + self, + policy_definition_name: str, + management_group_id: str, + parameters: "models.PolicyDefinition", + **kwargs + ) -> "models.PolicyDefinition": + """This operation creates or updates a policy definition in the given management group with the given name. + + Creates or updates a policy definition in a management group. + + :param policy_definition_name: The name of the policy definition to create. + :type policy_definition_name: str + :param management_group_id: The ID of the management group. + :type management_group_id: str + :param parameters: The policy definition properties. + :type parameters: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyDefinition', pipeline_response) + + if cls: + 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 + + async def delete_at_management_group( + self, + policy_definition_name: str, + management_group_id: str, + **kwargs + ) -> None: + """This operation deletes the policy definition in the given management group with the given name. + + Deletes a policy definition in a management group. + + :param policy_definition_name: The name of the policy definition to delete. + :type policy_definition_name: str + :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: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + async def get_at_management_group( + self, + policy_definition_name: str, + management_group_id: str, + **kwargs + ) -> "models.PolicyDefinition": + """This operation retrieves the policy definition in the given management group with the given name. + + Retrieve a policy definition in a management group. + + :param policy_definition_name: The name of the policy definition to get. + :type policy_definition_name: str + :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: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyDefinition', pipeline_response) + + if cls: + 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 + + def list( + self, + **kwargs + ) -> AsyncIterable["models.PolicyDefinitionListResult"]: + """This operation retrieves a list of all the policy definitions in a given subscription. + + Retrieves policy definitions in a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyDefinitionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions'} # type: ignore + + def list_built_in( + self, + **kwargs + ) -> AsyncIterable["models.PolicyDefinitionListResult"]: + """This operation retrieves a list of all the built-in policy definitions. + + Retrieve 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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyDefinitionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policyDefinitions'} # type: ignore + + def list_by_management_group( + self, + management_group_id: str, + **kwargs + ) -> AsyncIterable["models.PolicyDefinitionListResult"]: + """This operation retrieves a list of all the policy definitions in a given management group. + + Retrieve policy definitions in a 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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyDefinitionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/aio/operations_async/_policy_set_definitions_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/aio/operations_async/_policy_set_definitions_operations_async.py new file mode 100644 index 000000000000..6d09aa0a0675 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/aio/operations_async/_policy_set_definitions_operations_async.py @@ -0,0 +1,652 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import 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 ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class PolicySetDefinitionsOperations: + """PolicySetDefinitionsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.policy.v2019_06_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def create_or_update( + self, + policy_set_definition_name: str, + parameters: "models.PolicySetDefinition", + **kwargs + ) -> "models.PolicySetDefinition": + """This operation creates or updates a policy set definition in the given subscription with the given name. + + Creates or updates a policy set definition. + + :param policy_set_definition_name: The name of the policy set definition to create. + :type policy_set_definition_name: str + :param parameters: The policy set definition properties. + :type parameters: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicySetDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicySetDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicySetDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + async def delete( + self, + policy_set_definition_name: str, + **kwargs + ) -> None: + """This operation deletes the policy set definition in the given subscription with the given name. + + Deletes a policy set definition. + + :param policy_set_definition_name: The name of the policy set definition to delete. + :type policy_set_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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 = { + '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] + + # Construct and send request + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + async def get( + self, + policy_set_definition_name: str, + **kwargs + ) -> "models.PolicySetDefinition": + """This operation retrieves the policy set definition in the given subscription with the given name. + + Retrieves a policy set definition. + + :param policy_set_definition_name: The name of the policy set definition to get. + :type policy_set_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicySetDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicySetDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + + # 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'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + async def get_built_in( + self, + policy_set_definition_name: str, + **kwargs + ) -> "models.PolicySetDefinition": + """This operation retrieves the built-in policy set definition with the given name. + + Retrieves a built in policy set definition. + + :param policy_set_definition_name: The name of the policy set definition to get. + :type policy_set_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicySetDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicySetDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + + # 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'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + def list( + self, + **kwargs + ) -> AsyncIterable["models.PolicySetDefinitionListResult"]: + """This operation retrieves a list of all the policy set definitions in the given subscription. + + Retrieves 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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('PolicySetDefinitionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + 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 + + def list_built_in( + self, + **kwargs + ) -> AsyncIterable["models.PolicySetDefinitionListResult"]: + """This operation retrieves a list of all the built-in policy set definitions. + + Retrieves 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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('PolicySetDefinitionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + 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 + + async def create_or_update_at_management_group( + self, + policy_set_definition_name: str, + management_group_id: str, + parameters: "models.PolicySetDefinition", + **kwargs + ) -> "models.PolicySetDefinition": + """This operation creates or updates a policy set definition in the given management group with the given name. + + Creates or updates a policy set definition. + + :param policy_set_definition_name: The name of the policy set definition to create. + :type policy_set_definition_name: str + :param management_group_id: The ID of the management group. + :type management_group_id: str + :param parameters: The policy set definition properties. + :type parameters: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicySetDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicySetDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicySetDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + + if cls: + 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 + + async def delete_at_management_group( + self, + policy_set_definition_name: str, + management_group_id: str, + **kwargs + ) -> None: + """This operation deletes the policy set definition in the given management group with the given name. + + Deletes a policy set definition. + + :param policy_set_definition_name: The name of the policy set definition to delete. + :type policy_set_definition_name: str + :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: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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 = { + '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] + + # Construct and send request + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + async def get_at_management_group( + self, + policy_set_definition_name: str, + management_group_id: str, + **kwargs + ) -> "models.PolicySetDefinition": + """This operation retrieves the policy set definition in the given management group with the given name. + + Retrieves a policy set definition. + + :param policy_set_definition_name: The name of the policy set definition to get. + :type policy_set_definition_name: str + :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: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicySetDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicySetDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + + # 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'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + + if cls: + 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 + + def list_by_management_group( + self, + management_group_id: str, + **kwargs + ) -> AsyncIterable["models.PolicySetDefinitionListResult"]: + """This operation retrieves a list of all the a policy set definition in the given management group. + + Retrieves all policy set definitions in 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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('PolicySetDefinitionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/models/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/models/__init__.py index 871692defb76..fa5d789fffec 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/models/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/models/__init__.py @@ -1,51 +1,52 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- try: - from ._models_py3 import ErrorResponse, ErrorResponseException + from ._models_py3 import ErrorResponse from ._models_py3 import Identity from ._models_py3 import PolicyAssignment + from ._models_py3 import PolicyAssignmentListResult from ._models_py3 import PolicyDefinition + from ._models_py3 import PolicyDefinitionListResult from ._models_py3 import PolicyDefinitionReference from ._models_py3 import PolicySetDefinition + from ._models_py3 import PolicySetDefinitionListResult from ._models_py3 import PolicySku except (SyntaxError, ImportError): - from ._models import ErrorResponse, ErrorResponseException - from ._models import Identity - from ._models import PolicyAssignment - from ._models import PolicyDefinition - from ._models import PolicyDefinitionReference - from ._models import PolicySetDefinition - from ._models import PolicySku -from ._paged_models import PolicyAssignmentPaged -from ._paged_models import PolicyDefinitionPaged -from ._paged_models import PolicySetDefinitionPaged + from ._models import ErrorResponse # type: ignore + from ._models import Identity # type: ignore + from ._models import PolicyAssignment # type: ignore + from ._models import PolicyAssignmentListResult # type: ignore + from ._models import PolicyDefinition # type: ignore + from ._models import PolicyDefinitionListResult # type: ignore + from ._models import PolicyDefinitionReference # type: ignore + from ._models import PolicySetDefinition # type: ignore + from ._models import PolicySetDefinitionListResult # type: ignore + from ._models import PolicySku # type: ignore + from ._policy_client_enums import ( EnforcementMode, - ResourceIdentityType, PolicyType, + ResourceIdentityType, ) __all__ = [ - 'ErrorResponse', 'ErrorResponseException', + 'ErrorResponse', 'Identity', 'PolicyAssignment', + 'PolicyAssignmentListResult', 'PolicyDefinition', + 'PolicyDefinitionListResult', 'PolicyDefinitionReference', 'PolicySetDefinition', + 'PolicySetDefinitionListResult', 'PolicySku', - 'PolicyAssignmentPaged', - 'PolicyDefinitionPaged', - 'PolicySetDefinitionPaged', 'EnforcementMode', - 'ResourceIdentityType', 'PolicyType', + 'ResourceIdentityType', ] 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 6d76cbd87a01..6811425f2738 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 @@ -1,29 +1,17 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.serialization import Model -from msrest.exceptions import HttpOperationError +from azure.core.exceptions import HttpResponseError +import msrest.serialization -class CloudError(Model): - """CloudError. - """ - - _attribute_map = { - } - - -class ErrorResponse(Model): - """Error response indicates Azure Resource Manager is not able to process the - incoming request. The reason is provided in the error message. +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 @@ -39,39 +27,27 @@ class ErrorResponse(Model): 'error_message': {'key': 'errorMessage', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ErrorResponse, self).__init__(**kwargs) self.http_status = kwargs.get('http_status', None) self.error_code = kwargs.get('error_code', None) self.error_message = kwargs.get('error_message', None) -class ErrorResponseException(HttpOperationError): - """Server responsed with exception of type: 'ErrorResponse'. - - :param deserialize: A deserializer - :param response: Server response to be deserialized. - """ - - def __init__(self, deserialize, response, *args): - - super(ErrorResponseException, self).__init__(deserialize, response, 'ErrorResponse', *args) - - -class Identity(Model): +class Identity(msrest.serialization.Model): """Identity for the resource. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar principal_id: The principal ID of the resource identity. :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 + :param type: The identity type. Possible values include: "SystemAssigned", "None". + :type type: str or ~azure.mgmt.resource.policy.v2019_06_01.models.ResourceIdentityType """ _validation = { @@ -82,26 +58,41 @@ class Identity(Model): _attribute_map = { 'principal_id': {'key': 'principalId', 'type': 'str'}, 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'ResourceIdentityType'}, + 'type': {'key': 'type', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Identity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None self.type = kwargs.get('type', None) -class PolicyAssignment(Model): +class PolicyAssignment(msrest.serialization.Model): """The policy assignment. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. + :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 + :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 + 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 assigned. + :param 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 @@ -109,31 +100,13 @@ class PolicyAssignment(Model): :type not_scopes: list[str] :param parameters: Required if a parameter is used in policy rule. :type parameters: object - :param description: This message will be part of response in case of - policy violation. + :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: object - :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 - :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 - :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 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 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 """ _validation = { @@ -143,6 +116,12 @@ class PolicyAssignment(Model): } _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'sku': {'key': 'sku', 'type': 'PolicySku'}, + 'location': {'key': 'location', 'type': 'str'}, + 'identity': {'key': 'identity', 'type': 'Identity'}, 'display_name': {'key': 'properties.displayName', 'type': 'str'}, 'policy_definition_id': {'key': 'properties.policyDefinitionId', 'type': 'str'}, 'scope': {'key': 'properties.scope', 'type': 'str'}, @@ -151,16 +130,19 @@ class PolicyAssignment(Model): 'description': {'key': 'properties.description', 'type': 'str'}, 'metadata': {'key': 'properties.metadata', 'type': 'object'}, 'enforcement_mode': {'key': 'properties.enforcementMode', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'PolicySku'}, - 'location': {'key': 'location', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(PolicyAssignment, self).__init__(**kwargs) + self.id = None + self.type = None + self.name = None + self.sku = kwargs.get('sku', None) + self.location = kwargs.get('location', None) + self.identity = kwargs.get('identity', None) self.display_name = kwargs.get('display_name', None) self.policy_definition_id = kwargs.get('policy_definition_id', None) self.scope = kwargs.get('scope', None) @@ -169,25 +151,45 @@ def __init__(self, **kwargs): self.description = kwargs.get('description', None) self.metadata = kwargs.get('metadata', None) self.enforcement_mode = kwargs.get('enforcement_mode', None) - self.id = None - self.type = None - self.name = None - self.sku = kwargs.get('sku', None) - self.location = kwargs.get('location', None) - self.identity = kwargs.get('identity', None) -class PolicyDefinition(Model): +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 + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[PolicyAssignment]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(PolicyAssignmentListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class PolicyDefinition(msrest.serialization.Model): """The policy definition. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :param 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 + :ivar id: The ID of the policy definition. + :vartype id: str + :ivar name: The name of the policy definition. + :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, + 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, Microsoft.KeyVault.Data. :type mode: str @@ -201,13 +203,6 @@ class PolicyDefinition(Model): :type metadata: object :param parameters: Required if a parameter is used in policy rule. :type parameters: object - :ivar id: The ID of the policy definition. - :vartype id: str - :ivar name: The name of the policy definition. - :vartype name: str - :ivar type: The type of the resource - (Microsoft.Authorization/policyDefinitions). - :vartype type: str """ _validation = { @@ -217,6 +212,9 @@ class PolicyDefinition(Model): } _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, 'policy_type': {'key': 'properties.policyType', 'type': 'str'}, 'mode': {'key': 'properties.mode', 'type': 'str'}, 'display_name': {'key': 'properties.displayName', 'type': 'str'}, @@ -224,13 +222,16 @@ class PolicyDefinition(Model): 'policy_rule': {'key': 'properties.policyRule', 'type': 'object'}, 'metadata': {'key': 'properties.metadata', 'type': 'object'}, 'parameters': {'key': 'properties.parameters', 'type': 'object'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(PolicyDefinition, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None self.policy_type = kwargs.get('policy_type', None) self.mode = kwargs.get('mode', None) self.display_name = kwargs.get('display_name', None) @@ -238,16 +239,35 @@ def __init__(self, **kwargs): self.policy_rule = kwargs.get('policy_rule', None) self.metadata = kwargs.get('metadata', None) self.parameters = kwargs.get('parameters', None) - self.id = None - self.name = None - self.type = None -class PolicyDefinitionReference(Model): +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 + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[PolicyDefinition]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(PolicyDefinitionListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class PolicyDefinitionReference(msrest.serialization.Model): """The policy definition reference. - :param policy_definition_id: The ID of the policy definition or policy set - definition. + :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: object @@ -258,86 +278,106 @@ class PolicyDefinitionReference(Model): 'parameters': {'key': 'parameters', 'type': 'object'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(PolicyDefinitionReference, self).__init__(**kwargs) self.policy_definition_id = kwargs.get('policy_definition_id', None) self.parameters = kwargs.get('parameters', None) -class PolicySetDefinition(Model): +class PolicySetDefinition(msrest.serialization.Model): """The policy set definition. - Variables are only populated by the server, and will be ignored when - sending a request. - - All required parameters must be populated in order to send to Azure. + Variables are only populated by the server, and will be ignored when sending a request. - :param 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 + :ivar id: The ID of the policy set definition. + :vartype id: str + :ivar name: The name of the policy set definition. + :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, + 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: object - :param parameters: The policy set definition parameters that can be used - in policy definition references. - :type parameters: object - :param policy_definitions: Required. An array of policy definition + :param parameters: The policy set definition parameters that can be used in policy definition references. + :type parameters: object + :param policy_definitions: An array of policy definition references. :type policy_definitions: list[~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinitionReference] - :ivar id: The ID of the policy set definition. - :vartype id: str - :ivar name: The name of the policy set definition. - :vartype name: str - :ivar type: The type of the resource - (Microsoft.Authorization/policySetDefinitions). - :vartype type: str """ _validation = { - 'policy_definitions': {'required': True}, 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, } _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, 'policy_type': {'key': 'properties.policyType', 'type': 'str'}, 'display_name': {'key': 'properties.displayName', 'type': 'str'}, 'description': {'key': 'properties.description', 'type': 'str'}, 'metadata': {'key': 'properties.metadata', 'type': 'object'}, 'parameters': {'key': 'properties.parameters', 'type': 'object'}, 'policy_definitions': {'key': 'properties.policyDefinitions', 'type': '[PolicyDefinitionReference]'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(PolicySetDefinition, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None self.policy_type = kwargs.get('policy_type', None) self.display_name = kwargs.get('display_name', None) self.description = kwargs.get('description', None) self.metadata = kwargs.get('metadata', None) self.parameters = kwargs.get('parameters', None) self.policy_definitions = kwargs.get('policy_definitions', None) - self.id = None - self.name = None - self.type = None -class PolicySku(Model): +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 + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[PolicySetDefinition]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(PolicySetDefinitionListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class PolicySku(msrest.serialization.Model): """The policy sku. This property is optional, obsolete, and will be ignored. 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. + :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 @@ -352,7 +392,10 @@ class PolicySku(Model): 'tier': {'key': 'tier', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(PolicySku, self).__init__(**kwargs) - self.name = kwargs.get('name', None) + 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 dd814ee24957..e0a31a1a00f9 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 @@ -1,29 +1,21 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.serialization import Model -from msrest.exceptions import HttpOperationError +from typing import List, Optional, Union +from azure.core.exceptions import HttpResponseError +import msrest.serialization -class CloudError(Model): - """CloudError. - """ - - _attribute_map = { - } +from ._policy_client_enums import * -class ErrorResponse(Model): - """Error response indicates Azure Resource Manager is not able to process the - incoming request. The reason is provided in the error message. +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 @@ -39,39 +31,31 @@ class ErrorResponse(Model): 'error_message': {'key': 'errorMessage', 'type': 'str'}, } - def __init__(self, *, http_status: str=None, error_code: str=None, error_message: str=None, **kwargs) -> None: + def __init__( + self, + *, + http_status: Optional[str] = None, + error_code: Optional[str] = None, + error_message: Optional[str] = None, + **kwargs + ): super(ErrorResponse, self).__init__(**kwargs) self.http_status = http_status self.error_code = error_code self.error_message = error_message -class ErrorResponseException(HttpOperationError): - """Server responsed with exception of type: 'ErrorResponse'. - - :param deserialize: A deserializer - :param response: Server response to be deserialized. - """ - - def __init__(self, deserialize, response, *args): - - super(ErrorResponseException, self).__init__(deserialize, response, 'ErrorResponse', *args) - - -class Identity(Model): +class Identity(msrest.serialization.Model): """Identity for the resource. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar principal_id: The principal ID of the resource identity. :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 + :param type: The identity type. Possible values include: "SystemAssigned", "None". + :type type: str or ~azure.mgmt.resource.policy.v2019_06_01.models.ResourceIdentityType """ _validation = { @@ -82,26 +66,43 @@ class Identity(Model): _attribute_map = { 'principal_id': {'key': 'principalId', 'type': 'str'}, 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'ResourceIdentityType'}, + 'type': {'key': 'type', 'type': 'str'}, } - def __init__(self, *, type=None, **kwargs) -> None: + def __init__( + self, + *, + type: Optional[Union[str, "ResourceIdentityType"]] = None, + **kwargs + ): super(Identity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None self.type = type -class PolicyAssignment(Model): +class PolicyAssignment(msrest.serialization.Model): """The policy assignment. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. + :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 + :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 + 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 assigned. + :param 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 @@ -109,31 +110,13 @@ class PolicyAssignment(Model): :type not_scopes: list[str] :param parameters: Required if a parameter is used in policy rule. :type parameters: object - :param description: This message will be part of response in case of - policy violation. + :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: object - :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 - :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 - :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 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 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 """ _validation = { @@ -143,6 +126,12 @@ class PolicyAssignment(Model): } _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'sku': {'key': 'sku', 'type': 'PolicySku'}, + 'location': {'key': 'location', 'type': 'str'}, + 'identity': {'key': 'identity', 'type': 'Identity'}, 'display_name': {'key': 'properties.displayName', 'type': 'str'}, 'policy_definition_id': {'key': 'properties.policyDefinitionId', 'type': 'str'}, 'scope': {'key': 'properties.scope', 'type': 'str'}, @@ -151,16 +140,31 @@ class PolicyAssignment(Model): 'description': {'key': 'properties.description', 'type': 'str'}, 'metadata': {'key': 'properties.metadata', 'type': 'object'}, 'enforcement_mode': {'key': 'properties.enforcementMode', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'PolicySku'}, - 'location': {'key': 'location', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, } - def __init__(self, *, display_name: str=None, policy_definition_id: str=None, scope: str=None, not_scopes=None, parameters=None, description: str=None, metadata=None, enforcement_mode=None, sku=None, location: str=None, identity=None, **kwargs) -> None: + def __init__( + self, + *, + sku: Optional["PolicySku"] = None, + location: Optional[str] = None, + identity: Optional["Identity"] = None, + display_name: Optional[str] = None, + policy_definition_id: Optional[str] = None, + scope: Optional[str] = None, + not_scopes: Optional[List[str]] = None, + parameters: Optional[object] = None, + description: Optional[str] = None, + metadata: Optional[object] = None, + enforcement_mode: Optional[Union[str, "EnforcementMode"]] = None, + **kwargs + ): super(PolicyAssignment, self).__init__(**kwargs) + self.id = None + self.type = None + self.name = None + self.sku = sku + self.location = location + self.identity = identity self.display_name = display_name self.policy_definition_id = policy_definition_id self.scope = scope @@ -169,25 +173,48 @@ def __init__(self, *, display_name: str=None, policy_definition_id: str=None, sc self.description = description self.metadata = metadata self.enforcement_mode = enforcement_mode - self.id = None - self.type = None - self.name = None - self.sku = sku - self.location = location - self.identity = identity -class PolicyDefinition(Model): +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 + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[PolicyAssignment]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["PolicyAssignment"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(PolicyAssignmentListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class PolicyDefinition(msrest.serialization.Model): """The policy definition. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :param 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 + :ivar id: The ID of the policy definition. + :vartype id: str + :ivar name: The name of the policy definition. + :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, + 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, Microsoft.KeyVault.Data. :type mode: str @@ -201,13 +228,6 @@ class PolicyDefinition(Model): :type metadata: object :param parameters: Required if a parameter is used in policy rule. :type parameters: object - :ivar id: The ID of the policy definition. - :vartype id: str - :ivar name: The name of the policy definition. - :vartype name: str - :ivar type: The type of the resource - (Microsoft.Authorization/policyDefinitions). - :vartype type: str """ _validation = { @@ -217,6 +237,9 @@ class PolicyDefinition(Model): } _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, 'policy_type': {'key': 'properties.policyType', 'type': 'str'}, 'mode': {'key': 'properties.mode', 'type': 'str'}, 'display_name': {'key': 'properties.displayName', 'type': 'str'}, @@ -224,13 +247,24 @@ class PolicyDefinition(Model): 'policy_rule': {'key': 'properties.policyRule', 'type': 'object'}, 'metadata': {'key': 'properties.metadata', 'type': 'object'}, 'parameters': {'key': 'properties.parameters', 'type': 'object'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, } - def __init__(self, *, policy_type=None, mode: str=None, display_name: str=None, description: str=None, policy_rule=None, metadata=None, parameters=None, **kwargs) -> None: + def __init__( + self, + *, + policy_type: Optional[Union[str, "PolicyType"]] = None, + mode: Optional[str] = None, + display_name: Optional[str] = None, + description: Optional[str] = None, + policy_rule: Optional[object] = None, + metadata: Optional[object] = None, + parameters: Optional[object] = None, + **kwargs + ): super(PolicyDefinition, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None self.policy_type = policy_type self.mode = mode self.display_name = display_name @@ -238,16 +272,38 @@ def __init__(self, *, policy_type=None, mode: str=None, display_name: str=None, self.policy_rule = policy_rule self.metadata = metadata self.parameters = parameters - self.id = None - self.name = None - self.type = None -class PolicyDefinitionReference(Model): +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 + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[PolicyDefinition]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["PolicyDefinition"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(PolicyDefinitionListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class PolicyDefinitionReference(msrest.serialization.Model): """The policy definition reference. - :param policy_definition_id: The ID of the policy definition or policy set - definition. + :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: object @@ -258,86 +314,119 @@ class PolicyDefinitionReference(Model): 'parameters': {'key': 'parameters', 'type': 'object'}, } - def __init__(self, *, policy_definition_id: str=None, parameters=None, **kwargs) -> None: + def __init__( + self, + *, + policy_definition_id: Optional[str] = None, + parameters: Optional[object] = None, + **kwargs + ): super(PolicyDefinitionReference, self).__init__(**kwargs) self.policy_definition_id = policy_definition_id self.parameters = parameters -class PolicySetDefinition(Model): +class PolicySetDefinition(msrest.serialization.Model): """The policy set definition. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. - - :param 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 + :ivar id: The ID of the policy set definition. + :vartype id: str + :ivar name: The name of the policy set definition. + :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, + 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: object - :param parameters: The policy set definition parameters that can be used - in policy definition references. - :type parameters: object - :param policy_definitions: Required. An array of policy definition + :param parameters: The policy set definition parameters that can be used in policy definition references. + :type parameters: object + :param policy_definitions: An array of policy definition references. :type policy_definitions: list[~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinitionReference] - :ivar id: The ID of the policy set definition. - :vartype id: str - :ivar name: The name of the policy set definition. - :vartype name: str - :ivar type: The type of the resource - (Microsoft.Authorization/policySetDefinitions). - :vartype type: str """ _validation = { - 'policy_definitions': {'required': True}, 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, } _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, 'policy_type': {'key': 'properties.policyType', 'type': 'str'}, 'display_name': {'key': 'properties.displayName', 'type': 'str'}, 'description': {'key': 'properties.description', 'type': 'str'}, 'metadata': {'key': 'properties.metadata', 'type': 'object'}, 'parameters': {'key': 'properties.parameters', 'type': 'object'}, 'policy_definitions': {'key': 'properties.policyDefinitions', 'type': '[PolicyDefinitionReference]'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, } - def __init__(self, *, policy_definitions, policy_type=None, display_name: str=None, description: str=None, metadata=None, parameters=None, **kwargs) -> None: + def __init__( + self, + *, + policy_type: Optional[Union[str, "PolicyType"]] = None, + display_name: Optional[str] = None, + description: Optional[str] = None, + metadata: Optional[object] = None, + parameters: Optional[object] = None, + policy_definitions: Optional[List["PolicyDefinitionReference"]] = None, + **kwargs + ): super(PolicySetDefinition, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None self.policy_type = policy_type self.display_name = display_name self.description = description self.metadata = metadata self.parameters = parameters self.policy_definitions = policy_definitions - self.id = None - self.name = None - self.type = None -class PolicySku(Model): +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 + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[PolicySetDefinition]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["PolicySetDefinition"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(PolicySetDefinitionListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class PolicySku(msrest.serialization.Model): """The policy sku. This property is optional, obsolete, and will be ignored. 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. + :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 @@ -352,7 +441,13 @@ class PolicySku(Model): 'tier': {'key': 'tier', 'type': 'str'}, } - def __init__(self, *, name: str, tier: str=None, **kwargs) -> None: + def __init__( + self, + *, + name: str, + tier: Optional[str] = None, + **kwargs + ): 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/_paged_models.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/models/_paged_models.py deleted file mode 100644 index 4b47efe6b779..000000000000 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/models/_paged_models.py +++ /dev/null @@ -1,53 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.paging import Paged - - -class PolicyAssignmentPaged(Paged): - """ - A paging container for iterating over a list of :class:`PolicyAssignment ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[PolicyAssignment]'} - } - - def __init__(self, *args, **kwargs): - - super(PolicyAssignmentPaged, self).__init__(*args, **kwargs) -class PolicyDefinitionPaged(Paged): - """ - A paging container for iterating over a list of :class:`PolicyDefinition ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[PolicyDefinition]'} - } - - def __init__(self, *args, **kwargs): - - super(PolicyDefinitionPaged, self).__init__(*args, **kwargs) -class PolicySetDefinitionPaged(Paged): - """ - A paging container for iterating over a list of :class:`PolicySetDefinition ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[PolicySetDefinition]'} - } - - def __init__(self, *args, **kwargs): - - super(PolicySetDefinitionPaged, self).__init__(*args, **kwargs) 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 387aac38a63d..133d4c286365 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 @@ -1,31 +1,31 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from enum import Enum - class EnforcementMode(str, Enum): + """The policy assignment enforcement mode. Possible values are Default and DoNotEnforce. + """ default = "Default" #: The policy effect is enforced during resource creation or update. do_not_enforce = "DoNotEnforce" #: The policy effect is not enforced during resource creation or update. - -class ResourceIdentityType(str, Enum): - - system_assigned = "SystemAssigned" - none = "None" - - class PolicyType(str, Enum): + """The type of policy definition. Possible values are NotSpecified, BuiltIn, and Custom. + """ not_specified = "NotSpecified" built_in = "BuiltIn" custom = "Custom" + +class ResourceIdentityType(str, Enum): + """The identity type. + """ + + system_assigned = "SystemAssigned" + none = "None" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/operations/__init__.py index c7d7b8eb9d97..4583d62b03a4 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/operations/__init__.py @@ -1,12 +1,9 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from ._policy_assignments_operations import PolicyAssignmentsOperations 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 c3d3c9427bb2..633029ef6da1 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 @@ -1,778 +1,670 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class PolicyAssignmentsOperations(object): """PolicyAssignmentsOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.policy.v2019_06_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for the operation. Constant value: "2019-06-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-06-01" - - self.config = config + self._config = config def delete( - self, scope, policy_assignment_name, custom_headers=None, raw=False, **operation_config): - """Deletes a policy assignment. - - This operation deletes a policy assignment, given its name and the - scope it was created in. The scope of a policy assignment is the part - of its ID preceding - '/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. - - :param scope: The scope of the policy assignment. Valid scopes are: - management group (format: - '/providers/Microsoft.Management/managementGroups/{managementGroup}'), - subscription (format: '/subscriptions/{subscriptionId}'), resource - group (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', - or resource (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' + self, + scope, # type: str + policy_assignment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyAssignment" + """This operation deletes a policy assignment, given its name and the scope it was created in. The scope of a policy assignment is the part of its ID preceding '/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + + Deletes a policy assignment. + + :param scope: The scope of the policy assignment. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. :type scope: str - :param policy_assignment_name: The name of the policy assignment to - delete. + :param policy_assignment_name: The name of the policy assignment to delete. :type policy_assignment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyAssignment or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignment or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignment or None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + # Construct URL - url = self.delete.metadata['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') + 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('PolicyAssignment', response) + deserialized = self._deserialize('PolicyAssignment', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} + delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore def create( - self, scope, policy_assignment_name, parameters, custom_headers=None, raw=False, **operation_config): - """Creates or updates a policy assignment. - - This operation creates or updates a policy assignment with the given - scope and name. Policy assignments apply to all resources contained - within their scope. For example, when you assign a policy at resource - group scope, that policy applies to all resources in the group. - - :param scope: The scope of the policy assignment. Valid scopes are: - management group (format: - '/providers/Microsoft.Management/managementGroups/{managementGroup}'), - subscription (format: '/subscriptions/{subscriptionId}'), resource - group (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', - or resource (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' + self, + scope, # type: str + policy_assignment_name, # type: str + parameters, # type: "models.PolicyAssignment" + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyAssignment" + """This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + + Creates or updates a policy assignment. + + :param scope: The scope of the policy assignment. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. :type scope: str :param policy_assignment_name: The name of the policy assignment. :type policy_assignment_name: str :param parameters: Parameters for the policy assignment. - :type parameters: - ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignment - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyAssignment or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignment or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :type parameters: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignment + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + content_type = kwargs.pop("content_type", "application/json") + # Construct URL - url = self.create.metadata['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') + 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'PolicyAssignment') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 201: - deserialized = self._deserialize('PolicyAssignment', response) + deserialized = self._deserialize('PolicyAssignment', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} + create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore def get( - self, scope, policy_assignment_name, custom_headers=None, raw=False, **operation_config): - """Retrieves a policy assignment. - - This operation retrieves a single policy assignment, given its name and - the scope it was created at. - - :param scope: The scope of the policy assignment. Valid scopes are: - management group (format: - '/providers/Microsoft.Management/managementGroups/{managementGroup}'), - subscription (format: '/subscriptions/{subscriptionId}'), resource - group (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', - or resource (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' + self, + scope, # type: str + policy_assignment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyAssignment" + """This operation retrieves a single policy assignment, given its name and the scope it was created at. + + Retrieves a policy assignment. + + :param scope: The scope of the policy assignment. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. :type scope: str - :param policy_assignment_name: The name of the policy assignment to - get. + :param policy_assignment_name: The name of the policy assignment to get. :type policy_assignment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyAssignment or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignment or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + # Construct URL - url = self.get.metadata['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') + 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('PolicyAssignment', response) + deserialized = self._deserialize('PolicyAssignment', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} + get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore def list_for_resource_group( - self, resource_group_name, filter=None, custom_headers=None, raw=False, **operation_config): - """Retrieves all policy assignments that apply to a resource group. - - This operation retrieves the list of all policy assignments associated - with the given resource group in the given subscription that match the - optional given $filter. Valid values for $filter are: 'atScope()' or - 'policyDefinitionId eq '{value}''. If $filter is not provided, the - unfiltered list includes all policy assignments associated with the - resource group, including those that apply directly or apply from - containing scopes, as well as any applied to resources contained within - the resource group. If $filter=atScope() is provided, the returned list - includes all policy assignments that apply to the resource group, which - is everything in the unfiltered list except those applied to resources - contained within the resource group. If $filter=policyDefinitionId eq - '{value}' is provided, the returned list includes all policy - assignments of the policy definition whose id is {value} that apply to - the resource group. - - :param resource_group_name: The name of the resource group that - contains policy assignments. + self, + resource_group_name, # type: str + filter=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.PolicyAssignmentListResult"] + """This operation retrieves the list of all policy assignments associated with the given resource group in the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource group, including those that apply directly or apply from containing scopes, as well as any applied to resources contained within the resource group. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource group, which is everything in the unfiltered list except those applied to resources contained within the resource group. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource group. + + Retrieves all policy assignments that apply to a resource group. + + :param resource_group_name: The name of the resource group that contains policy assignments. :type resource_group_name: str - :param filter: The filter to apply on the operation. Valid values for - $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If - $filter is not provided, no filtering is performed. + :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()' + or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. :type filter: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of PolicyAssignment - :rtype: - ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignmentPaged[~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignment] - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_for_resource_group.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) - - return response + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.PolicyAssignmentPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list_for_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments'} + return ItemPaged( + get_next, extract_data + ) + list_for_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments'} # type: ignore def list_for_resource( - self, resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, filter=None, custom_headers=None, raw=False, **operation_config): - """Retrieves all policy assignments that apply to a resource. - - This operation retrieves the list of all policy assignments associated - with the specified resource in the given resource group and - subscription that match the optional given $filter. Valid values for - $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If - $filter is not provided, the unfiltered list includes all policy - assignments associated with the resource, including those that apply - directly or from all containing scopes, as well as any applied to - resources contained within the resource. If $filter=atScope() is - provided, the returned list includes all policy assignments that apply - to the resource, which is everything in the unfiltered list except - those applied to resources contained within the resource. If - $filter=policyDefinitionId eq '{value}' is provided, the returned list - includes all policy assignments of the policy definition whose id is - {value} that apply to the resource. Three parameters plus the resource - name are used to identify a specific resource. If the resource is not - part of a parent resource (the more common case), the parent resource - path should not be provided (or provided as ''). For example a web app - could be specified as ({resourceProviderNamespace} == 'Microsoft.Web', - {parentResourcePath} == '', {resourceType} == 'sites', {resourceName} - == 'MyWebApp'). If the resource is part of a parent resource, then all - parameters should be provided. For example a virtual machine DNS name - could be specified as ({resourceProviderNamespace} == - 'Microsoft.Compute', {parentResourcePath} == - 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames', - {resourceName} == 'MyComputerName'). A convenient alternative to - providing the namespace and type name separately is to provide both in - the {resourceType} parameter, format: ({resourceProviderNamespace} == - '', {parentResourcePath} == '', {resourceType} == - 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). - - :param resource_group_name: The name of the resource group containing - the resource. + self, + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + filter=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.PolicyAssignmentListResult"] + """This operation retrieves the list of all policy assignments associated with the specified resource in the given resource group and subscription that match the optional given $filter. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource, including those that apply directly or from all containing scopes, as well as any applied to resources contained within the resource. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource, which is everything in the unfiltered list except those applied to resources contained within the resource. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource. Three parameters plus the resource name are used to identify a specific resource. If the resource is not part of a parent resource (the more common case), the parent resource path should not be provided (or provided as ''). For example a web app could be specified as ({resourceProviderNamespace} == 'Microsoft.Web', {parentResourcePath} == '', {resourceType} == 'sites', {resourceName} == 'MyWebApp'). If the resource is part of a parent resource, then all parameters should be provided. For example a virtual machine DNS name could be specified as ({resourceProviderNamespace} == 'Microsoft.Compute', {parentResourcePath} == 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames', {resourceName} == 'MyComputerName'). A convenient alternative to providing the namespace and type name separately is to provide both in the {resourceType} parameter, format: ({resourceProviderNamespace} == '', {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). + + Retrieves all policy assignments that apply to a resource. + + :param resource_group_name: The name of the resource group containing the resource. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource - provider. For example, the namespace of a virtual machine is - Microsoft.Compute (from Microsoft.Compute/virtualMachines) + :param resource_provider_namespace: The namespace of the resource provider. For example, the + namespace of a virtual machine is Microsoft.Compute (from Microsoft.Compute/virtualMachines). :type resource_provider_namespace: str - :param parent_resource_path: The parent resource path. Use empty - string if there is none. + :param parent_resource_path: The parent resource path. Use empty string if there is none. :type parent_resource_path: str - :param resource_type: The resource type name. For example the type - name of a web app is 'sites' (from Microsoft.Web/sites). + :param resource_type: The resource type name. For example the type name of a web app is 'sites' + (from Microsoft.Web/sites). :type resource_type: str :param resource_name: The name of the resource. :type resource_name: str - :param filter: The filter to apply on the operation. Valid values for - $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If - $filter is not provided, no filtering is performed. + :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()' + or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. :type filter: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of PolicyAssignment - :rtype: - ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignmentPaged[~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignment] - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_for_resource.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.PolicyAssignmentPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_for_resource.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments'} + 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 def list( - self, filter=None, custom_headers=None, raw=False, **operation_config): - """Retrieves all policy assignments that apply to a subscription. - - This operation retrieves the list of all policy assignments associated - with the given subscription that match the optional given $filter. - Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq - '{value}''. If $filter is not provided, the unfiltered list includes - all policy assignments associated with the subscription, including - those that apply directly or from management groups that contain the - given subscription, as well as any applied to objects contained within - the subscription. If $filter=atScope() is provided, the returned list - includes all policy assignments that apply to the subscription, which - is everything in the unfiltered list except those applied to objects - contained within the subscription. If $filter=policyDefinitionId eq - '{value}' is provided, the returned list includes all policy - assignments of the policy definition whose id is {value}. - - :param filter: The filter to apply on the operation. Valid values for - $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If - $filter is not provided, no filtering is performed. + self, + filter=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.PolicyAssignmentListResult"] + """This operation retrieves the list of all policy assignments associated with the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the subscription, including those that apply directly or from management groups that contain the given subscription, as well as any applied to objects contained within the subscription. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the subscription, which is everything in the unfiltered list except those applied to objects contained within the subscription. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value}. + + Retrieves all policy assignments that apply to a subscription. + + :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()' + or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. :type filter: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of PolicyAssignment - :rtype: - ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignmentPaged[~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignment] - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['url'] + url = self.list.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_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 = {} + 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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) - - return response + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.PolicyAssignmentPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments'} # type: ignore def delete_by_id( - self, policy_assignment_id, custom_headers=None, raw=False, **operation_config): - """Deletes a policy assignment. - - This operation deletes the policy with the given ID. Policy assignment - IDs have this format: - '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. - Valid formats for {scope} are: - '/providers/Microsoft.Management/managementGroups/{managementGroup}' - (management group), '/subscriptions/{subscriptionId}' (subscription), - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' - (resource group), or - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' - (resource). - - :param policy_assignment_id: The ID of the policy assignment to - delete. Use the format + self, + policy_assignment_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyAssignment" + """This operation deletes the policy with the given ID. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid formats for {scope} are: '/providers/Microsoft.Management/managementGroups/{managementGroup}' (management group), '/subscriptions/{subscriptionId}' (subscription), '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' (resource group), or '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' (resource). + + Deletes a policy assignment. + + :param policy_assignment_id: The ID of the policy assignment to delete. Use the format '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. :type policy_assignment_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyAssignment or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignment or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignment or None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + # Construct URL - url = self.delete_by_id.metadata['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) + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('PolicyAssignment', response) + deserialized = self._deserialize('PolicyAssignment', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - delete_by_id.metadata = {'url': '/{policyAssignmentId}'} + delete_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore def create_by_id( - self, policy_assignment_id, parameters, custom_headers=None, raw=False, **operation_config): - """Creates or updates a policy assignment. - - This operation creates or updates the policy assignment with the given - ID. Policy assignments made on a scope apply to all resources contained - in that scope. For example, when you assign a policy to a resource - group that policy applies to all resources in the group. Policy - assignment IDs have this format: - '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. - Valid scopes are: management group (format: - '/providers/Microsoft.Management/managementGroups/{managementGroup}'), - subscription (format: '/subscriptions/{subscriptionId}'), resource - group (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', - or resource (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. - - :param policy_assignment_id: The ID of the policy assignment to - create. Use the format + self, + policy_assignment_id, # type: str + parameters, # type: "models.PolicyAssignment" + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyAssignment" + """This operation creates or updates the policy assignment with the given ID. Policy assignments made on a scope apply to all resources contained in that scope. For example, when you assign a policy to a resource group that policy applies to all resources in the group. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + + Creates or updates a policy assignment. + + :param policy_assignment_id: The ID of the policy assignment to create. Use the format '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. :type policy_assignment_id: str :param parameters: Parameters for policy assignment. - :type parameters: - ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignment - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyAssignment or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignment or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :type parameters: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignment + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + content_type = kwargs.pop("content_type", "application/json") + # Construct URL - url = self.create_by_id.metadata['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) + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'PolicyAssignment') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 201: - deserialized = self._deserialize('PolicyAssignment', response) + deserialized = self._deserialize('PolicyAssignment', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create_by_id.metadata = {'url': '/{policyAssignmentId}'} + create_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore def get_by_id( - self, policy_assignment_id, custom_headers=None, raw=False, **operation_config): - """Retrieves the policy assignment with the given ID. - - The operation retrieves the policy assignment with the given ID. Policy - assignment IDs have this format: - '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. - Valid scopes are: management group (format: - '/providers/Microsoft.Management/managementGroups/{managementGroup}'), - subscription (format: '/subscriptions/{subscriptionId}'), resource - group (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', - or resource (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. - - :param policy_assignment_id: The ID of the policy assignment to get. - Use the format + self, + policy_assignment_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyAssignment" + """The operation retrieves the policy assignment with the given ID. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + + Retrieves the policy assignment with the given ID. + + :param policy_assignment_id: The ID of the policy assignment to get. Use the format '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. :type policy_assignment_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyAssignment or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignment or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + # Construct URL - url = self.get_by_id.metadata['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) + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('PolicyAssignment', response) + deserialized = self._deserialize('PolicyAssignment', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/{policyAssignmentId}'} + 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 6def5f46aeb7..b3194788b8d0 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 @@ -1,686 +1,646 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class PolicyDefinitionsOperations(object): """PolicyDefinitionsOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.policy.v2019_06_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for the operation. Constant value: "2019-06-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-06-01" - - self.config = config + self._config = config def create_or_update( - self, policy_definition_name, parameters, custom_headers=None, raw=False, **operation_config): - """Creates or updates a policy definition in a subscription. + self, + policy_definition_name, # type: str + parameters, # type: "models.PolicyDefinition" + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyDefinition" + """This operation creates or updates a policy definition in the given subscription with the given name. - This operation creates or updates a policy definition in the given - subscription with the given name. + Creates or updates a policy definition in a subscription. - :param policy_definition_name: The name of the policy definition to - create. + :param policy_definition_name: The name of the policy definition to create. :type policy_definition_name: str :param parameters: The policy definition properties. - :type parameters: - ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinition - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyDefinition or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinition or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :type parameters: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinition + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + content_type = kwargs.pop("content_type", "application/json") + # Construct URL - url = self.create_or_update.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'PolicyDefinition') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [201]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 201: - deserialized = self._deserialize('PolicyDefinition', response) + deserialized = self._deserialize('PolicyDefinition', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore def delete( - self, policy_definition_name, custom_headers=None, raw=False, **operation_config): - """Deletes a policy definition in a subscription. + self, + policy_definition_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """This operation deletes the policy definition in the given subscription with the given name. - This operation deletes the policy definition in the given subscription - with the given name. + Deletes a policy definition in a subscription. - :param policy_definition_name: The name of the policy definition to - delete. + :param policy_definition_name: The name of the policy definition to delete. :type policy_definition_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + # Construct URL - url = self.delete.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} + delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore def get( - self, policy_definition_name, custom_headers=None, raw=False, **operation_config): - """Retrieves a policy definition in a subscription. + self, + policy_definition_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyDefinition" + """This operation retrieves the policy definition in the given subscription with the given name. - This operation retrieves the policy definition in the given - subscription with the given name. + Retrieves a policy definition in a subscription. - :param policy_definition_name: The name of the policy definition to - get. + :param policy_definition_name: The name of the policy definition to get. :type policy_definition_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyDefinition or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinition or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinition + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + # Construct URL - url = self.get.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('PolicyDefinition', response) + deserialized = self._deserialize('PolicyDefinition', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore def get_built_in( - self, policy_definition_name, custom_headers=None, raw=False, **operation_config): - """Retrieves a built-in policy definition. + self, + policy_definition_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyDefinition" + """This operation retrieves the built-in policy definition with the given name. - This operation retrieves the built-in policy definition with the given - name. + Retrieves a built-in policy definition. - :param policy_definition_name: The name of the built-in policy - definition to get. + :param policy_definition_name: The name of the built-in policy definition to get. :type policy_definition_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyDefinition or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinition or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinition + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + # Construct URL - url = self.get_built_in.metadata['url'] + url = self.get_built_in.metadata['url'] # type: ignore path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str') + 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('PolicyDefinition', response) + deserialized = self._deserialize('PolicyDefinition', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} + get_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore def create_or_update_at_management_group( - self, policy_definition_name, parameters, management_group_id, custom_headers=None, raw=False, **operation_config): - """Creates or updates a policy definition in a management group. - - This operation creates or updates a policy definition in the given - management group with the given name. - - :param policy_definition_name: The name of the policy definition to - create. + self, + policy_definition_name, # type: str + management_group_id, # type: str + parameters, # type: "models.PolicyDefinition" + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyDefinition" + """This operation creates or updates a policy definition in the given management group with the given name. + + Creates or updates a policy definition in a management group. + + :param policy_definition_name: The name of the policy definition to create. :type policy_definition_name: str - :param parameters: The policy definition properties. - :type parameters: - ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinition :param management_group_id: The ID of the management group. :type management_group_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyDefinition or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinition or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :param parameters: The policy definition properties. + :type parameters: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinition + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + content_type = kwargs.pop("content_type", "application/json") + # Construct URL - url = self.create_or_update_at_management_group.metadata['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') + 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'PolicyDefinition') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [201]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 201: - deserialized = self._deserialize('PolicyDefinition', response) + deserialized = self._deserialize('PolicyDefinition', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + 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}'} + create_or_update_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore def delete_at_management_group( - self, policy_definition_name, management_group_id, custom_headers=None, raw=False, **operation_config): - """Deletes a policy definition in a management group. + self, + policy_definition_name, # type: str + management_group_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """This operation deletes the policy definition in the given management group with the given name. - This operation deletes the policy definition in the given management - group with the given name. + Deletes a policy definition in a management group. - :param policy_definition_name: The name of the policy definition to - delete. + :param policy_definition_name: The name of the policy definition to delete. :type policy_definition_name: str :param management_group_id: The ID of the management group. :type management_group_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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'] + 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') + 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} + if cls: + return cls(pipeline_response, None, {}) + + delete_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore def get_at_management_group( - self, policy_definition_name, management_group_id, custom_headers=None, raw=False, **operation_config): - """Retrieve a policy definition in a management group. + self, + policy_definition_name, # type: str + management_group_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyDefinition" + """This operation retrieves the policy definition in the given management group with the given name. - This operation retrieves the policy definition in the given management - group with the given name. + Retrieve a policy definition in a management group. - :param policy_definition_name: The name of the policy definition to - get. + :param policy_definition_name: The name of the policy definition to get. :type policy_definition_name: str :param management_group_id: The ID of the management group. :type management_group_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyDefinition or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinition or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinition + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + # Construct URL - url = self.get_at_management_group.metadata['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') + 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('PolicyDefinition', response) + deserialized = self._deserialize('PolicyDefinition', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} + get_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore def list( - self, custom_headers=None, raw=False, **operation_config): - """Retrieves policy definitions in a subscription. - - This operation retrieves a list of all the policy definitions in a - given subscription. - - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of PolicyDefinition - :rtype: - ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinitionPaged[~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinition] - :raises: :class:`CloudError` + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.PolicyDefinitionListResult"] + """This operation retrieves a list of all the policy definitions in a given subscription. + + Retrieves policy definitions in a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['url'] + url = self.list.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyDefinitionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.PolicyDefinitionPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions'} # type: ignore def list_built_in( - self, custom_headers=None, raw=False, **operation_config): - """Retrieve built-in policy definitions. - - This operation retrieves a list of all the built-in policy definitions. - - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of PolicyDefinition - :rtype: - ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinitionPaged[~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinition] - :raises: :class:`CloudError` + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.PolicyDefinitionListResult"] + """This operation retrieves a list of all the built-in policy definitions. + + Retrieve 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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_built_in.metadata['url'] - + url = self.list_built_in.metadata['url'] # type: ignore # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyDefinitionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.PolicyDefinitionPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policyDefinitions'} + return ItemPaged( + get_next, extract_data + ) + list_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policyDefinitions'} # type: ignore def list_by_management_group( - self, management_group_id, custom_headers=None, raw=False, **operation_config): - """Retrieve policy definitions in a management group. + self, + management_group_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.PolicyDefinitionListResult"] + """This operation retrieves a list of all the policy definitions in a given management group. - This operation retrieves a list of all the policy definitions in a - given management group. + Retrieve policy definitions in a management group. :param management_group_id: The ID of the management group. :type management_group_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of PolicyDefinition - :rtype: - ~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinitionPaged[~azure.mgmt.resource.policy.v2019_06_01.models.PolicyDefinition] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_by_management_group.metadata['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') + 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyDefinitionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.PolicyDefinitionPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_by_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions'} + return ItemPaged( + get_next, extract_data + ) + list_by_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions'} # type: ignore 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 8c8a1e4e898e..d90f3b03f619 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 @@ -1,680 +1,666 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class PolicySetDefinitionsOperations(object): """PolicySetDefinitionsOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.policy.v2019_06_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for the operation. Constant value: "2019-06-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-06-01" - - self.config = config + self._config = config def create_or_update( - self, policy_set_definition_name, parameters, custom_headers=None, raw=False, **operation_config): - """Creates or updates a policy set definition. + self, + policy_set_definition_name, # type: str + parameters, # type: "models.PolicySetDefinition" + **kwargs # type: Any + ): + # type: (...) -> "models.PolicySetDefinition" + """This operation creates or updates a policy set definition in the given subscription with the given name. - This operation creates or updates a policy set definition in the given - subscription with the given name. + Creates or updates a policy set definition. - :param policy_set_definition_name: The name of the policy set - definition to create. + :param policy_set_definition_name: The name of the policy set definition to create. :type policy_set_definition_name: str :param parameters: The policy set definition properties. - :type parameters: - ~azure.mgmt.resource.policy.v2019_06_01.models.PolicySetDefinition - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicySetDefinition or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2019_06_01.models.PolicySetDefinition or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :type parameters: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicySetDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicySetDefinition + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicySetDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + content_type = kwargs.pop("content_type", "application/json") + # Construct URL - url = self.create_or_update.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'PolicySetDefinition') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('PolicySetDefinition', response) + deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('PolicySetDefinition', response) + deserialized = self._deserialize('PolicySetDefinition', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore def delete( - self, policy_set_definition_name, custom_headers=None, raw=False, **operation_config): - """Deletes a policy set definition. + self, + policy_set_definition_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """This operation deletes the policy set definition in the given subscription with the given name. - This operation deletes the policy set definition in the given - subscription with the given name. + Deletes a policy set definition. - :param policy_set_definition_name: The name of the policy set - definition to delete. + :param policy_set_definition_name: The name of the policy set definition to delete. :type policy_set_definition_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + # Construct URL - url = self.delete.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} + delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore def get( - self, policy_set_definition_name, custom_headers=None, raw=False, **operation_config): - """Retrieves a policy set definition. + self, + policy_set_definition_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.PolicySetDefinition" + """This operation retrieves the policy set definition in the given subscription with the given name. - This operation retrieves the policy set definition in the given - subscription with the given name. + Retrieves a policy set definition. - :param policy_set_definition_name: The name of the policy set - definition to get. + :param policy_set_definition_name: The name of the policy set definition to get. :type policy_set_definition_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicySetDefinition or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2019_06_01.models.PolicySetDefinition or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicySetDefinition + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicySetDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + # Construct URL - url = self.get.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('PolicySetDefinition', response) + deserialized = self._deserialize('PolicySetDefinition', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore def get_built_in( - self, policy_set_definition_name, custom_headers=None, raw=False, **operation_config): - """Retrieves a built in policy set definition. + self, + policy_set_definition_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.PolicySetDefinition" + """This operation retrieves the built-in policy set definition with the given name. - This operation retrieves the built-in policy set definition with the - given name. + Retrieves a built in policy set definition. - :param policy_set_definition_name: The name of the policy set - definition to get. + :param policy_set_definition_name: The name of the policy set definition to get. :type policy_set_definition_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicySetDefinition or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2019_06_01.models.PolicySetDefinition or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicySetDefinition + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicySetDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + # Construct URL - url = self.get_built_in.metadata['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') + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('PolicySetDefinition', response) + deserialized = self._deserialize('PolicySetDefinition', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} + get_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore def list( - self, custom_headers=None, raw=False, **operation_config): - """Retrieves the policy set definitions for a subscription. - - This operation retrieves a list of all the policy set definitions in - the given subscription. - - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of PolicySetDefinition - :rtype: - ~azure.mgmt.resource.policy.v2019_06_01.models.PolicySetDefinitionPaged[~azure.mgmt.resource.policy.v2019_06_01.models.PolicySetDefinition] - :raises: - :class:`ErrorResponseException` + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.PolicySetDefinitionListResult"] + """This operation retrieves a list of all the policy set definitions in the given subscription. + + Retrieves 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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['url'] + url = self.list.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('PolicySetDefinitionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) - - return response + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.PolicySetDefinitionPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions'} # type: ignore def list_built_in( - self, custom_headers=None, raw=False, **operation_config): - """Retrieves built-in policy set definitions. - - This operation retrieves a list of all the built-in policy set - definitions. - - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of PolicySetDefinition - :rtype: - ~azure.mgmt.resource.policy.v2019_06_01.models.PolicySetDefinitionPaged[~azure.mgmt.resource.policy.v2019_06_01.models.PolicySetDefinition] - :raises: - :class:`ErrorResponseException` + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.PolicySetDefinitionListResult"] + """This operation retrieves a list of all the built-in policy set definitions. + + Retrieves 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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_built_in.metadata['url'] - + url = self.list_built_in.metadata['url'] # type: ignore # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('PolicySetDefinitionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) - - return response + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.PolicySetDefinitionPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policySetDefinitions'} + return ItemPaged( + get_next, extract_data + ) + list_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policySetDefinitions'} # type: ignore def create_or_update_at_management_group( - self, policy_set_definition_name, parameters, management_group_id, custom_headers=None, raw=False, **operation_config): - """Creates or updates a policy set definition. - - This operation creates or updates a policy set definition in the given - management group with the given name. - - :param policy_set_definition_name: The name of the policy set - definition to create. + self, + policy_set_definition_name, # type: str + management_group_id, # type: str + parameters, # type: "models.PolicySetDefinition" + **kwargs # type: Any + ): + # type: (...) -> "models.PolicySetDefinition" + """This operation creates or updates a policy set definition in the given management group with the given name. + + Creates or updates a policy set definition. + + :param policy_set_definition_name: The name of the policy set definition to create. :type policy_set_definition_name: str - :param parameters: The policy set definition properties. - :type parameters: - ~azure.mgmt.resource.policy.v2019_06_01.models.PolicySetDefinition :param management_group_id: The ID of the management group. :type management_group_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicySetDefinition or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2019_06_01.models.PolicySetDefinition or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :param parameters: The policy set definition properties. + :type parameters: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicySetDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicySetDefinition + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicySetDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + content_type = kwargs.pop("content_type", "application/json") + # Construct URL - url = self.create_or_update_at_management_group.metadata['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') + 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'PolicySetDefinition') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('PolicySetDefinition', response) + deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('PolicySetDefinition', response) + deserialized = self._deserialize('PolicySetDefinition', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + 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}'} + create_or_update_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore def delete_at_management_group( - self, policy_set_definition_name, management_group_id, custom_headers=None, raw=False, **operation_config): - """Deletes a policy set definition. + self, + policy_set_definition_name, # type: str + management_group_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """This operation deletes the policy set definition in the given management group with the given name. - This operation deletes the policy set definition in the given - management group with the given name. + Deletes a policy set definition. - :param policy_set_definition_name: The name of the policy set - definition to delete. + :param policy_set_definition_name: The name of the policy set definition to delete. :type policy_set_definition_name: str :param management_group_id: The ID of the management group. :type management_group_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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'] + 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') + 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} + delete_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore def get_at_management_group( - self, policy_set_definition_name, management_group_id, custom_headers=None, raw=False, **operation_config): - """Retrieves a policy set definition. + self, + policy_set_definition_name, # type: str + management_group_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.PolicySetDefinition" + """This operation retrieves the policy set definition in the given management group with the given name. - This operation retrieves the policy set definition in the given - management group with the given name. + Retrieves a policy set definition. - :param policy_set_definition_name: The name of the policy set - definition to get. + :param policy_set_definition_name: The name of the policy set definition to get. :type policy_set_definition_name: str :param management_group_id: The ID of the management group. :type management_group_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicySetDefinition or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2019_06_01.models.PolicySetDefinition or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_06_01.models.PolicySetDefinition + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicySetDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + # Construct URL - url = self.get_at_management_group.metadata['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') + 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('PolicySetDefinition', response) + deserialized = self._deserialize('PolicySetDefinition', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} + get_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore def list_by_management_group( - self, management_group_id, custom_headers=None, raw=False, **operation_config): - """Retrieves all policy set definitions in management group. + self, + management_group_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.PolicySetDefinitionListResult"] + """This operation retrieves a list of all the a policy set definition in the given management group. - This operation retrieves a list of all the a policy set definition in - the given management group. + Retrieves all policy set definitions in management group. :param management_group_id: The ID of the management group. :type management_group_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of PolicySetDefinition - :rtype: - ~azure.mgmt.resource.policy.v2019_06_01.models.PolicySetDefinitionPaged[~azure.mgmt.resource.policy.v2019_06_01.models.PolicySetDefinition] - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_by_management_group.metadata['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') + 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('PolicySetDefinitionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) - - return response + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.PolicySetDefinitionPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list_by_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions'} + return ItemPaged( + get_next, extract_data + ) + list_by_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/py.typed b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file 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 deleted file mode 100644 index 4174449873ab..000000000000 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_06_01/version.py +++ /dev/null @@ -1,13 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -VERSION = "2019-06-01" - 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 56bf47bfb9e4..e4bba9352a5c 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 @@ -1,19 +1,16 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._configuration import PolicyClientConfiguration from ._policy_client import PolicyClient -__all__ = ['PolicyClient', 'PolicyClientConfiguration'] - -from .version import VERSION - -__version__ = VERSION +__all__ = ['PolicyClient'] +try: + from ._patch import patch_sdk + patch_sdk() +except ImportError: + pass 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 ede4f42045d0..0d567e5a495f 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 @@ -1,48 +1,69 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrestazure import AzureConfiguration -from .version import VERSION +from typing import TYPE_CHECKING +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + + from azure.core.credentials import TokenCredential + +VERSION = "unknown" + +class PolicyClientConfiguration(Configuration): + """Configuration for PolicyClient. -class PolicyClientConfiguration(AzureConfiguration): - """Configuration for PolicyClient Note that all parameters used to create this instance are saved as instance attributes. - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` + :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 """ def __init__( - self, credentials, subscription_id, base_url=None): - - if credentials is None: - raise ValueError("Parameter 'credentials' must not be None.") + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + 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.") - if not base_url: - base_url = 'https://management.azure.com' + super(PolicyClientConfiguration, self).__init__(**kwargs) - super(PolicyClientConfiguration, self).__init__(base_url) - - # Starting Autorest.Python 4.0.64, make connection pool activated by default - self.keep_alive = True - - self.add_user_agent('azure-mgmt-resource/{}'.format(VERSION)) - self.add_user_agent('Azure-SDK-For-Python') - - self.credentials = credentials + self.credential = credential self.subscription_id = subscription_id + self.api_version = "2019-09-01" + self.credential_scopes = ['https://management.azure.com/.default'] + self.credential_scopes.extend(kwargs.pop('credential_scopes', [])) + kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + 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) 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 new file mode 100644 index 000000000000..0279b9a3d2e3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/_metadata.json @@ -0,0 +1,55 @@ +{ + "chosen_version": "2019-09-01", + "total_api_version_list": ["2019-09-01"], + "client": { + "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." + }, + "global_parameters": { + "sync_method": { + "credential": { + "method_signature": "credential, # type: \"TokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials.TokenCredential", + "required": true + }, + "subscription_id": { + "method_signature": "subscription_id, # type: str", + "description": "The ID of the target subscription.", + "docstring_type": "str", + "required": true + } + }, + "async_method": { + "credential": { + "method_signature": "credential, # type: \"AsyncTokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + }, + "subscription_id": { + "method_signature": "subscription_id, # type: str", + "description": "The ID of the target subscription.", + "docstring_type": "str", + "required": true + } + }, + "constant": { + }, + "call": "credential, subscription_id" + }, + "config": { + "credential": true, + "credential_scopes": ["https://management.azure.com/.default"] + }, + "operation_groups": { + "policy_assignments": "PolicyAssignmentsOperations", + "policy_definitions": "PolicyDefinitionsOperations", + "policy_set_definitions": "PolicySetDefinitionsOperations" + }, + "operation_mixins": { + }, + "sync_imports": "None", + "async_imports": "None" +} \ 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 b232c927bb8a..7f1777315ab8 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 @@ -1,16 +1,19 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.service_client import SDKClient -from msrest import Serializer, Deserializer +from typing import TYPE_CHECKING + +from azure.mgmt.core import ARMPipelineClient +from msrest import Deserializer, Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional from ._configuration import PolicyClientConfiguration from .operations import PolicyAssignmentsOperations @@ -19,41 +22,56 @@ from . import models -class PolicyClient(SDKClient): +class PolicyClient(object): """To manage and control access to your resources, you can define customized policies and assign them at a scope. - :ivar config: Configuration for client. - :vartype config: PolicyClientConfiguration - - :ivar policy_assignments: PolicyAssignments operations + :ivar policy_assignments: PolicyAssignmentsOperations operations :vartype policy_assignments: azure.mgmt.resource.policy.v2019_09_01.operations.PolicyAssignmentsOperations - :ivar policy_definitions: PolicyDefinitions operations + :ivar policy_definitions: PolicyDefinitionsOperations operations :vartype policy_definitions: azure.mgmt.resource.policy.v2019_09_01.operations.PolicyDefinitionsOperations - :ivar policy_set_definitions: PolicySetDefinitions operations + :ivar policy_set_definitions: PolicySetDefinitionsOperations operations :vartype policy_set_definitions: azure.mgmt.resource.policy.v2019_09_01.operations.PolicySetDefinitionsOperations - - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` + :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. """ def __init__( - self, credentials, subscription_id, base_url=None): - - self.config = PolicyClientConfiguration(credentials, subscription_id, base_url) - super(PolicyClient, self).__init__(self.config.credentials, self.config) + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = 'https://management.azure.com' + self._config = PolicyClientConfiguration(credential, 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.api_version = '2019-09-01' self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self.policy_assignments = PolicyAssignmentsOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.policy_definitions = PolicyDefinitionsOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.policy_set_definitions = PolicySetDefinitionsOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> PolicyClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) 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 new file mode 100644 index 000000000000..df3c0beab48a --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/aio/__init__.py @@ -0,0 +1,10 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._policy_client_async import PolicyClient +__all__ = ['PolicyClient'] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/aio/_configuration_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/aio/_configuration_async.py new file mode 100644 index 000000000000..759166e2cb2c --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/aio/_configuration_async.py @@ -0,0 +1,65 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + +VERSION = "unknown" + +class PolicyClientConfiguration(Configuration): + """Configuration for PolicyClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :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 + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + 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 + self.api_version = "2019-09-01" + self.credential_scopes = ['https://management.azure.com/.default'] + self.credential_scopes.extend(kwargs.pop('credential_scopes', [])) + kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs: Any + ) -> None: + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + 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) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/aio/_policy_client_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/aio/_policy_client_async.py new file mode 100644 index 000000000000..a35595ed845b --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/aio/_policy_client_async.py @@ -0,0 +1,69 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, Optional + +from azure.mgmt.core import AsyncARMPipelineClient +from msrest import Deserializer, Serializer + +from ._configuration_async import PolicyClientConfiguration +from .operations_async import PolicyAssignmentsOperations +from .operations_async import PolicyDefinitionsOperations +from .operations_async import PolicySetDefinitionsOperations +from .. import models + + +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.aio.operations_async.PolicyAssignmentsOperations + :ivar policy_definitions: PolicyDefinitionsOperations operations + :vartype policy_definitions: azure.mgmt.resource.policy.v2019_09_01.aio.operations_async.PolicyDefinitionsOperations + :ivar policy_set_definitions: PolicySetDefinitionsOperations operations + :vartype policy_set_definitions: azure.mgmt.resource.policy.v2019_09_01.aio.operations_async.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 + :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, + **kwargs: 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) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + + self.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 close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "PolicyClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/aio/operations_async/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/aio/operations_async/__init__.py new file mode 100644 index 000000000000..6a33a6888921 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/aio/operations_async/__init__.py @@ -0,0 +1,17 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._policy_assignments_operations_async import PolicyAssignmentsOperations +from ._policy_definitions_operations_async import PolicyDefinitionsOperations +from ._policy_set_definitions_operations_async import PolicySetDefinitionsOperations + +__all__ = [ + 'PolicyAssignmentsOperations', + 'PolicyDefinitionsOperations', + 'PolicySetDefinitionsOperations', +] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/aio/operations_async/_policy_assignments_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/aio/operations_async/_policy_assignments_operations_async.py new file mode 100644 index 000000000000..49c8cd97e84b --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/aio/operations_async/_policy_assignments_operations_async.py @@ -0,0 +1,722 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import 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 ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class PolicyAssignmentsOperations: + """PolicyAssignmentsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.policy.v2019_09_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def delete( + self, + scope: str, + policy_assignment_name: str, + **kwargs + ) -> "models.PolicyAssignment": + """This operation deletes a policy assignment, given its name and the scope it was created in. The scope of a policy assignment is the part of its ID preceding '/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + + Deletes a policy assignment. + + :param scope: The scope of the policy assignment. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + :type scope: str + :param policy_assignment_name: The name of the policy assignment to delete. + :type policy_assignment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignment or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-09-01" + + # 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'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('PolicyAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore + + async def create( + self, + scope: str, + policy_assignment_name: str, + parameters: "models.PolicyAssignment", + **kwargs + ) -> "models.PolicyAssignment": + """This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + + Creates or updates a policy assignment. + + :param scope: The scope of the policy assignment. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + :type scope: str + :param policy_assignment_name: The name of the policy assignment. + :type policy_assignment_name: str + :param parameters: Parameters for the policy assignment. + :type parameters: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignment + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-09-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore + + async def get( + self, + scope: str, + policy_assignment_name: str, + **kwargs + ) -> "models.PolicyAssignment": + """This operation retrieves a single policy assignment, given its name and the scope it was created at. + + Retrieves a policy assignment. + + :param scope: The scope of the policy assignment. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + :type scope: str + :param policy_assignment_name: The name of the policy assignment to get. + :type policy_assignment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-09-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore + + def list_for_resource_group( + self, + resource_group_name: str, + filter: Optional[str] = None, + **kwargs + ) -> AsyncIterable["models.PolicyAssignmentListResult"]: + """This operation retrieves the list of all policy assignments associated with the given resource group in the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource group, including those that apply directly or apply from containing scopes, as well as any applied to resources contained within the resource group. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource group, which is everything in the unfiltered list except those applied to resources contained within the resource group. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource group. + + Retrieves all policy assignments that apply to a resource group. + + :param resource_group_name: The name of the resource group that contains policy assignments. + :type resource_group_name: str + :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()' + 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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-09-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, 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 + + def list_for_resource( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + filter: Optional[str] = None, + **kwargs + ) -> AsyncIterable["models.PolicyAssignmentListResult"]: + """This operation retrieves the list of all policy assignments associated with the specified resource in the given resource group and subscription that match the optional given $filter. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource, including those that apply directly or from all containing scopes, as well as any applied to resources contained within the resource. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource, which is everything in the unfiltered list except those applied to resources contained within the resource. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource. Three parameters plus the resource name are used to identify a specific resource. If the resource is not part of a parent resource (the more common case), the parent resource path should not be provided (or provided as ''). For example a web app could be specified as ({resourceProviderNamespace} == 'Microsoft.Web', {parentResourcePath} == '', {resourceType} == 'sites', {resourceName} == 'MyWebApp'). If the resource is part of a parent resource, then all parameters should be provided. For example a virtual machine DNS name could be specified as ({resourceProviderNamespace} == 'Microsoft.Compute', {parentResourcePath} == 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames', {resourceName} == 'MyComputerName'). A convenient alternative to providing the namespace and type name separately is to provide both in the {resourceType} parameter, format: ({resourceProviderNamespace} == '', {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). + + Retrieves all policy assignments that apply to a resource. + + :param resource_group_name: The name of the resource group containing the resource. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. For example, the + namespace of a virtual machine is Microsoft.Compute (from Microsoft.Compute/virtualMachines). + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource path. Use empty string if there is none. + :type parent_resource_path: str + :param resource_type: The resource type name. For example the type name of a web app is 'sites' + (from Microsoft.Web/sites). + :type resource_type: str + :param resource_name: The name of the resource. + :type resource_name: str + :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()' + 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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-09-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, 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 + + def list_for_management_group( + self, + management_group_id: str, + filter: str, + **kwargs + ) -> AsyncIterable["models.PolicyAssignmentListResult"]: + """This operation retrieves the list of all policy assignments applicable to the management group that match the given $filter. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter=atScope() is provided, the returned list includes all policy assignments that are assigned to the management group or the management group's ancestors. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the management group. + + Retrieves all policy assignments that apply to a management group. + + :param management_group_id: The ID of the management group. + :type management_group_id: str + :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()' + or 'policyDefinitionId eq '{value}''. A filter is required when listing policy assignments at + 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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-09-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + 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 + + def list( + self, + filter: Optional[str] = None, + **kwargs + ) -> AsyncIterable["models.PolicyAssignmentListResult"]: + """This operation retrieves the list of all policy assignments associated with the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the subscription, including those that apply directly or from management groups that contain the given subscription, as well as any applied to objects contained within the subscription. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the subscription, which is everything in the unfiltered list except those applied to objects contained within the subscription. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value}. + + Retrieves all policy assignments that apply to a subscription. + + :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()' + 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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-09-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments'} # type: ignore + + async def delete_by_id( + self, + policy_assignment_id: str, + **kwargs + ) -> "models.PolicyAssignment": + """This operation deletes the policy with the given ID. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid formats for {scope} are: '/providers/Microsoft.Management/managementGroups/{managementGroup}' (management group), '/subscriptions/{subscriptionId}' (subscription), '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' (resource group), or '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' (resource). + + Deletes a policy assignment. + + :param policy_assignment_id: The ID of the policy assignment to delete. Use the format + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + :type policy_assignment_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignment or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-09-01" + + # 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'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('PolicyAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + delete_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + + async def create_by_id( + self, + policy_assignment_id: str, + parameters: "models.PolicyAssignment", + **kwargs + ) -> "models.PolicyAssignment": + """This operation creates or updates the policy assignment with the given ID. Policy assignments made on a scope apply to all resources contained in that scope. For example, when you assign a policy to a resource group that policy applies to all resources in the group. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + + Creates or updates a policy assignment. + + :param policy_assignment_id: The ID of the policy assignment to create. Use the format + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + :type policy_assignment_id: str + :param parameters: Parameters for policy assignment. + :type parameters: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignment + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-09-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore + + async def get_by_id( + self, + policy_assignment_id: str, + **kwargs + ) -> "models.PolicyAssignment": + """The operation retrieves the policy assignment with the given ID. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + + Retrieves the policy assignment with the given ID. + + :param policy_assignment_id: The ID of the policy assignment to get. Use the format + '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + :type policy_assignment_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-09-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyAssignment', pipeline_response) + + if cls: + 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_async/_policy_definitions_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/aio/operations_async/_policy_definitions_operations_async.py new file mode 100644 index 000000000000..80a6e43ea945 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/aio/operations_async/_policy_definitions_operations_async.py @@ -0,0 +1,632 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import 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 ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class PolicyDefinitionsOperations: + """PolicyDefinitionsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.policy.v2019_09_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def create_or_update( + self, + policy_definition_name: str, + parameters: "models.PolicyDefinition", + **kwargs + ) -> "models.PolicyDefinition": + """This operation creates or updates a policy definition in the given subscription with the given name. + + Creates or updates a policy definition in a subscription. + + :param policy_definition_name: The name of the policy definition to create. + :type policy_definition_name: str + :param parameters: The policy definition properties. + :type parameters: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-09-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + async def delete( + self, + policy_definition_name: str, + **kwargs + ) -> None: + """This operation deletes the policy definition in the given subscription with the given name. + + Deletes a policy definition in a subscription. + + :param policy_definition_name: The name of the policy definition to delete. + :type policy_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-09-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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + async def get( + self, + policy_definition_name: str, + **kwargs + ) -> "models.PolicyDefinition": + """This operation retrieves the policy definition in the given subscription with the given name. + + Retrieves a policy definition in a subscription. + + :param policy_definition_name: The name of the policy definition to get. + :type policy_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-09-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + async def get_built_in( + self, + policy_definition_name: str, + **kwargs + ) -> "models.PolicyDefinition": + """This operation retrieves the built-in policy definition with the given name. + + Retrieves a built-in policy definition. + + :param policy_definition_name: The name of the built-in policy definition to get. + :type policy_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-09-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + async def create_or_update_at_management_group( + self, + policy_definition_name: str, + management_group_id: str, + parameters: "models.PolicyDefinition", + **kwargs + ) -> "models.PolicyDefinition": + """This operation creates or updates a policy definition in the given management group with the given name. + + Creates or updates a policy definition in a management group. + + :param policy_definition_name: The name of the policy definition to create. + :type policy_definition_name: str + :param management_group_id: The ID of the management group. + :type management_group_id: str + :param parameters: The policy definition properties. + :type parameters: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-09-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyDefinition', pipeline_response) + + if cls: + 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 + + async def delete_at_management_group( + self, + policy_definition_name: str, + management_group_id: str, + **kwargs + ) -> None: + """This operation deletes the policy definition in the given management group with the given name. + + Deletes a policy definition in a management group. + + :param policy_definition_name: The name of the policy definition to delete. + :type policy_definition_name: str + :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: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-09-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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore + + async def get_at_management_group( + self, + policy_definition_name: str, + management_group_id: str, + **kwargs + ) -> "models.PolicyDefinition": + """This operation retrieves the policy definition in the given management group with the given name. + + Retrieve a policy definition in a management group. + + :param policy_definition_name: The name of the policy definition to get. + :type policy_definition_name: str + :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: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-09-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyDefinition', pipeline_response) + + if cls: + 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 + + def list( + self, + **kwargs + ) -> AsyncIterable["models.PolicyDefinitionListResult"]: + """This operation retrieves a list of all the policy definitions in a given subscription. + + Retrieves policy definitions in a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-09-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyDefinitionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions'} # type: ignore + + def list_built_in( + self, + **kwargs + ) -> AsyncIterable["models.PolicyDefinitionListResult"]: + """This operation retrieves a list of all the built-in policy definitions. + + Retrieve 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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-09-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyDefinitionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policyDefinitions'} # type: ignore + + def list_by_management_group( + self, + management_group_id: str, + **kwargs + ) -> AsyncIterable["models.PolicyDefinitionListResult"]: + """This operation retrieves a list of all the policy definitions in a given management group. + + Retrieve policy definitions in a 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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-09-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyDefinitionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/aio/operations_async/_policy_set_definitions_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/aio/operations_async/_policy_set_definitions_operations_async.py new file mode 100644 index 000000000000..04d6c5d594ad --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/aio/operations_async/_policy_set_definitions_operations_async.py @@ -0,0 +1,642 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import 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 ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class PolicySetDefinitionsOperations: + """PolicySetDefinitionsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.policy.v2019_09_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def create_or_update( + self, + policy_set_definition_name: str, + parameters: "models.PolicySetDefinition", + **kwargs + ) -> "models.PolicySetDefinition": + """This operation creates or updates a policy set definition in the given subscription with the given name. + + Creates or updates a policy set definition. + + :param policy_set_definition_name: The name of the policy set definition to create. + :type policy_set_definition_name: str + :param parameters: The policy set definition properties. + :type parameters: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicySetDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-09-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + async def delete( + self, + policy_set_definition_name: str, + **kwargs + ) -> None: + """This operation deletes the policy set definition in the given subscription with the given name. + + Deletes a policy set definition. + + :param policy_set_definition_name: The name of the policy set definition to delete. + :type policy_set_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-09-01" + + # 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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + async def get( + self, + policy_set_definition_name: str, + **kwargs + ) -> "models.PolicySetDefinition": + """This operation retrieves the policy set definition in the given subscription with the given name. + + Retrieves a policy set definition. + + :param policy_set_definition_name: The name of the policy set definition to get. + :type policy_set_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicySetDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-09-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + async def get_built_in( + self, + policy_set_definition_name: str, + **kwargs + ) -> "models.PolicySetDefinition": + """This operation retrieves the built-in policy set definition with the given name. + + Retrieves a built in policy set definition. + + :param policy_set_definition_name: The name of the policy set definition to get. + :type policy_set_definition_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicySetDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-09-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + def list( + self, + **kwargs + ) -> AsyncIterable["models.PolicySetDefinitionListResult"]: + """This operation retrieves a list of all the policy set definitions in the given subscription. + + Retrieves 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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-09-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('PolicySetDefinitionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions'} # type: ignore + + def list_built_in( + self, + **kwargs + ) -> AsyncIterable["models.PolicySetDefinitionListResult"]: + """This operation retrieves a list of all the built-in policy set definitions. + + Retrieves 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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-09-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('PolicySetDefinitionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policySetDefinitions'} # type: ignore + + async def create_or_update_at_management_group( + self, + policy_set_definition_name: str, + management_group_id: str, + parameters: "models.PolicySetDefinition", + **kwargs + ) -> "models.PolicySetDefinition": + """This operation creates or updates a policy set definition in the given management group with the given name. + + Creates or updates a policy set definition. + + :param policy_set_definition_name: The name of the policy set definition to create. + :type policy_set_definition_name: str + :param management_group_id: The ID of the management group. + :type management_group_id: str + :param parameters: The policy set definition properties. + :type parameters: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicySetDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-09-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + + if cls: + 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 + + async def delete_at_management_group( + self, + policy_set_definition_name: str, + management_group_id: str, + **kwargs + ) -> None: + """This operation deletes the policy set definition in the given management group with the given name. + + Deletes a policy set definition. + + :param policy_set_definition_name: The name of the policy set definition to delete. + :type policy_set_definition_name: str + :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: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-09-01" + + # 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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore + + async def get_at_management_group( + self, + policy_set_definition_name: str, + management_group_id: str, + **kwargs + ) -> "models.PolicySetDefinition": + """This operation retrieves the policy set definition in the given management group with the given name. + + Retrieves a policy set definition. + + :param policy_set_definition_name: The name of the policy set definition to get. + :type policy_set_definition_name: str + :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: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicySetDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-09-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + + if cls: + 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 + + def list_by_management_group( + self, + management_group_id: str, + **kwargs + ) -> AsyncIterable["models.PolicySetDefinitionListResult"]: + """This operation retrieves a list of all the a policy set definition in the given management group. + + Retrieves all policy set definitions in 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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-09-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('PolicySetDefinitionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/models/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/models/__init__.py index 7bb65cbc04ac..80fc2408bbfb 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/models/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/models/__init__.py @@ -1,12 +1,9 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- try: @@ -17,32 +14,36 @@ from ._models_py3 import ParameterDefinitionsValueMetadata from ._models_py3 import ParameterValuesValue from ._models_py3 import PolicyAssignment + from ._models_py3 import PolicyAssignmentListResult from ._models_py3 import PolicyDefinition from ._models_py3 import PolicyDefinitionGroup + from ._models_py3 import PolicyDefinitionListResult from ._models_py3 import PolicyDefinitionReference from ._models_py3 import PolicySetDefinition + from ._models_py3 import PolicySetDefinitionListResult from ._models_py3 import PolicySku except (SyntaxError, ImportError): - from ._models import ErrorAdditionalInfo - from ._models import ErrorResponse - from ._models import Identity - from ._models import ParameterDefinitionsValue - from ._models import ParameterDefinitionsValueMetadata - from ._models import ParameterValuesValue - from ._models import PolicyAssignment - from ._models import PolicyDefinition - from ._models import PolicyDefinitionGroup - from ._models import PolicyDefinitionReference - from ._models import PolicySetDefinition - from ._models import PolicySku -from ._paged_models import PolicyAssignmentPaged -from ._paged_models import PolicyDefinitionPaged -from ._paged_models import PolicySetDefinitionPaged + from ._models import ErrorAdditionalInfo # type: ignore + from ._models import ErrorResponse # type: ignore + from ._models import Identity # type: ignore + from ._models import ParameterDefinitionsValue # type: ignore + from ._models import ParameterDefinitionsValueMetadata # type: ignore + from ._models import ParameterValuesValue # type: ignore + from ._models import PolicyAssignment # type: ignore + from ._models import PolicyAssignmentListResult # type: ignore + from ._models import PolicyDefinition # type: ignore + from ._models import PolicyDefinitionGroup # type: ignore + from ._models import PolicyDefinitionListResult # type: ignore + from ._models import PolicyDefinitionReference # type: ignore + from ._models import PolicySetDefinition # type: ignore + from ._models import PolicySetDefinitionListResult # type: ignore + from ._models import PolicySku # type: ignore + from ._policy_client_enums import ( EnforcementMode, - ResourceIdentityType, - PolicyType, ParameterType, + PolicyType, + ResourceIdentityType, ) __all__ = [ @@ -53,16 +54,16 @@ 'ParameterDefinitionsValueMetadata', 'ParameterValuesValue', 'PolicyAssignment', + 'PolicyAssignmentListResult', 'PolicyDefinition', 'PolicyDefinitionGroup', + 'PolicyDefinitionListResult', 'PolicyDefinitionReference', 'PolicySetDefinition', + 'PolicySetDefinitionListResult', 'PolicySku', - 'PolicyAssignmentPaged', - 'PolicyDefinitionPaged', - 'PolicySetDefinitionPaged', 'EnforcementMode', - 'ResourceIdentityType', - 'PolicyType', 'ParameterType', + 'PolicyType', + 'ResourceIdentityType', ] 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 f88d67578208..a8b2893e8e34 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 @@ -1,51 +1,18 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.serialization import Model -from msrest.exceptions import HttpOperationError +import msrest.serialization -class CloudError(Model): - """An error response from a policy operation. - - :param error: - :type error: ~azure.mgmt.resource.policy.v2019_09_01.models.ErrorResponse - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorResponse'}, - } - - def __init__(self, **kwargs): - super(CloudError, self).__init__(**kwargs) - self.error = kwargs.get('error', None) - - -class CloudErrorException(HttpOperationError): - """Server responsed with exception of type: 'CloudError'. - - :param deserialize: A deserializer - :param response: Server response to be deserialized. - """ - - def __init__(self, deserialize, response, *args): - - super(CloudErrorException, self).__init__(deserialize, response, 'CloudError', *args) - - -class ErrorAdditionalInfo(Model): +class ErrorAdditionalInfo(msrest.serialization.Model): """The resource management error additional info. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar type: The additional info type. :vartype type: str @@ -63,17 +30,19 @@ class ErrorAdditionalInfo(Model): 'info': {'key': 'info', 'type': 'object'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None -class ErrorResponse(Model): +class ErrorResponse(msrest.serialization.Model): """The resource management error response. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar code: The error code. :vartype code: str @@ -82,8 +51,7 @@ class ErrorResponse(Model): :ivar target: The error target. :vartype target: str :ivar details: The error details. - :vartype details: - list[~azure.mgmt.resource.policy.v2019_09_01.models.ErrorResponse] + :vartype details: list[~azure.mgmt.resource.policy.v2019_09_01.models.ErrorResponse] :ivar additional_info: The error additional info. :vartype additional_info: list[~azure.mgmt.resource.policy.v2019_09_01.models.ErrorAdditionalInfo] @@ -105,7 +73,10 @@ class ErrorResponse(Model): 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ErrorResponse, self).__init__(**kwargs) self.code = None self.message = None @@ -114,21 +85,18 @@ def __init__(self, **kwargs): self.additional_info = None -class Identity(Model): +class Identity(msrest.serialization.Model): """Identity for the resource. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar principal_id: The principal ID of the resource identity. :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 identity to a resource. Possible values include: - 'SystemAssigned', 'None' - :type type: str or - ~azure.mgmt.resource.policy.v2019_09_01.models.ResourceIdentityType + :param 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 """ _validation = { @@ -139,27 +107,28 @@ class Identity(Model): _attribute_map = { 'principal_id': {'key': 'principalId', 'type': 'str'}, 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'ResourceIdentityType'}, + 'type': {'key': 'type', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Identity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None self.type = kwargs.get('type', None) -class ParameterDefinitionsValue(Model): +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', 'Object', 'Boolean', 'Integer', 'Float', 'DateTime' - :type type: str or - ~azure.mgmt.resource.policy.v2019_09_01.models.ParameterType + :param 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[object] - :param default_value: The default value for the parameter if no value is - provided. + :param default_value: The default value for the parameter if no value is provided. :type default_value: object :param metadata: General metadata for the parameter. :type metadata: @@ -173,7 +142,10 @@ class ParameterDefinitionsValue(Model): 'metadata': {'key': 'metadata', 'type': 'ParameterDefinitionsValueMetadata'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ParameterDefinitionsValue, self).__init__(**kwargs) self.type = kwargs.get('type', None) self.allowed_values = kwargs.get('allowed_values', None) @@ -181,11 +153,11 @@ def __init__(self, **kwargs): self.metadata = kwargs.get('metadata', None) -class ParameterDefinitionsValueMetadata(Model): +class ParameterDefinitionsValueMetadata(msrest.serialization.Model): """General metadata for the parameter. - :param additional_properties: Unmatched properties from the message are - deserialized this collection + :param additional_properties: Unmatched properties from the message are deserialized to this + collection. :type additional_properties: dict[str, object] :param display_name: The display name for the parameter. :type display_name: str @@ -199,14 +171,17 @@ class ParameterDefinitionsValueMetadata(Model): 'description': {'key': 'description', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ParameterDefinitionsValueMetadata, self).__init__(**kwargs) self.additional_properties = kwargs.get('additional_properties', None) self.display_name = kwargs.get('display_name', None) self.description = kwargs.get('description', None) -class ParameterValuesValue(Model): +class ParameterValuesValue(msrest.serialization.Model): """The value of a parameter. :param value: The value of the parameter. @@ -217,56 +192,53 @@ class ParameterValuesValue(Model): 'value': {'key': 'value', 'type': 'object'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ParameterValuesValue, self).__init__(**kwargs) self.value = kwargs.get('value', None) -class PolicyAssignment(Model): +class PolicyAssignment(msrest.serialization.Model): """The policy assignment. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. + :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 + :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 + 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 assigned. + :param 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. + :param parameters: The parameter values for the assigned policy rule. The keys are the + parameter names. :type 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. + :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 typically a collection of key value pairs. + :param metadata: The policy assignment metadata. Metadata is an open ended object and is + typically a collection of key value pairs. :type metadata: object - :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 - :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 - :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 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 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 """ _validation = { @@ -276,6 +248,12 @@ class PolicyAssignment(Model): } _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'sku': {'key': 'sku', 'type': 'PolicySku'}, + 'location': {'key': 'location', 'type': 'str'}, + 'identity': {'key': 'identity', 'type': 'Identity'}, 'display_name': {'key': 'properties.displayName', 'type': 'str'}, 'policy_definition_id': {'key': 'properties.policyDefinitionId', 'type': 'str'}, 'scope': {'key': 'properties.scope', 'type': 'str'}, @@ -284,16 +262,19 @@ class PolicyAssignment(Model): 'description': {'key': 'properties.description', 'type': 'str'}, 'metadata': {'key': 'properties.metadata', 'type': 'object'}, 'enforcement_mode': {'key': 'properties.enforcementMode', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'PolicySku'}, - 'location': {'key': 'location', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(PolicyAssignment, self).__init__(**kwargs) + self.id = None + self.type = None + self.name = None + self.sku = kwargs.get('sku', None) + self.location = kwargs.get('location', None) + self.identity = kwargs.get('identity', None) self.display_name = kwargs.get('display_name', None) self.policy_definition_id = kwargs.get('policy_definition_id', None) self.scope = kwargs.get('scope', None) @@ -302,25 +283,45 @@ def __init__(self, **kwargs): self.description = kwargs.get('description', None) self.metadata = kwargs.get('metadata', None) self.enforcement_mode = kwargs.get('enforcement_mode', None) - self.id = None - self.type = None - self.name = None - self.sku = kwargs.get('sku', None) - self.location = kwargs.get('location', None) - self.identity = kwargs.get('identity', None) -class PolicyDefinition(Model): +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 + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[PolicyAssignment]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(PolicyAssignmentListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class PolicyDefinition(msrest.serialization.Model): """The policy definition. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :param 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 + :ivar id: The ID of the policy definition. + :vartype id: str + :ivar name: The name of the policy definition. + :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, + 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, Microsoft.KeyVault.Data. :type mode: str @@ -330,20 +331,13 @@ class PolicyDefinition(Model): :type description: str :param policy_rule: The policy rule. :type policy_rule: object - :param metadata: The policy definition metadata. Metadata is an open - ended object and is typically a collection of key value pairs. + :param metadata: The policy definition metadata. Metadata is an open ended object and is + typically a collection of key value pairs. :type metadata: object - :param parameters: The parameter definitions for parameters used in the - policy rule. The keys are the parameter names. + :param parameters: The parameter definitions for parameters used in the policy rule. The keys + are the parameter names. :type parameters: dict[str, ~azure.mgmt.resource.policy.v2019_09_01.models.ParameterDefinitionsValue] - :ivar id: The ID of the policy definition. - :vartype id: str - :ivar name: The name of the policy definition. - :vartype name: str - :ivar type: The type of the resource - (Microsoft.Authorization/policyDefinitions). - :vartype type: str """ _validation = { @@ -353,6 +347,9 @@ class PolicyDefinition(Model): } _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, 'policy_type': {'key': 'properties.policyType', 'type': 'str'}, 'mode': {'key': 'properties.mode', 'type': 'str'}, 'display_name': {'key': 'properties.displayName', 'type': 'str'}, @@ -360,13 +357,16 @@ class PolicyDefinition(Model): 'policy_rule': {'key': 'properties.policyRule', 'type': 'object'}, 'metadata': {'key': 'properties.metadata', 'type': 'object'}, 'parameters': {'key': 'properties.parameters', 'type': '{ParameterDefinitionsValue}'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(PolicyDefinition, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None self.policy_type = kwargs.get('policy_type', None) self.mode = kwargs.get('mode', None) self.display_name = kwargs.get('display_name', None) @@ -374,12 +374,9 @@ def __init__(self, **kwargs): self.policy_rule = kwargs.get('policy_rule', None) self.metadata = kwargs.get('metadata', None) self.parameters = kwargs.get('parameters', None) - self.id = None - self.name = None - self.type = None -class PolicyDefinitionGroup(Model): +class PolicyDefinitionGroup(msrest.serialization.Model): """The policy definition group. All required parameters must be populated in order to send to Azure. @@ -392,8 +389,8 @@ class PolicyDefinitionGroup(Model): :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 about the group. + :param additional_metadata_id: A resource ID of a resource that contains additional metadata + about the group. :type additional_metadata_id: str """ @@ -409,32 +406,57 @@ class PolicyDefinitionGroup(Model): 'additional_metadata_id': {'key': 'additionalMetadataId', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(PolicyDefinitionGroup, self).__init__(**kwargs) - self.name = kwargs.get('name', None) + self.name = kwargs['name'] self.display_name = kwargs.get('display_name', None) self.category = kwargs.get('category', None) self.description = kwargs.get('description', None) self.additional_metadata_id = kwargs.get('additional_metadata_id', None) -class PolicyDefinitionReference(Model): +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 + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[PolicyDefinition]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(PolicyDefinitionListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class PolicyDefinitionReference(msrest.serialization.Model): """The policy definition reference. 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. + :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 parameter names. + :param parameters: The parameter values for the referenced policy rule. The keys are the + parameter names. :type 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 policy definition reference. + :param 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. + :param group_names: The name of the groups that this policy definition reference belongs to. :type group_names: list[str] """ @@ -449,63 +471,61 @@ class PolicyDefinitionReference(Model): 'group_names': {'key': 'groupNames', 'type': '[str]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(PolicyDefinitionReference, self).__init__(**kwargs) - self.policy_definition_id = kwargs.get('policy_definition_id', None) + self.policy_definition_id = kwargs['policy_definition_id'] self.parameters = kwargs.get('parameters', None) self.policy_definition_reference_id = kwargs.get('policy_definition_reference_id', None) self.group_names = kwargs.get('group_names', None) -class PolicySetDefinition(Model): +class PolicySetDefinition(msrest.serialization.Model): """The policy set definition. - Variables are only populated by the server, and will be ignored when - sending a request. - - All required parameters must be populated in order to send to Azure. + Variables are only populated by the server, and will be ignored when sending a request. - :param 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 + :ivar id: The ID of the policy set definition. + :vartype id: str + :ivar name: The name of the policy set definition. + :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, + 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 typically a collection of key value pairs. + :param metadata: The policy set definition metadata. Metadata is an open ended object and is + typically a collection of key value pairs. :type metadata: object - :param parameters: The policy set definition parameters that can be used - in policy definition references. + :param parameters: The policy set definition parameters that can be used in policy definition + references. :type parameters: dict[str, ~azure.mgmt.resource.policy.v2019_09_01.models.ParameterDefinitionsValue] - :param policy_definitions: Required. An array of policy definition - references. + :param policy_definitions: An array of policy definition references. :type policy_definitions: list[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinitionReference] - :param policy_definition_groups: The metadata describing groups of policy - definition references within the policy set definition. + :param policy_definition_groups: The metadata describing groups of policy definition references + within the policy set definition. :type policy_definition_groups: list[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinitionGroup] - :ivar id: The ID of the policy set definition. - :vartype id: str - :ivar name: The name of the policy set definition. - :vartype name: str - :ivar type: The type of the resource - (Microsoft.Authorization/policySetDefinitions). - :vartype type: str """ _validation = { - 'policy_definitions': {'required': True}, 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, } _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, 'policy_type': {'key': 'properties.policyType', 'type': 'str'}, 'display_name': {'key': 'properties.displayName', 'type': 'str'}, 'description': {'key': 'properties.description', 'type': 'str'}, @@ -513,13 +533,16 @@ class PolicySetDefinition(Model): 'parameters': {'key': 'properties.parameters', 'type': '{ParameterDefinitionsValue}'}, 'policy_definitions': {'key': 'properties.policyDefinitions', 'type': '[PolicyDefinitionReference]'}, 'policy_definition_groups': {'key': 'properties.policyDefinitionGroups', 'type': '[PolicyDefinitionGroup]'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(PolicySetDefinition, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None self.policy_type = kwargs.get('policy_type', None) self.display_name = kwargs.get('display_name', None) self.description = kwargs.get('description', None) @@ -527,18 +550,37 @@ def __init__(self, **kwargs): self.parameters = kwargs.get('parameters', None) self.policy_definitions = kwargs.get('policy_definitions', None) self.policy_definition_groups = kwargs.get('policy_definition_groups', None) - self.id = None - self.name = None - self.type = None -class PolicySku(Model): +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 + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[PolicySetDefinition]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(PolicySetDefinitionListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class PolicySku(msrest.serialization.Model): """The policy sku. This property is optional, obsolete, and will be ignored. 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. + :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 @@ -553,7 +595,10 @@ class PolicySku(Model): 'tier': {'key': 'tier', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(PolicySku, self).__init__(**kwargs) - self.name = kwargs.get('name', None) + 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 7a0c0c14935c..9604a1bd73c0 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 @@ -1,51 +1,22 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.serialization import Model -from msrest.exceptions import HttpOperationError +from typing import Dict, List, Optional, Union +import msrest.serialization -class CloudError(Model): - """An error response from a policy operation. +from ._policy_client_enums import * - :param error: - :type error: ~azure.mgmt.resource.policy.v2019_09_01.models.ErrorResponse - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorResponse'}, - } - - def __init__(self, *, error=None, **kwargs) -> None: - super(CloudError, self).__init__(**kwargs) - self.error = error - - -class CloudErrorException(HttpOperationError): - """Server responsed with exception of type: 'CloudError'. - - :param deserialize: A deserializer - :param response: Server response to be deserialized. - """ - def __init__(self, deserialize, response, *args): - - super(CloudErrorException, self).__init__(deserialize, response, 'CloudError', *args) - - -class ErrorAdditionalInfo(Model): +class ErrorAdditionalInfo(msrest.serialization.Model): """The resource management error additional info. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar type: The additional info type. :vartype type: str @@ -63,17 +34,19 @@ class ErrorAdditionalInfo(Model): 'info': {'key': 'info', 'type': 'object'}, } - def __init__(self, **kwargs) -> None: + def __init__( + self, + **kwargs + ): super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None -class ErrorResponse(Model): +class ErrorResponse(msrest.serialization.Model): """The resource management error response. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar code: The error code. :vartype code: str @@ -82,8 +55,7 @@ class ErrorResponse(Model): :ivar target: The error target. :vartype target: str :ivar details: The error details. - :vartype details: - list[~azure.mgmt.resource.policy.v2019_09_01.models.ErrorResponse] + :vartype details: list[~azure.mgmt.resource.policy.v2019_09_01.models.ErrorResponse] :ivar additional_info: The error additional info. :vartype additional_info: list[~azure.mgmt.resource.policy.v2019_09_01.models.ErrorAdditionalInfo] @@ -105,7 +77,10 @@ class ErrorResponse(Model): 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, } - def __init__(self, **kwargs) -> None: + def __init__( + self, + **kwargs + ): super(ErrorResponse, self).__init__(**kwargs) self.code = None self.message = None @@ -114,21 +89,18 @@ def __init__(self, **kwargs) -> None: self.additional_info = None -class Identity(Model): +class Identity(msrest.serialization.Model): """Identity for the resource. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar principal_id: The principal ID of the resource identity. :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 identity to a resource. Possible values include: - 'SystemAssigned', 'None' - :type type: str or - ~azure.mgmt.resource.policy.v2019_09_01.models.ResourceIdentityType + :param 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 """ _validation = { @@ -139,27 +111,30 @@ class Identity(Model): _attribute_map = { 'principal_id': {'key': 'principalId', 'type': 'str'}, 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'ResourceIdentityType'}, + 'type': {'key': 'type', 'type': 'str'}, } - def __init__(self, *, type=None, **kwargs) -> None: + def __init__( + self, + *, + type: Optional[Union[str, "ResourceIdentityType"]] = None, + **kwargs + ): super(Identity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None self.type = type -class ParameterDefinitionsValue(Model): +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', 'Object', 'Boolean', 'Integer', 'Float', 'DateTime' - :type type: str or - ~azure.mgmt.resource.policy.v2019_09_01.models.ParameterType + :param 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[object] - :param default_value: The default value for the parameter if no value is - provided. + :param default_value: The default value for the parameter if no value is provided. :type default_value: object :param metadata: General metadata for the parameter. :type metadata: @@ -173,7 +148,15 @@ class ParameterDefinitionsValue(Model): 'metadata': {'key': 'metadata', 'type': 'ParameterDefinitionsValueMetadata'}, } - def __init__(self, *, type=None, allowed_values=None, default_value=None, metadata=None, **kwargs) -> None: + def __init__( + self, + *, + type: Optional[Union[str, "ParameterType"]] = None, + allowed_values: Optional[List[object]] = None, + default_value: Optional[object] = None, + metadata: Optional["ParameterDefinitionsValueMetadata"] = None, + **kwargs + ): super(ParameterDefinitionsValue, self).__init__(**kwargs) self.type = type self.allowed_values = allowed_values @@ -181,11 +164,11 @@ def __init__(self, *, type=None, allowed_values=None, default_value=None, metada self.metadata = metadata -class ParameterDefinitionsValueMetadata(Model): +class ParameterDefinitionsValueMetadata(msrest.serialization.Model): """General metadata for the parameter. - :param additional_properties: Unmatched properties from the message are - deserialized this collection + :param additional_properties: Unmatched properties from the message are deserialized to this + collection. :type additional_properties: dict[str, object] :param display_name: The display name for the parameter. :type display_name: str @@ -199,14 +182,21 @@ class ParameterDefinitionsValueMetadata(Model): 'description': {'key': 'description', 'type': 'str'}, } - def __init__(self, *, additional_properties=None, display_name: str=None, description: str=None, **kwargs) -> None: + def __init__( + self, + *, + additional_properties: Optional[Dict[str, object]] = None, + display_name: Optional[str] = None, + description: Optional[str] = None, + **kwargs + ): super(ParameterDefinitionsValueMetadata, self).__init__(**kwargs) self.additional_properties = additional_properties self.display_name = display_name self.description = description -class ParameterValuesValue(Model): +class ParameterValuesValue(msrest.serialization.Model): """The value of a parameter. :param value: The value of the parameter. @@ -217,56 +207,55 @@ class ParameterValuesValue(Model): 'value': {'key': 'value', 'type': 'object'}, } - def __init__(self, *, value=None, **kwargs) -> None: + def __init__( + self, + *, + value: Optional[object] = None, + **kwargs + ): super(ParameterValuesValue, self).__init__(**kwargs) self.value = value -class PolicyAssignment(Model): +class PolicyAssignment(msrest.serialization.Model): """The policy assignment. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. + :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 + :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 + 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 assigned. + :param 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. + :param parameters: The parameter values for the assigned policy rule. The keys are the + parameter names. :type 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. + :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 typically a collection of key value pairs. + :param metadata: The policy assignment metadata. Metadata is an open ended object and is + typically a collection of key value pairs. :type metadata: object - :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 - :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 - :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 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 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 """ _validation = { @@ -276,6 +265,12 @@ class PolicyAssignment(Model): } _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'sku': {'key': 'sku', 'type': 'PolicySku'}, + 'location': {'key': 'location', 'type': 'str'}, + 'identity': {'key': 'identity', 'type': 'Identity'}, 'display_name': {'key': 'properties.displayName', 'type': 'str'}, 'policy_definition_id': {'key': 'properties.policyDefinitionId', 'type': 'str'}, 'scope': {'key': 'properties.scope', 'type': 'str'}, @@ -284,16 +279,31 @@ class PolicyAssignment(Model): 'description': {'key': 'properties.description', 'type': 'str'}, 'metadata': {'key': 'properties.metadata', 'type': 'object'}, 'enforcement_mode': {'key': 'properties.enforcementMode', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'PolicySku'}, - 'location': {'key': 'location', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, } - def __init__(self, *, display_name: str=None, policy_definition_id: str=None, scope: str=None, not_scopes=None, parameters=None, description: str=None, metadata=None, enforcement_mode=None, sku=None, location: str=None, identity=None, **kwargs) -> None: + def __init__( + self, + *, + sku: Optional["PolicySku"] = None, + location: Optional[str] = None, + identity: Optional["Identity"] = None, + display_name: Optional[str] = None, + policy_definition_id: Optional[str] = None, + scope: Optional[str] = None, + not_scopes: Optional[List[str]] = None, + parameters: Optional[Dict[str, "ParameterValuesValue"]] = None, + description: Optional[str] = None, + metadata: Optional[object] = None, + enforcement_mode: Optional[Union[str, "EnforcementMode"]] = None, + **kwargs + ): super(PolicyAssignment, self).__init__(**kwargs) + self.id = None + self.type = None + self.name = None + self.sku = sku + self.location = location + self.identity = identity self.display_name = display_name self.policy_definition_id = policy_definition_id self.scope = scope @@ -302,25 +312,48 @@ def __init__(self, *, display_name: str=None, policy_definition_id: str=None, sc self.description = description self.metadata = metadata self.enforcement_mode = enforcement_mode - self.id = None - self.type = None - self.name = None - self.sku = sku - self.location = location - self.identity = identity -class PolicyDefinition(Model): +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 + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[PolicyAssignment]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["PolicyAssignment"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(PolicyAssignmentListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class PolicyDefinition(msrest.serialization.Model): """The policy definition. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :param 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 + :ivar id: The ID of the policy definition. + :vartype id: str + :ivar name: The name of the policy definition. + :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, + 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, Microsoft.KeyVault.Data. :type mode: str @@ -330,20 +363,13 @@ class PolicyDefinition(Model): :type description: str :param policy_rule: The policy rule. :type policy_rule: object - :param metadata: The policy definition metadata. Metadata is an open - ended object and is typically a collection of key value pairs. + :param metadata: The policy definition metadata. Metadata is an open ended object and is + typically a collection of key value pairs. :type metadata: object - :param parameters: The parameter definitions for parameters used in the - policy rule. The keys are the parameter names. + :param parameters: The parameter definitions for parameters used in the policy rule. The keys + are the parameter names. :type parameters: dict[str, ~azure.mgmt.resource.policy.v2019_09_01.models.ParameterDefinitionsValue] - :ivar id: The ID of the policy definition. - :vartype id: str - :ivar name: The name of the policy definition. - :vartype name: str - :ivar type: The type of the resource - (Microsoft.Authorization/policyDefinitions). - :vartype type: str """ _validation = { @@ -353,6 +379,9 @@ class PolicyDefinition(Model): } _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, 'policy_type': {'key': 'properties.policyType', 'type': 'str'}, 'mode': {'key': 'properties.mode', 'type': 'str'}, 'display_name': {'key': 'properties.displayName', 'type': 'str'}, @@ -360,13 +389,24 @@ class PolicyDefinition(Model): 'policy_rule': {'key': 'properties.policyRule', 'type': 'object'}, 'metadata': {'key': 'properties.metadata', 'type': 'object'}, 'parameters': {'key': 'properties.parameters', 'type': '{ParameterDefinitionsValue}'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, } - def __init__(self, *, policy_type=None, mode: str=None, display_name: str=None, description: str=None, policy_rule=None, metadata=None, parameters=None, **kwargs) -> None: + def __init__( + self, + *, + policy_type: Optional[Union[str, "PolicyType"]] = None, + mode: Optional[str] = None, + display_name: Optional[str] = None, + description: Optional[str] = None, + policy_rule: Optional[object] = None, + metadata: Optional[object] = None, + parameters: Optional[Dict[str, "ParameterDefinitionsValue"]] = None, + **kwargs + ): super(PolicyDefinition, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None self.policy_type = policy_type self.mode = mode self.display_name = display_name @@ -374,12 +414,9 @@ def __init__(self, *, policy_type=None, mode: str=None, display_name: str=None, self.policy_rule = policy_rule self.metadata = metadata self.parameters = parameters - self.id = None - self.name = None - self.type = None -class PolicyDefinitionGroup(Model): +class PolicyDefinitionGroup(msrest.serialization.Model): """The policy definition group. All required parameters must be populated in order to send to Azure. @@ -392,8 +429,8 @@ class PolicyDefinitionGroup(Model): :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 about the group. + :param additional_metadata_id: A resource ID of a resource that contains additional metadata + about the group. :type additional_metadata_id: str """ @@ -409,7 +446,16 @@ class PolicyDefinitionGroup(Model): 'additional_metadata_id': {'key': 'additionalMetadataId', 'type': 'str'}, } - def __init__(self, *, name: str, display_name: str=None, category: str=None, description: str=None, additional_metadata_id: str=None, **kwargs) -> None: + def __init__( + self, + *, + name: str, + display_name: Optional[str] = None, + category: Optional[str] = None, + description: Optional[str] = None, + additional_metadata_id: Optional[str] = None, + **kwargs + ): super(PolicyDefinitionGroup, self).__init__(**kwargs) self.name = name self.display_name = display_name @@ -418,23 +464,48 @@ def __init__(self, *, name: str, display_name: str=None, category: str=None, des self.additional_metadata_id = additional_metadata_id -class PolicyDefinitionReference(Model): +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 + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[PolicyDefinition]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["PolicyDefinition"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(PolicyDefinitionListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class PolicyDefinitionReference(msrest.serialization.Model): """The policy definition reference. 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. + :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 parameter names. + :param parameters: The parameter values for the referenced policy rule. The keys are the + parameter names. :type 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 policy definition reference. + :param 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. + :param group_names: The name of the groups that this policy definition reference belongs to. :type group_names: list[str] """ @@ -449,7 +520,15 @@ class PolicyDefinitionReference(Model): 'group_names': {'key': 'groupNames', 'type': '[str]'}, } - def __init__(self, *, policy_definition_id: str, parameters=None, policy_definition_reference_id: str=None, group_names=None, **kwargs) -> None: + def __init__( + self, + *, + policy_definition_id: str, + parameters: Optional[Dict[str, "ParameterValuesValue"]] = None, + policy_definition_reference_id: Optional[str] = None, + group_names: Optional[List[str]] = None, + **kwargs + ): super(PolicyDefinitionReference, self).__init__(**kwargs) self.policy_definition_id = policy_definition_id self.parameters = parameters @@ -457,55 +536,50 @@ def __init__(self, *, policy_definition_id: str, parameters=None, policy_definit self.group_names = group_names -class PolicySetDefinition(Model): +class PolicySetDefinition(msrest.serialization.Model): """The policy set definition. - Variables are only populated by the server, and will be ignored when - sending a request. - - All required parameters must be populated in order to send to Azure. + Variables are only populated by the server, and will be ignored when sending a request. - :param 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 + :ivar id: The ID of the policy set definition. + :vartype id: str + :ivar name: The name of the policy set definition. + :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, + 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 typically a collection of key value pairs. + :param metadata: The policy set definition metadata. Metadata is an open ended object and is + typically a collection of key value pairs. :type metadata: object - :param parameters: The policy set definition parameters that can be used - in policy definition references. + :param parameters: The policy set definition parameters that can be used in policy definition + references. :type parameters: dict[str, ~azure.mgmt.resource.policy.v2019_09_01.models.ParameterDefinitionsValue] - :param policy_definitions: Required. An array of policy definition - references. + :param policy_definitions: An array of policy definition references. :type policy_definitions: list[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinitionReference] - :param policy_definition_groups: The metadata describing groups of policy - definition references within the policy set definition. + :param policy_definition_groups: The metadata describing groups of policy definition references + within the policy set definition. :type policy_definition_groups: list[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinitionGroup] - :ivar id: The ID of the policy set definition. - :vartype id: str - :ivar name: The name of the policy set definition. - :vartype name: str - :ivar type: The type of the resource - (Microsoft.Authorization/policySetDefinitions). - :vartype type: str """ _validation = { - 'policy_definitions': {'required': True}, 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, } _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, 'policy_type': {'key': 'properties.policyType', 'type': 'str'}, 'display_name': {'key': 'properties.displayName', 'type': 'str'}, 'description': {'key': 'properties.description', 'type': 'str'}, @@ -513,13 +587,24 @@ class PolicySetDefinition(Model): 'parameters': {'key': 'properties.parameters', 'type': '{ParameterDefinitionsValue}'}, 'policy_definitions': {'key': 'properties.policyDefinitions', 'type': '[PolicyDefinitionReference]'}, 'policy_definition_groups': {'key': 'properties.policyDefinitionGroups', 'type': '[PolicyDefinitionGroup]'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, } - def __init__(self, *, policy_definitions, policy_type=None, display_name: str=None, description: str=None, metadata=None, parameters=None, policy_definition_groups=None, **kwargs) -> None: + def __init__( + self, + *, + policy_type: Optional[Union[str, "PolicyType"]] = None, + display_name: Optional[str] = None, + description: Optional[str] = None, + metadata: Optional[object] = None, + parameters: Optional[Dict[str, "ParameterDefinitionsValue"]] = None, + policy_definitions: Optional[List["PolicyDefinitionReference"]] = None, + policy_definition_groups: Optional[List["PolicyDefinitionGroup"]] = None, + **kwargs + ): super(PolicySetDefinition, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None self.policy_type = policy_type self.display_name = display_name self.description = description @@ -527,18 +612,40 @@ def __init__(self, *, policy_definitions, policy_type=None, display_name: str=No self.parameters = parameters self.policy_definitions = policy_definitions self.policy_definition_groups = policy_definition_groups - self.id = None - self.name = None - self.type = None -class PolicySku(Model): +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 + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[PolicySetDefinition]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["PolicySetDefinition"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(PolicySetDefinitionListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class PolicySku(msrest.serialization.Model): """The policy sku. This property is optional, obsolete, and will be ignored. 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. + :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 @@ -553,7 +660,13 @@ class PolicySku(Model): 'tier': {'key': 'tier', 'type': 'str'}, } - def __init__(self, *, name: str, tier: str=None, **kwargs) -> None: + def __init__( + self, + *, + name: str, + tier: Optional[str] = None, + **kwargs + ): 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/_paged_models.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/models/_paged_models.py deleted file mode 100644 index d6168d1d62aa..000000000000 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/models/_paged_models.py +++ /dev/null @@ -1,53 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.paging import Paged - - -class PolicyAssignmentPaged(Paged): - """ - A paging container for iterating over a list of :class:`PolicyAssignment ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[PolicyAssignment]'} - } - - def __init__(self, *args, **kwargs): - - super(PolicyAssignmentPaged, self).__init__(*args, **kwargs) -class PolicyDefinitionPaged(Paged): - """ - A paging container for iterating over a list of :class:`PolicyDefinition ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[PolicyDefinition]'} - } - - def __init__(self, *args, **kwargs): - - super(PolicyDefinitionPaged, self).__init__(*args, **kwargs) -class PolicySetDefinitionPaged(Paged): - """ - A paging container for iterating over a list of :class:`PolicySetDefinition ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[PolicySetDefinition]'} - } - - def __init__(self, *args, **kwargs): - - super(PolicySetDefinitionPaged, self).__init__(*args, **kwargs) 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 805f0fcafcb8..def18d71d88e 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 @@ -1,43 +1,45 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from enum import Enum - class EnforcementMode(str, Enum): + """The policy assignment enforcement mode. Possible values are Default and DoNotEnforce. + """ default = "Default" #: The policy effect is enforced during resource creation or update. do_not_enforce = "DoNotEnforce" #: The policy effect is not enforced during resource creation or update. +class ParameterType(str, Enum): + """The data type of the parameter. + """ -class ResourceIdentityType(str, Enum): - - system_assigned = "SystemAssigned" #: Indicates that a system assigned identity is associated with the resource. - none = "None" #: Indicates that no identity is associated with the resource or that the existing identity should be removed. - + string = "String" + array = "Array" + object = "Object" + boolean = "Boolean" + integer = "Integer" + float = "Float" + date_time = "DateTime" class PolicyType(str, Enum): + """The type of policy definition. Possible values are NotSpecified, BuiltIn, Custom, and Static. + """ not_specified = "NotSpecified" built_in = "BuiltIn" custom = "Custom" static = "Static" +class ResourceIdentityType(str, Enum): + """The identity type. This is the only required field when adding a system assigned identity to a + resource. + """ -class ParameterType(str, Enum): - - string = "String" - array = "Array" - object_enum = "Object" - boolean = "Boolean" - integer = "Integer" - float_enum = "Float" - date_time_enum = "DateTime" + system_assigned = "SystemAssigned" #: Indicates that a system assigned identity is associated with the resource. + none = "None" #: Indicates that no identity is associated with the resource or that the existing identity should be removed. diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/operations/__init__.py index c7d7b8eb9d97..4583d62b03a4 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/operations/__init__.py @@ -1,12 +1,9 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from ._policy_assignments_operations import PolicyAssignmentsOperations 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 b10755dcd661..ffa7050a6367 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 @@ -1,872 +1,736 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class PolicyAssignmentsOperations(object): """PolicyAssignmentsOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.policy.v2019_09_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for the operation. Constant value: "2019-09-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-09-01" - - self.config = config + self._config = config def delete( - self, scope, policy_assignment_name, custom_headers=None, raw=False, **operation_config): - """Deletes a policy assignment. - - This operation deletes a policy assignment, given its name and the - scope it was created in. The scope of a policy assignment is the part - of its ID preceding - '/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. - - :param scope: The scope of the policy assignment. Valid scopes are: - management group (format: - '/providers/Microsoft.Management/managementGroups/{managementGroup}'), - subscription (format: '/subscriptions/{subscriptionId}'), resource - group (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', - or resource (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' + self, + scope, # type: str + policy_assignment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyAssignment" + """This operation deletes a policy assignment, given its name and the scope it was created in. The scope of a policy assignment is the part of its ID preceding '/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + + Deletes a policy assignment. + + :param scope: The scope of the policy assignment. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. :type scope: str - :param policy_assignment_name: The name of the policy assignment to - delete. + :param policy_assignment_name: The name of the policy assignment to delete. :type policy_assignment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyAssignment or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignment or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignment or None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-09-01" + # Construct URL - url = self.delete.metadata['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') + 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('PolicyAssignment', response) + deserialized = self._deserialize('PolicyAssignment', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} + delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore def create( - self, scope, policy_assignment_name, parameters, custom_headers=None, raw=False, **operation_config): - """Creates or updates a policy assignment. - - This operation creates or updates a policy assignment with the given - scope and name. Policy assignments apply to all resources contained - within their scope. For example, when you assign a policy at resource - group scope, that policy applies to all resources in the group. - - :param scope: The scope of the policy assignment. Valid scopes are: - management group (format: - '/providers/Microsoft.Management/managementGroups/{managementGroup}'), - subscription (format: '/subscriptions/{subscriptionId}'), resource - group (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', - or resource (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' + self, + scope, # type: str + policy_assignment_name, # type: str + parameters, # type: "models.PolicyAssignment" + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyAssignment" + """This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + + Creates or updates a policy assignment. + + :param scope: The scope of the policy assignment. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. :type scope: str :param policy_assignment_name: The name of the policy assignment. :type policy_assignment_name: str :param parameters: Parameters for the policy assignment. - :type parameters: - ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignment - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyAssignment or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignment or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :type parameters: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignment + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-09-01" + content_type = kwargs.pop("content_type", "application/json") + # Construct URL - url = self.create.metadata['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') + 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'PolicyAssignment') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 201: - deserialized = self._deserialize('PolicyAssignment', response) + deserialized = self._deserialize('PolicyAssignment', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} + create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore def get( - self, scope, policy_assignment_name, custom_headers=None, raw=False, **operation_config): - """Retrieves a policy assignment. - - This operation retrieves a single policy assignment, given its name and - the scope it was created at. - - :param scope: The scope of the policy assignment. Valid scopes are: - management group (format: - '/providers/Microsoft.Management/managementGroups/{managementGroup}'), - subscription (format: '/subscriptions/{subscriptionId}'), resource - group (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', - or resource (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' + self, + scope, # type: str + policy_assignment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyAssignment" + """This operation retrieves a single policy assignment, given its name and the scope it was created at. + + Retrieves a policy assignment. + + :param scope: The scope of the policy assignment. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'), resource group (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. :type scope: str - :param policy_assignment_name: The name of the policy assignment to - get. + :param policy_assignment_name: The name of the policy assignment to get. :type policy_assignment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyAssignment or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignment or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-09-01" + # Construct URL - url = self.get.metadata['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') + 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('PolicyAssignment', response) + deserialized = self._deserialize('PolicyAssignment', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} + get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'} # type: ignore def list_for_resource_group( - self, resource_group_name, filter=None, custom_headers=None, raw=False, **operation_config): - """Retrieves all policy assignments that apply to a resource group. - - This operation retrieves the list of all policy assignments associated - with the given resource group in the given subscription that match the - optional given $filter. Valid values for $filter are: 'atScope()' or - 'policyDefinitionId eq '{value}''. If $filter is not provided, the - unfiltered list includes all policy assignments associated with the - resource group, including those that apply directly or apply from - containing scopes, as well as any applied to resources contained within - the resource group. If $filter=atScope() is provided, the returned list - includes all policy assignments that apply to the resource group, which - is everything in the unfiltered list except those applied to resources - contained within the resource group. If $filter=policyDefinitionId eq - '{value}' is provided, the returned list includes all policy - assignments of the policy definition whose id is {value} that apply to - the resource group. - - :param resource_group_name: The name of the resource group that - contains policy assignments. + self, + resource_group_name, # type: str + filter=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.PolicyAssignmentListResult"] + """This operation retrieves the list of all policy assignments associated with the given resource group in the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource group, including those that apply directly or apply from containing scopes, as well as any applied to resources contained within the resource group. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource group, which is everything in the unfiltered list except those applied to resources contained within the resource group. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource group. + + Retrieves all policy assignments that apply to a resource group. + + :param resource_group_name: The name of the resource group that contains policy assignments. :type resource_group_name: str - :param filter: The filter to apply on the operation. Valid values for - $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If - $filter is not provided, no filtering is performed. + :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()' + or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. :type filter: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of PolicyAssignment - :rtype: - ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignmentPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignment] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-09-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_for_resource_group.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.PolicyAssignmentPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_for_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments'} + return ItemPaged( + get_next, extract_data + ) + list_for_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments'} # type: ignore def list_for_resource( - self, resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, filter=None, custom_headers=None, raw=False, **operation_config): - """Retrieves all policy assignments that apply to a resource. - - This operation retrieves the list of all policy assignments associated - with the specified resource in the given resource group and - subscription that match the optional given $filter. Valid values for - $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If - $filter is not provided, the unfiltered list includes all policy - assignments associated with the resource, including those that apply - directly or from all containing scopes, as well as any applied to - resources contained within the resource. If $filter=atScope() is - provided, the returned list includes all policy assignments that apply - to the resource, which is everything in the unfiltered list except - those applied to resources contained within the resource. If - $filter=policyDefinitionId eq '{value}' is provided, the returned list - includes all policy assignments of the policy definition whose id is - {value} that apply to the resource. Three parameters plus the resource - name are used to identify a specific resource. If the resource is not - part of a parent resource (the more common case), the parent resource - path should not be provided (or provided as ''). For example a web app - could be specified as ({resourceProviderNamespace} == 'Microsoft.Web', - {parentResourcePath} == '', {resourceType} == 'sites', {resourceName} - == 'MyWebApp'). If the resource is part of a parent resource, then all - parameters should be provided. For example a virtual machine DNS name - could be specified as ({resourceProviderNamespace} == - 'Microsoft.Compute', {parentResourcePath} == - 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames', - {resourceName} == 'MyComputerName'). A convenient alternative to - providing the namespace and type name separately is to provide both in - the {resourceType} parameter, format: ({resourceProviderNamespace} == - '', {parentResourcePath} == '', {resourceType} == - 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). - - :param resource_group_name: The name of the resource group containing - the resource. + self, + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + filter=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.PolicyAssignmentListResult"] + """This operation retrieves the list of all policy assignments associated with the specified resource in the given resource group and subscription that match the optional given $filter. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource, including those that apply directly or from all containing scopes, as well as any applied to resources contained within the resource. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource, which is everything in the unfiltered list except those applied to resources contained within the resource. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource. Three parameters plus the resource name are used to identify a specific resource. If the resource is not part of a parent resource (the more common case), the parent resource path should not be provided (or provided as ''). For example a web app could be specified as ({resourceProviderNamespace} == 'Microsoft.Web', {parentResourcePath} == '', {resourceType} == 'sites', {resourceName} == 'MyWebApp'). If the resource is part of a parent resource, then all parameters should be provided. For example a virtual machine DNS name could be specified as ({resourceProviderNamespace} == 'Microsoft.Compute', {parentResourcePath} == 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames', {resourceName} == 'MyComputerName'). A convenient alternative to providing the namespace and type name separately is to provide both in the {resourceType} parameter, format: ({resourceProviderNamespace} == '', {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). + + Retrieves all policy assignments that apply to a resource. + + :param resource_group_name: The name of the resource group containing the resource. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource - provider. For example, the namespace of a virtual machine is - Microsoft.Compute (from Microsoft.Compute/virtualMachines) + :param resource_provider_namespace: The namespace of the resource provider. For example, the + namespace of a virtual machine is Microsoft.Compute (from Microsoft.Compute/virtualMachines). :type resource_provider_namespace: str - :param parent_resource_path: The parent resource path. Use empty - string if there is none. + :param parent_resource_path: The parent resource path. Use empty string if there is none. :type parent_resource_path: str - :param resource_type: The resource type name. For example the type - name of a web app is 'sites' (from Microsoft.Web/sites). + :param resource_type: The resource type name. For example the type name of a web app is 'sites' + (from Microsoft.Web/sites). :type resource_type: str :param resource_name: The name of the resource. :type resource_name: str - :param filter: The filter to apply on the operation. Valid values for - $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If - $filter is not provided, no filtering is performed. + :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()' + or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. :type filter: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of PolicyAssignment - :rtype: - ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignmentPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignment] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-09-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_for_resource.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.PolicyAssignmentPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_for_resource.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments'} + 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 def list_for_management_group( - self, management_group_id, filter, custom_headers=None, raw=False, **operation_config): - """Retrieves all policy assignments that apply to a management group. - - This operation retrieves the list of all policy assignments applicable - to the management group that match the given $filter. Valid values for - $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If - $filter=atScope() is provided, the returned list includes all policy - assignments that are assigned to the management group or the management - group's ancestors. If $filter=policyDefinitionId eq '{value}' is - provided, the returned list includes all policy assignments of the - policy definition whose id is {value} that apply to the management - group. + self, + management_group_id, # type: str + filter, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.PolicyAssignmentListResult"] + """This operation retrieves the list of all policy assignments applicable to the management group that match the given $filter. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter=atScope() is provided, the returned list includes all policy assignments that are assigned to the management group or the management group's ancestors. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the management group. + + Retrieves all policy assignments that apply to a management group. :param management_group_id: The ID of the management group. :type management_group_id: str - :param filter: The filter to apply on the operation. Valid values for - $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. A - filter is required when listing policy assignments at management group - scope. + :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()' + or 'policyDefinitionId eq '{value}''. A filter is required when listing policy assignments at + management group scope. :type filter: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of PolicyAssignment - :rtype: - ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignmentPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignment] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-09-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_for_management_group.metadata['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') + 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.PolicyAssignmentPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_for_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyAssignments'} + return ItemPaged( + get_next, extract_data + ) + list_for_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyAssignments'} # type: ignore def list( - self, filter=None, custom_headers=None, raw=False, **operation_config): - """Retrieves all policy assignments that apply to a subscription. - - This operation retrieves the list of all policy assignments associated - with the given subscription that match the optional given $filter. - Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq - '{value}''. If $filter is not provided, the unfiltered list includes - all policy assignments associated with the subscription, including - those that apply directly or from management groups that contain the - given subscription, as well as any applied to objects contained within - the subscription. If $filter=atScope() is provided, the returned list - includes all policy assignments that apply to the subscription, which - is everything in the unfiltered list except those applied to objects - contained within the subscription. If $filter=policyDefinitionId eq - '{value}' is provided, the returned list includes all policy - assignments of the policy definition whose id is {value}. - - :param filter: The filter to apply on the operation. Valid values for - $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If - $filter is not provided, no filtering is performed. + self, + filter=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.PolicyAssignmentListResult"] + """This operation retrieves the list of all policy assignments associated with the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the subscription, including those that apply directly or from management groups that contain the given subscription, as well as any applied to objects contained within the subscription. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the subscription, which is everything in the unfiltered list except those applied to objects contained within the subscription. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value}. + + Retrieves all policy assignments that apply to a subscription. + + :param filter: The filter to apply on the operation. Valid values for $filter are: 'atScope()' + or 'policyDefinitionId eq '{value}''. If $filter is not provided, no filtering is performed. :type filter: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of PolicyAssignment - :rtype: - ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignmentPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignment] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-09-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['url'] + url = self.list.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_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 = {} + 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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyAssignmentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.PolicyAssignmentPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments'} # type: ignore def delete_by_id( - self, policy_assignment_id, custom_headers=None, raw=False, **operation_config): - """Deletes a policy assignment. - - This operation deletes the policy with the given ID. Policy assignment - IDs have this format: - '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. - Valid formats for {scope} are: - '/providers/Microsoft.Management/managementGroups/{managementGroup}' - (management group), '/subscriptions/{subscriptionId}' (subscription), - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' - (resource group), or - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' - (resource). - - :param policy_assignment_id: The ID of the policy assignment to - delete. Use the format + self, + policy_assignment_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyAssignment" + """This operation deletes the policy with the given ID. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid formats for {scope} are: '/providers/Microsoft.Management/managementGroups/{managementGroup}' (management group), '/subscriptions/{subscriptionId}' (subscription), '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' (resource group), or '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' (resource). + + Deletes a policy assignment. + + :param policy_assignment_id: The ID of the policy assignment to delete. Use the format '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. :type policy_assignment_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyAssignment or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignment or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignment or None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-09-01" + # Construct URL - url = self.delete_by_id.metadata['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) + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('PolicyAssignment', response) + deserialized = self._deserialize('PolicyAssignment', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - delete_by_id.metadata = {'url': '/{policyAssignmentId}'} + delete_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore def create_by_id( - self, policy_assignment_id, parameters, custom_headers=None, raw=False, **operation_config): - """Creates or updates a policy assignment. - - This operation creates or updates the policy assignment with the given - ID. Policy assignments made on a scope apply to all resources contained - in that scope. For example, when you assign a policy to a resource - group that policy applies to all resources in the group. Policy - assignment IDs have this format: - '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. - Valid scopes are: management group (format: - '/providers/Microsoft.Management/managementGroups/{managementGroup}'), - subscription (format: '/subscriptions/{subscriptionId}'), resource - group (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', - or resource (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. - - :param policy_assignment_id: The ID of the policy assignment to - create. Use the format + self, + policy_assignment_id, # type: str + parameters, # type: "models.PolicyAssignment" + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyAssignment" + """This operation creates or updates the policy assignment with the given ID. Policy assignments made on a scope apply to all resources contained in that scope. For example, when you assign a policy to a resource group that policy applies to all resources in the group. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + + Creates or updates a policy assignment. + + :param policy_assignment_id: The ID of the policy assignment to create. Use the format '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. :type policy_assignment_id: str :param parameters: Parameters for policy assignment. - :type parameters: - ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignment - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyAssignment or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignment or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :type parameters: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignment + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-09-01" + content_type = kwargs.pop("content_type", "application/json") + # Construct URL - url = self.create_by_id.metadata['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) + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'PolicyAssignment') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 201: - deserialized = self._deserialize('PolicyAssignment', response) + deserialized = self._deserialize('PolicyAssignment', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create_by_id.metadata = {'url': '/{policyAssignmentId}'} + create_by_id.metadata = {'url': '/{policyAssignmentId}'} # type: ignore def get_by_id( - self, policy_assignment_id, custom_headers=None, raw=False, **operation_config): - """Retrieves the policy assignment with the given ID. - - The operation retrieves the policy assignment with the given ID. Policy - assignment IDs have this format: - '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. - Valid scopes are: management group (format: - '/providers/Microsoft.Management/managementGroups/{managementGroup}'), - subscription (format: '/subscriptions/{subscriptionId}'), resource - group (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', - or resource (format: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. - - :param policy_assignment_id: The ID of the policy assignment to get. - Use the format + self, + policy_assignment_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyAssignment" + """The operation retrieves the policy assignment with the given ID. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + + Retrieves the policy assignment with the given ID. + + :param policy_assignment_id: The ID of the policy assignment to get. Use the format '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. :type policy_assignment_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyAssignment or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignment or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyAssignment or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyAssignment"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-09-01" + # Construct URL - url = self.get_by_id.metadata['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) + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('PolicyAssignment', response) + deserialized = self._deserialize('PolicyAssignment', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/{policyAssignmentId}'} + 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 09efe4909d9b..daffb2f30c8a 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 @@ -1,686 +1,646 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class PolicyDefinitionsOperations(object): """PolicyDefinitionsOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.policy.v2019_09_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for the operation. Constant value: "2019-09-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-09-01" - - self.config = config + self._config = config def create_or_update( - self, policy_definition_name, parameters, custom_headers=None, raw=False, **operation_config): - """Creates or updates a policy definition in a subscription. + self, + policy_definition_name, # type: str + parameters, # type: "models.PolicyDefinition" + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyDefinition" + """This operation creates or updates a policy definition in the given subscription with the given name. - This operation creates or updates a policy definition in the given - subscription with the given name. + Creates or updates a policy definition in a subscription. - :param policy_definition_name: The name of the policy definition to - create. + :param policy_definition_name: The name of the policy definition to create. :type policy_definition_name: str :param parameters: The policy definition properties. - :type parameters: - ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinition - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyDefinition or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinition or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :type parameters: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinition + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-09-01" + content_type = kwargs.pop("content_type", "application/json") + # Construct URL - url = self.create_or_update.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'PolicyDefinition') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [201]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 201: - deserialized = self._deserialize('PolicyDefinition', response) + deserialized = self._deserialize('PolicyDefinition', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore def delete( - self, policy_definition_name, custom_headers=None, raw=False, **operation_config): - """Deletes a policy definition in a subscription. + self, + policy_definition_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """This operation deletes the policy definition in the given subscription with the given name. - This operation deletes the policy definition in the given subscription - with the given name. + Deletes a policy definition in a subscription. - :param policy_definition_name: The name of the policy definition to - delete. + :param policy_definition_name: The name of the policy definition to delete. :type policy_definition_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-09-01" + # Construct URL - url = self.delete.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} + delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore def get( - self, policy_definition_name, custom_headers=None, raw=False, **operation_config): - """Retrieves a policy definition in a subscription. + self, + policy_definition_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyDefinition" + """This operation retrieves the policy definition in the given subscription with the given name. - This operation retrieves the policy definition in the given - subscription with the given name. + Retrieves a policy definition in a subscription. - :param policy_definition_name: The name of the policy definition to - get. + :param policy_definition_name: The name of the policy definition to get. :type policy_definition_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyDefinition or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinition or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinition + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-09-01" + # Construct URL - url = self.get.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('PolicyDefinition', response) + deserialized = self._deserialize('PolicyDefinition', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore def get_built_in( - self, policy_definition_name, custom_headers=None, raw=False, **operation_config): - """Retrieves a built-in policy definition. + self, + policy_definition_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyDefinition" + """This operation retrieves the built-in policy definition with the given name. - This operation retrieves the built-in policy definition with the given - name. + Retrieves a built-in policy definition. - :param policy_definition_name: The name of the built-in policy - definition to get. + :param policy_definition_name: The name of the built-in policy definition to get. :type policy_definition_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyDefinition or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinition or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinition + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-09-01" + # Construct URL - url = self.get_built_in.metadata['url'] + url = self.get_built_in.metadata['url'] # type: ignore path_format_arguments = { - 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str') + 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('PolicyDefinition', response) + deserialized = self._deserialize('PolicyDefinition', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} + get_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore def create_or_update_at_management_group( - self, policy_definition_name, parameters, management_group_id, custom_headers=None, raw=False, **operation_config): - """Creates or updates a policy definition in a management group. - - This operation creates or updates a policy definition in the given - management group with the given name. - - :param policy_definition_name: The name of the policy definition to - create. + self, + policy_definition_name, # type: str + management_group_id, # type: str + parameters, # type: "models.PolicyDefinition" + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyDefinition" + """This operation creates or updates a policy definition in the given management group with the given name. + + Creates or updates a policy definition in a management group. + + :param policy_definition_name: The name of the policy definition to create. :type policy_definition_name: str - :param parameters: The policy definition properties. - :type parameters: - ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinition :param management_group_id: The ID of the management group. :type management_group_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyDefinition or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinition or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :param parameters: The policy definition properties. + :type parameters: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinition + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-09-01" + content_type = kwargs.pop("content_type", "application/json") + # Construct URL - url = self.create_or_update_at_management_group.metadata['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') + 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'PolicyDefinition') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [201]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 201: - deserialized = self._deserialize('PolicyDefinition', response) + deserialized = self._deserialize('PolicyDefinition', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + 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}'} + create_or_update_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore def delete_at_management_group( - self, policy_definition_name, management_group_id, custom_headers=None, raw=False, **operation_config): - """Deletes a policy definition in a management group. + self, + policy_definition_name, # type: str + management_group_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """This operation deletes the policy definition in the given management group with the given name. - This operation deletes the policy definition in the given management - group with the given name. + Deletes a policy definition in a management group. - :param policy_definition_name: The name of the policy definition to - delete. + :param policy_definition_name: The name of the policy definition to delete. :type policy_definition_name: str :param management_group_id: The ID of the management group. :type management_group_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-09-01" + # Construct URL - url = self.delete_at_management_group.metadata['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') + 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} + if cls: + return cls(pipeline_response, None, {}) + + delete_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore def get_at_management_group( - self, policy_definition_name, management_group_id, custom_headers=None, raw=False, **operation_config): - """Retrieve a policy definition in a management group. + self, + policy_definition_name, # type: str + management_group_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyDefinition" + """This operation retrieves the policy definition in the given management group with the given name. - This operation retrieves the policy definition in the given management - group with the given name. + Retrieve a policy definition in a management group. - :param policy_definition_name: The name of the policy definition to - get. + :param policy_definition_name: The name of the policy definition to get. :type policy_definition_name: str :param management_group_id: The ID of the management group. :type management_group_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyDefinition or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinition or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinition + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-09-01" + # Construct URL - url = self.get_at_management_group.metadata['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') + 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('PolicyDefinition', response) + deserialized = self._deserialize('PolicyDefinition', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} + get_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'} # type: ignore def list( - self, custom_headers=None, raw=False, **operation_config): - """Retrieves policy definitions in a subscription. - - This operation retrieves a list of all the policy definitions in a - given subscription. - - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of PolicyDefinition - :rtype: - ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinitionPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinition] - :raises: :class:`CloudError` + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.PolicyDefinitionListResult"] + """This operation retrieves a list of all the policy definitions in a given subscription. + + Retrieves policy definitions in a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-09-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['url'] + url = self.list.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyDefinitionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.PolicyDefinitionPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions'} # type: ignore def list_built_in( - self, custom_headers=None, raw=False, **operation_config): - """Retrieve built-in policy definitions. - - This operation retrieves a list of all the built-in policy definitions. - - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of PolicyDefinition - :rtype: - ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinitionPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinition] - :raises: :class:`CloudError` + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.PolicyDefinitionListResult"] + """This operation retrieves a list of all the built-in policy definitions. + + Retrieve 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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-09-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_built_in.metadata['url'] - + url = self.list_built_in.metadata['url'] # type: ignore # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyDefinitionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.PolicyDefinitionPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policyDefinitions'} + return ItemPaged( + get_next, extract_data + ) + list_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policyDefinitions'} # type: ignore def list_by_management_group( - self, management_group_id, custom_headers=None, raw=False, **operation_config): - """Retrieve policy definitions in a management group. + self, + management_group_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.PolicyDefinitionListResult"] + """This operation retrieves a list of all the policy definitions in a given management group. - This operation retrieves a list of all the policy definitions in a - given management group. + Retrieve policy definitions in a management group. :param management_group_id: The ID of the management group. :type management_group_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of PolicyDefinition - :rtype: - ~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinitionPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicyDefinition] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-09-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_by_management_group.metadata['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') + 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('PolicyDefinitionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.PolicyDefinitionPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_by_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions'} + return ItemPaged( + get_next, extract_data + ) + list_by_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions'} # type: ignore 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 07a26ff53a2c..393d352d9a29 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 @@ -1,691 +1,656 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class PolicySetDefinitionsOperations(object): """PolicySetDefinitionsOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.policy.v2019_09_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for the operation. Constant value: "2019-09-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-09-01" - - self.config = config + self._config = config def create_or_update( - self, policy_set_definition_name, parameters, custom_headers=None, raw=False, **operation_config): - """Creates or updates a policy set definition. + self, + policy_set_definition_name, # type: str + parameters, # type: "models.PolicySetDefinition" + **kwargs # type: Any + ): + # type: (...) -> "models.PolicySetDefinition" + """This operation creates or updates a policy set definition in the given subscription with the given name. - This operation creates or updates a policy set definition in the given - subscription with the given name. + Creates or updates a policy set definition. - :param policy_set_definition_name: The name of the policy set - definition to create. + :param policy_set_definition_name: The name of the policy set definition to create. :type policy_set_definition_name: str :param parameters: The policy set definition properties. - :type parameters: - ~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinition - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicySetDefinition or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinition or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :type parameters: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinition + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicySetDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-09-01" + content_type = kwargs.pop("content_type", "application/json") + # Construct URL - url = self.create_or_update.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'PolicySetDefinition') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('PolicySetDefinition', response) + deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('PolicySetDefinition', response) + deserialized = self._deserialize('PolicySetDefinition', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore def delete( - self, policy_set_definition_name, custom_headers=None, raw=False, **operation_config): - """Deletes a policy set definition. + self, + policy_set_definition_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """This operation deletes the policy set definition in the given subscription with the given name. - This operation deletes the policy set definition in the given - subscription with the given name. + Deletes a policy set definition. - :param policy_set_definition_name: The name of the policy set - definition to delete. + :param policy_set_definition_name: The name of the policy set definition to delete. :type policy_set_definition_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-09-01" + # Construct URL - url = self.delete.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} + delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore def get( - self, policy_set_definition_name, custom_headers=None, raw=False, **operation_config): - """Retrieves a policy set definition. + self, + policy_set_definition_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.PolicySetDefinition" + """This operation retrieves the policy set definition in the given subscription with the given name. - This operation retrieves the policy set definition in the given - subscription with the given name. + Retrieves a policy set definition. - :param policy_set_definition_name: The name of the policy set - definition to get. + :param policy_set_definition_name: The name of the policy set definition to get. :type policy_set_definition_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicySetDefinition or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinition or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinition + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicySetDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-09-01" + # Construct URL - url = self.get.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('PolicySetDefinition', response) + deserialized = self._deserialize('PolicySetDefinition', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore def get_built_in( - self, policy_set_definition_name, custom_headers=None, raw=False, **operation_config): - """Retrieves a built in policy set definition. + self, + policy_set_definition_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.PolicySetDefinition" + """This operation retrieves the built-in policy set definition with the given name. - This operation retrieves the built-in policy set definition with the - given name. + Retrieves a built in policy set definition. - :param policy_set_definition_name: The name of the policy set - definition to get. + :param policy_set_definition_name: The name of the policy set definition to get. :type policy_set_definition_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicySetDefinition or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinition or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinition + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicySetDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-09-01" + # Construct URL - url = self.get_built_in.metadata['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') + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('PolicySetDefinition', response) + deserialized = self._deserialize('PolicySetDefinition', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} + get_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore def list( - self, custom_headers=None, raw=False, **operation_config): - """Retrieves the policy set definitions for a subscription. - - This operation retrieves a list of all the policy set definitions in - the given subscription. - - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of PolicySetDefinition - :rtype: - ~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinitionPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinition] - :raises: :class:`CloudError` + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.PolicySetDefinitionListResult"] + """This operation retrieves a list of all the policy set definitions in the given subscription. + + Retrieves 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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-09-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['url'] + url = self.list.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('PolicySetDefinitionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.PolicySetDefinitionPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions'} # type: ignore def list_built_in( - self, custom_headers=None, raw=False, **operation_config): - """Retrieves built-in policy set definitions. - - This operation retrieves a list of all the built-in policy set - definitions. - - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of PolicySetDefinition - :rtype: - ~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinitionPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinition] - :raises: :class:`CloudError` + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.PolicySetDefinitionListResult"] + """This operation retrieves a list of all the built-in policy set definitions. + + Retrieves 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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-09-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_built_in.metadata['url'] - + url = self.list_built_in.metadata['url'] # type: ignore # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('PolicySetDefinitionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.PolicySetDefinitionPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policySetDefinitions'} + return ItemPaged( + get_next, extract_data + ) + list_built_in.metadata = {'url': '/providers/Microsoft.Authorization/policySetDefinitions'} # type: ignore def create_or_update_at_management_group( - self, policy_set_definition_name, parameters, management_group_id, custom_headers=None, raw=False, **operation_config): - """Creates or updates a policy set definition. - - This operation creates or updates a policy set definition in the given - management group with the given name. - - :param policy_set_definition_name: The name of the policy set - definition to create. + self, + policy_set_definition_name, # type: str + management_group_id, # type: str + parameters, # type: "models.PolicySetDefinition" + **kwargs # type: Any + ): + # type: (...) -> "models.PolicySetDefinition" + """This operation creates or updates a policy set definition in the given management group with the given name. + + Creates or updates a policy set definition. + + :param policy_set_definition_name: The name of the policy set definition to create. :type policy_set_definition_name: str - :param parameters: The policy set definition properties. - :type parameters: - ~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinition :param management_group_id: The ID of the management group. :type management_group_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicySetDefinition or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinition or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :param parameters: The policy set definition properties. + :type parameters: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinition + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicySetDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-09-01" + content_type = kwargs.pop("content_type", "application/json") + # Construct URL - url = self.create_or_update_at_management_group.metadata['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') + 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'PolicySetDefinition') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('PolicySetDefinition', response) + deserialized = self._deserialize('PolicySetDefinition', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('PolicySetDefinition', response) + deserialized = self._deserialize('PolicySetDefinition', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + 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}'} + create_or_update_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore def delete_at_management_group( - self, policy_set_definition_name, management_group_id, custom_headers=None, raw=False, **operation_config): - """Deletes a policy set definition. + self, + policy_set_definition_name, # type: str + management_group_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """This operation deletes the policy set definition in the given management group with the given name. - This operation deletes the policy set definition in the given - management group with the given name. + Deletes a policy set definition. - :param policy_set_definition_name: The name of the policy set - definition to delete. + :param policy_set_definition_name: The name of the policy set definition to delete. :type policy_set_definition_name: str :param management_group_id: The ID of the management group. :type management_group_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-09-01" + # Construct URL - url = self.delete_at_management_group.metadata['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') + 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} + delete_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore def get_at_management_group( - self, policy_set_definition_name, management_group_id, custom_headers=None, raw=False, **operation_config): - """Retrieves a policy set definition. + self, + policy_set_definition_name, # type: str + management_group_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.PolicySetDefinition" + """This operation retrieves the policy set definition in the given management group with the given name. - This operation retrieves the policy set definition in the given - management group with the given name. + Retrieves a policy set definition. - :param policy_set_definition_name: The name of the policy set - definition to get. + :param policy_set_definition_name: The name of the policy set definition to get. :type policy_set_definition_name: str :param management_group_id: The ID of the management group. :type management_group_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicySetDefinition or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinition or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicySetDefinition or the result of cls(response) + :rtype: ~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinition + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicySetDefinition"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-09-01" + # Construct URL - url = self.get_at_management_group.metadata['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') + 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('PolicySetDefinition', response) + deserialized = self._deserialize('PolicySetDefinition', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} + get_at_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}'} # type: ignore def list_by_management_group( - self, management_group_id, custom_headers=None, raw=False, **operation_config): - """Retrieves all policy set definitions in management group. + self, + management_group_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.PolicySetDefinitionListResult"] + """This operation retrieves a list of all the a policy set definition in the given management group. - This operation retrieves a list of all the a policy set definition in - the given management group. + Retrieves all policy set definitions in management group. :param management_group_id: The ID of the management group. :type management_group_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of PolicySetDefinition - :rtype: - ~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinitionPaged[~azure.mgmt.resource.policy.v2019_09_01.models.PolicySetDefinition] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-09-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_by_management_group.metadata['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') + 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('PolicySetDefinitionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.PolicySetDefinitionPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list_by_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions'} + return ItemPaged( + get_next, extract_data + ) + list_by_management_group.metadata = {'url': '/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/py.typed b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file 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 deleted file mode 100644 index c438021f6b89..000000000000 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2019_09_01/version.py +++ /dev/null @@ -1,13 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -VERSION = "2019-09-01" - diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/__init__.py index 7eb6845ce5ea..fde2ed4c3b83 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/__init__.py @@ -1,19 +1,16 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._configuration import ResourceManagementClientConfiguration from ._resource_management_client import ResourceManagementClient -__all__ = ['ResourceManagementClient', 'ResourceManagementClientConfiguration'] - -from ..version import VERSION - -__version__ = VERSION +__all__ = ['ResourceManagementClient'] +try: + from ._patch import patch_sdk + patch_sdk() +except ImportError: + pass 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 306faab728ec..11e850ae2fd4 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 @@ -1,48 +1,69 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrestazure import AzureConfiguration -from ..version import VERSION +from typing import TYPE_CHECKING +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + + from azure.core.credentials import TokenCredential + +VERSION = "unknown" + +class ResourceManagementClientConfiguration(Configuration): + """Configuration for ResourceManagementClient. -class ResourceManagementClientConfiguration(AzureConfiguration): - """Configuration for ResourceManagementClient Note that all parameters used to create this instance are saved as instance attributes. - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` + :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 """ def __init__( - self, credentials, subscription_id, base_url=None): - - if credentials is None: - raise ValueError("Parameter 'credentials' must not be None.") + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + 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.") - if not base_url: - base_url = 'https://management.azure.com' + super(ResourceManagementClientConfiguration, self).__init__(**kwargs) - super(ResourceManagementClientConfiguration, self).__init__(base_url) - - # Starting Autorest.Python 4.0.64, make connection pool activated by default - self.keep_alive = True - - self.add_user_agent('azure-mgmt-resource/{}'.format(VERSION)) - self.add_user_agent('Azure-SDK-For-Python') - - self.credentials = credentials + self.credential = credential self.subscription_id = subscription_id + self.api_version = "2019-10-01" + self.credential_scopes = ['https://management.azure.com/.default'] + self.credential_scopes.extend(kwargs.pop('credential_scopes', [])) + kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + 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) 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 68bc897193ac..fde2ed4c3b83 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 @@ -1,19 +1,16 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._configuration import ResourceManagementClientConfiguration from ._resource_management_client import ResourceManagementClient -__all__ = ['ResourceManagementClient', 'ResourceManagementClientConfiguration'] - -from .version import VERSION - -__version__ = VERSION +__all__ = ['ResourceManagementClient'] +try: + from ._patch import patch_sdk + patch_sdk() +except ImportError: + pass 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 3b326f792363..23448452a64b 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 @@ -1,48 +1,69 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrestazure import AzureConfiguration -from .version import VERSION +from typing import TYPE_CHECKING +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + + from azure.core.credentials import TokenCredential + +VERSION = "unknown" + +class ResourceManagementClientConfiguration(Configuration): + """Configuration for ResourceManagementClient. -class ResourceManagementClientConfiguration(AzureConfiguration): - """Configuration for ResourceManagementClient Note that all parameters used to create this instance are saved as instance attributes. - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` + :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 """ def __init__( - self, credentials, subscription_id, base_url=None): - - if credentials is None: - raise ValueError("Parameter 'credentials' must not be None.") + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + 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.") - if not base_url: - base_url = 'https://management.azure.com' + super(ResourceManagementClientConfiguration, self).__init__(**kwargs) - super(ResourceManagementClientConfiguration, self).__init__(base_url) - - # Starting Autorest.Python 4.0.64, make connection pool activated by default - self.keep_alive = True - - self.add_user_agent('azure-mgmt-resource/{}'.format(VERSION)) - self.add_user_agent('Azure-SDK-For-Python') - - self.credentials = credentials + self.credential = credential self.subscription_id = subscription_id + self.api_version = "2016-02-01" + self.credential_scopes = ['https://management.azure.com/.default'] + self.credential_scopes.extend(kwargs.pop('credential_scopes', [])) + kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + 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) 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 new file mode 100644 index 000000000000..a121a202388e --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/_metadata.json @@ -0,0 +1,58 @@ +{ + "chosen_version": "2016-02-01", + "total_api_version_list": ["2016-02-01"], + "client": { + "name": "ResourceManagementClient", + "filename": "_resource_management_client", + "description": "ResourceManagementClient." + }, + "global_parameters": { + "sync_method": { + "credential": { + "method_signature": "credential, # type: \"TokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials.TokenCredential", + "required": true + }, + "subscription_id": { + "method_signature": "subscription_id, # type: str", + "description": "The ID of the target subscription.", + "docstring_type": "str", + "required": true + } + }, + "async_method": { + "credential": { + "method_signature": "credential, # type: \"AsyncTokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + }, + "subscription_id": { + "method_signature": "subscription_id, # type: str", + "description": "The ID of the target subscription.", + "docstring_type": "str", + "required": true + } + }, + "constant": { + }, + "call": "credential, subscription_id" + }, + "config": { + "credential": true, + "credential_scopes": ["https://management.azure.com/.default"] + }, + "operation_groups": { + "deployments": "DeploymentsOperations", + "providers": "ProvidersOperations", + "resource_groups": "ResourceGroupsOperations", + "resources": "ResourcesOperations", + "tags": "TagsOperations", + "deployment_operations": "DeploymentOperationsOperations" + }, + "operation_mixins": { + }, + "sync_imports": "None", + "async_imports": "None" +} \ 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 147e393a4816..871b7ecce97c 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 @@ -1,16 +1,19 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.service_client import SDKClient -from msrest import Serializer, Deserializer +from typing import TYPE_CHECKING + +from azure.mgmt.core import ARMPipelineClient +from msrest import Deserializer, Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional from ._configuration import ResourceManagementClientConfiguration from .operations import DeploymentsOperations @@ -18,57 +21,72 @@ from .operations import ResourceGroupsOperations from .operations import ResourcesOperations from .operations import TagsOperations -from .operations import DeploymentOperations +from .operations import DeploymentOperationsOperations from . import models -class ResourceManagementClient(SDKClient): - """ResourceManagementClient +class ResourceManagementClient(object): + """ResourceManagementClient. - :ivar config: Configuration for client. - :vartype config: ResourceManagementClientConfiguration - - :ivar deployments: Deployments operations + :ivar deployments: DeploymentsOperations operations :vartype deployments: azure.mgmt.resource.resources.v2016_02_01.operations.DeploymentsOperations - :ivar providers: Providers operations + :ivar providers: ProvidersOperations operations :vartype providers: azure.mgmt.resource.resources.v2016_02_01.operations.ProvidersOperations - :ivar resource_groups: ResourceGroups operations + :ivar resource_groups: ResourceGroupsOperations operations :vartype resource_groups: azure.mgmt.resource.resources.v2016_02_01.operations.ResourceGroupsOperations - :ivar resources: Resources operations + :ivar resources: ResourcesOperations operations :vartype resources: azure.mgmt.resource.resources.v2016_02_01.operations.ResourcesOperations - :ivar tags: Tags operations + :ivar tags: TagsOperations operations :vartype tags: azure.mgmt.resource.resources.v2016_02_01.operations.TagsOperations - :ivar deployment_operations: DeploymentOperations operations - :vartype deployment_operations: azure.mgmt.resource.resources.v2016_02_01.operations.DeploymentOperations - - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` + :ivar deployment_operations: DeploymentOperationsOperations operations + :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. """ def __init__( - self, credentials, subscription_id, base_url=None): - - self.config = ResourceManagementClientConfiguration(credentials, subscription_id, base_url) - super(ResourceManagementClient, self).__init__(self.config.credentials, self.config) + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = 'https://management.azure.com' + self._config = ResourceManagementClientConfiguration(credential, 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.api_version = '2016-02-01' self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self.deployments = DeploymentsOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.providers = ProvidersOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.resource_groups = ResourceGroupsOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.resources = ResourcesOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.tags = TagsOperations( - self._client, self.config, self._serialize, self._deserialize) - self.deployment_operations = DeploymentOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) + self.deployment_operations = DeploymentOperationsOperations( + self._client, self._config, self._serialize, self._deserialize) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> ResourceManagementClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) 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 new file mode 100644 index 000000000000..7f9b1bac71c5 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/__init__.py @@ -0,0 +1,10 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._resource_management_client_async import ResourceManagementClient +__all__ = ['ResourceManagementClient'] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/_configuration_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/_configuration_async.py new file mode 100644 index 000000000000..de88392806ed --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/_configuration_async.py @@ -0,0 +1,65 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + +VERSION = "unknown" + +class ResourceManagementClientConfiguration(Configuration): + """Configuration for ResourceManagementClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :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 + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + 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 + self.api_version = "2016-02-01" + self.credential_scopes = ['https://management.azure.com/.default'] + self.credential_scopes.extend(kwargs.pop('credential_scopes', [])) + kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs: Any + ) -> None: + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + 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) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/_resource_management_client_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/_resource_management_client_async.py new file mode 100644 index 000000000000..5daee070d5b7 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/_resource_management_client_async.py @@ -0,0 +1,84 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, Optional + +from azure.mgmt.core import AsyncARMPipelineClient +from msrest import Deserializer, Serializer + +from ._configuration_async import ResourceManagementClientConfiguration +from .operations_async import DeploymentsOperations +from .operations_async import ProvidersOperations +from .operations_async import ResourceGroupsOperations +from .operations_async import ResourcesOperations +from .operations_async import TagsOperations +from .operations_async import DeploymentOperationsOperations +from .. import models + + +class ResourceManagementClient(object): + """ResourceManagementClient. + + :ivar deployments: DeploymentsOperations operations + :vartype deployments: azure.mgmt.resource.resources.v2016_02_01.aio.operations_async.DeploymentsOperations + :ivar providers: ProvidersOperations operations + :vartype providers: azure.mgmt.resource.resources.v2016_02_01.aio.operations_async.ProvidersOperations + :ivar resource_groups: ResourceGroupsOperations operations + :vartype resource_groups: azure.mgmt.resource.resources.v2016_02_01.aio.operations_async.ResourceGroupsOperations + :ivar resources: ResourcesOperations operations + :vartype resources: azure.mgmt.resource.resources.v2016_02_01.aio.operations_async.ResourcesOperations + :ivar tags: TagsOperations operations + :vartype tags: azure.mgmt.resource.resources.v2016_02_01.aio.operations_async.TagsOperations + :ivar deployment_operations: DeploymentOperationsOperations operations + :vartype deployment_operations: azure.mgmt.resource.resources.v2016_02_01.aio.operations_async.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. + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: Optional[str] = None, + **kwargs: 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) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + + self.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 close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "ResourceManagementClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/operations_async/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/operations_async/__init__.py new file mode 100644 index 000000000000..443d3be2d8df --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/operations_async/__init__.py @@ -0,0 +1,23 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._deployments_operations_async import DeploymentsOperations +from ._providers_operations_async import ProvidersOperations +from ._resource_groups_operations_async import ResourceGroupsOperations +from ._resources_operations_async import ResourcesOperations +from ._tags_operations_async import TagsOperations +from ._deployment_operations_operations_async import DeploymentOperationsOperations + +__all__ = [ + 'DeploymentsOperations', + 'ProvidersOperations', + 'ResourceGroupsOperations', + 'ResourcesOperations', + 'TagsOperations', + 'DeploymentOperationsOperations', +] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/operations_async/_deployment_operations_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/operations_async/_deployment_operations_operations_async.py new file mode 100644 index 000000000000..f6e9ba09e59c --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/operations_async/_deployment_operations_operations_async.py @@ -0,0 +1,178 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import 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 ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class DeploymentOperationsOperations: + """DeploymentOperationsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2016_02_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def get( + self, + resource_group_name: str, + deployment_name: str, + operation_id: str, + **kwargs + ) -> "models.DeploymentOperation": + """Get a list of deployments operations. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param operation_id: Operation Id. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentOperation or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentOperation + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentOperation"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-02-01" + + # Construct URL + url = self.get.metadata['url'] # type: 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentOperation', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + def list( + self, + resource_group_name: str, + deployment_name: str, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.DeploymentOperationsListResult"]: + """Gets a list of deployments operations. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-02-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentOperationsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/operations_async/_deployments_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/operations_async/_deployments_operations_async.py new file mode 100644 index 000000000000..b7f899e8100e --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/operations_async/_deployments_operations_async.py @@ -0,0 +1,661 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.polling import AsyncNoPolling, AsyncPollingMethod, async_poller +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class DeploymentsOperations: + """DeploymentsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2016_02_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def _delete_initial( + self, + resource_group_name: str, + deployment_name: str, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def delete( + self, + resource_group_name: str, + deployment_name: str, + **kwargs + ) -> None: + """Delete deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment to be deleted. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def check_existence( + self, + resource_group_name: str, + deployment_name: str, + **kwargs + ) -> None: + """Checks whether deployment exists. + + :param resource_group_name: The name of the resource group to check. The name is case + insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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] + + # Construct and send request + 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 + + if response.status_code not in [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + 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, + deployment_name: str, + properties: Optional["models.DeploymentProperties"] = None, + **kwargs + ) -> "models.DeploymentExtended": + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.Deployment(properties=properties) + api_version = "2016-02-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def create_or_update( + self, + resource_group_name: str, + deployment_name: str, + properties: Optional["models.DeploymentProperties"] = None, + **kwargs + ) -> "models.DeploymentExtended": + """Create a named template deployment using a template. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param properties: The deployment properties. + :type properties: ~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentProperties + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: DeploymentExtended + :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentExtended + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + properties=properties, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def get( + self, + resource_group_name: str, + deployment_name: str, + **kwargs + ) -> "models.DeploymentExtended": + """Get a deployment. + + :param resource_group_name: The name of the resource group to get. The name is case + insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExtended or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentExtended + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-02-01" + + # Construct URL + url = self.get.metadata['url'] # type: 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def cancel( + self, + resource_group_name: str, + deployment_name: str, + **kwargs + ) -> None: + """Cancel a currently running template deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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] + + # Construct and send request + 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 [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + cancel.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + + async def validate( + self, + resource_group_name: str, + deployment_name: str, + properties: Optional["models.DeploymentProperties"] = None, + **kwargs + ) -> "models.DeploymentValidateResult": + """Validate a deployment template. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param properties: The deployment properties. + :type properties: ~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentProperties + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentValidateResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentValidateResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.Deployment(properties=properties) + api_version = "2016-02-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 400]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + + if response.status_code == 400: + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + validate.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + async def export_template( + self, + resource_group_name: str, + deployment_name: str, + **kwargs + ) -> "models.DeploymentExportResult": + """Exports a deployment template. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentExportResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExportResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-02-01" + + # 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'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + def list( + self, + resource_group_name: str, + filter: Optional[str] = None, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.DeploymentListResult"]: + """Get a list of deployments. + + :param resource_group_name: The name of the resource group to filter by. The name is case + insensitive. + :type resource_group_name: str + :param filter: The filter to apply on the operation. + :type filter: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-02-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/'} # type: ignore + + async def calculate_template_hash( + self, + template: object, + **kwargs + ) -> "models.TemplateHashResult": + """Calculate the hash of the given template. + + :param template: The template provided to calculate hash. + :type template: object + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateHashResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.TemplateHashResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TemplateHashResult"] + error_map = {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.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'] = 'application/json' + + # Construct and send request + 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) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('TemplateHashResult', pipeline_response) + + if cls: + 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_async/_providers_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/operations_async/_providers_operations_async.py new file mode 100644 index 000000000000..314878ebba98 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/operations_async/_providers_operations_async.py @@ -0,0 +1,278 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import 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 ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ProvidersOperations: + """ProvidersOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2016_02_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def unregister( + self, + resource_provider_namespace: str, + **kwargs + ) -> "models.Provider": + """Unregisters provider from a subscription. + + :param resource_provider_namespace: Namespace of the resource provider. + :type resource_provider_namespace: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Provider or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.Provider + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Provider"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-02-01" + + # 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'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Provider', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + unregister.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister'} # type: ignore + + async def register( + self, + resource_provider_namespace: str, + **kwargs + ) -> "models.Provider": + """Registers provider to be used with a subscription. + + :param resource_provider_namespace: Namespace of the resource provider. + :type resource_provider_namespace: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Provider or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.Provider + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Provider"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-02-01" + + # 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'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Provider', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + register.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register'} # type: ignore + + def list( + self, + top: Optional[int] = None, + expand: Optional[str] = None, + **kwargs + ) -> AsyncIterable["models.ProviderListResult"]: + """Gets a list of resource providers. + + :param top: Query parameters. If null is passed returns all deployments. + :type top: int + :param expand: The $expand query parameter. e.g. To include property aliases in response, use + $expand=resourceTypes/aliases. + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of ProviderListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-02-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ProviderListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers'} # type: ignore + + async def get( + self, + resource_provider_namespace: str, + expand: Optional[str] = None, + **kwargs + ) -> "models.Provider": + """Gets a resource provider. + + :param resource_provider_namespace: Namespace of the resource provider. + :type resource_provider_namespace: str + :param expand: The $expand query parameter. e.g. To include property aliases in response, use + $expand=resourceTypes/aliases. + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Provider or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.Provider + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Provider"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-02-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Provider', pipeline_response) + + if cls: + 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_async/_resource_groups_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/operations_async/_resource_groups_operations_async.py new file mode 100644 index 000000000000..e29f42d9bcd9 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/operations_async/_resource_groups_operations_async.py @@ -0,0 +1,582 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, List, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.polling import AsyncNoPolling, AsyncPollingMethod, async_poller +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ResourceGroupsOperations: + """ResourceGroupsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2016_02_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list_resources( + self, + resource_group_name: str, + filter: Optional[str] = None, + expand: Optional[str] = None, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.ResourceListResult"]: + """Get all of the resources under a subscription. + + :param resource_group_name: Query parameters. If null is passed returns all resource groups. + :type resource_group_name: str + :param filter: The filter to apply on the operation. + :type filter: str + :param expand: Comma-separated list of additional properties to be included in the response. + Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, + ``$expand=createdTime,changedTime``. + :type expand: str + :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 ResourceListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-02-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ResourceListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources'} # type: ignore + + async def check_existence( + self, + resource_group_name: str, + **kwargs + ) -> None: + """Checks whether resource group exists. + + :param resource_group_name: The name of the resource group to check. 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: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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] + + # Construct and send request + 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 + + if response.status_code not in [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + async def create_or_update( + self, + resource_group_name: str, + parameters: "models.ResourceGroup", + **kwargs + ) -> "models.ResourceGroup": + """Create a resource group. + + :param resource_group_name: The name of the resource group to be created or updated. + :type resource_group_name: str + :param parameters: Parameters supplied to the create or update resource group service + operation. + :type parameters: ~azure.mgmt.resource.resources.v2016_02_01.models.ResourceGroup + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.ResourceGroup + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceGroup"] + error_map = {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.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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ResourceGroup', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ResourceGroup', pipeline_response) + + if cls: + 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, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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] + + # Construct and send request + 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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + async def delete( + self, + resource_group_name: str, + **kwargs + ) -> None: + """Delete resource group. + + :param resource_group_name: The name of the resource group to be deleted. 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 + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + async def get( + self, + resource_group_name: str, + **kwargs + ) -> "models.ResourceGroup": + """Get a resource group. + + :param resource_group_name: The name of the resource group to get. 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: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.ResourceGroup + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceGroup"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-02-01" + + # Construct URL + url = self.get.metadata['url'] # type: 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ResourceGroup', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + async def patch( + self, + resource_group_name: str, + parameters: "models.ResourceGroup", + **kwargs + ) -> "models.ResourceGroup": + """Resource groups can be updated through a simple PATCH operation to a group address. The format of the request is the same as that for creating a resource groups, though if a field is unspecified current value will be carried over. + + :param resource_group_name: The name of the resource group to be created or updated. The name + is case insensitive. + :type resource_group_name: str + :param parameters: Parameters supplied to the update state resource group service operation. + :type parameters: ~azure.mgmt.resource.resources.v2016_02_01.models.ResourceGroup + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.ResourceGroup + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceGroup"] + error_map = {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.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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ResourceGroup', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + patch.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + async def export_template( + self, + resource_group_name: str, + resources: Optional[List[str]] = None, + options: Optional[str] = None, + **kwargs + ) -> "models.ResourceGroupExportResult": + """Captures the specified resource group as a template. + + :param resource_group_name: The name of the resource group to be created or updated. + :type resource_group_name: str + :param 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', + 'SkipResourceNameParameterization', 'SkipAllParameterization'. + :type options: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroupExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.ResourceGroupExportResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceGroupExportResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.ExportTemplateRequest(resources=resources, options=options) + api_version = "2016-02-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ResourceGroupExportResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate'} # type: ignore + + def list( + self, + filter: Optional[str] = None, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.ResourceGroupListResult"]: + """Gets a collection of resource groups. + + :param filter: The filter to apply on the operation. + :type filter: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-02-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ResourceGroupListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/operations_async/_resources_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/operations_async/_resources_operations_async.py new file mode 100644 index 000000000000..4edaaefd281c --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/operations_async/_resources_operations_async.py @@ -0,0 +1,624 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, List, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.polling import AsyncNoPolling, AsyncPollingMethod, async_poller +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ResourcesOperations: + """ResourcesOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2016_02_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def _move_resources_initial( + self, + source_resource_group_name: str, + resources: Optional[List[str]] = None, + target_resource_group: Optional[str] = None, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.ResourcesMoveInfo(resources=resources, target_resource_group=target_resource_group) + 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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + + # Construct and send request + 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 + + if response.status_code not in [202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore + + async def move_resources( + self, + source_resource_group_name: str, + resources: Optional[List[str]] = None, + target_resource_group: Optional[str] = None, + **kwargs + ) -> None: + """Move resources from one resource group to another. The resources being moved should all be in the same resource group. + + :param source_resource_group_name: Source resource group name. + :type source_resource_group_name: str + :param resources: The ids of the resources. + :type resources: list[str] + :param target_resource_group: The target resource group. + :type target_resource_group: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._move_resources_initial( + source_resource_group_name=source_resource_group_name, + resources=resources, + target_resource_group=target_resource_group, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore + + def list( + self, + filter: Optional[str] = None, + expand: Optional[str] = None, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.ResourceListResult"]: + """Get all of the resources under a subscription. + + :param filter: The filter to apply on the operation. + :type filter: str + :param expand: Comma-separated list of additional properties to be included in the response. + Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, + ``$expand=createdTime,changedTime``. + :type expand: str + :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 ResourceListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-02-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ResourceListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resources'} # type: ignore + + async def check_existence( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + **kwargs + ) -> None: + """Checks whether resource exists. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param resource_provider_namespace: Resource identity. + :type resource_provider_namespace: str + :param parent_resource_path: Resource identity. + :type parent_resource_path: str + :param resource_type: Resource identity. + :type resource_type: str + :param resource_name: Resource identity. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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\._\(\)]+$'), + 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), + 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_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] + + # Construct and send request + 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 + + if response.status_code not in [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + async def delete( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + **kwargs + ) -> None: + """Delete resource and all of its resources. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param resource_provider_namespace: Resource identity. + :type resource_provider_namespace: str + :param parent_resource_path: Resource identity. + :type parent_resource_path: str + :param resource_type: Resource identity. + :type resource_type: str + :param resource_name: Resource identity. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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 = { + '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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + async def create_or_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + parameters: "models.GenericResource", + **kwargs + ) -> "models.GenericResource": + """Create a resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param resource_provider_namespace: Resource identity. + :type resource_provider_namespace: str + :param parent_resource_path: Resource identity. + :type parent_resource_path: str + :param resource_type: Resource identity. + :type resource_type: str + :param resource_name: Resource identity. + :type resource_name: str + :param parameters: Create or update resource parameters. + :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 + :return: GenericResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.GenericResource + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {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.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'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('GenericResource', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + 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, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + parameters: "models.GenericResource", + **kwargs + ) -> "models.GenericResource": + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {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._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'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + async def update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + parameters: "models.GenericResource", + **kwargs + ) -> "models.GenericResource": + """Updates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to update. + :type resource_type: str + :param resource_name: The name of the resource to update. + :type resource_name: str + :param parameters: Parameters for updating the resource. + :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 polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: GenericResource + :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.GenericResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._update_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, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + async def get( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + **kwargs + ) -> "models.GenericResource": + """Returns a resource belonging to a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param resource_provider_namespace: Resource identity. + :type resource_provider_namespace: str + :param parent_resource_path: Resource identity. + :type parent_resource_path: str + :param resource_type: Resource identity. + :type resource_type: str + :param resource_name: Resource identity. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GenericResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.GenericResource + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-02-01" + + # Construct URL + url = self.get.metadata['url'] # type: 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + 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_async/_tags_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/operations_async/_tags_operations_async.py new file mode 100644 index 000000000000..87781c0109f1 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/aio/operations_async/_tags_operations_async.py @@ -0,0 +1,323 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import 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 ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class TagsOperations: + """TagsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2016_02_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def delete_value( + self, + tag_name: str, + tag_value: str, + **kwargs + ) -> None: + """Delete a subscription resource tag value. + + :param tag_name: The name of the tag. + :type tag_name: str + :param tag_value: The value of the tag. + :type tag_value: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore + + async def create_or_update_value( + self, + tag_name: str, + tag_value: str, + **kwargs + ) -> "models.TagValue": + """Create a subscription resource tag value. + + :param tag_name: The name of the tag. + :type tag_name: str + :param tag_value: The value of the tag. + :type tag_value: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagValue or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.TagValue + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TagValue"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-02-01" + + # 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'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('TagValue', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('TagValue', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore + + async def create_or_update( + self, + tag_name: str, + **kwargs + ) -> "models.TagDetails": + """Create a subscription resource tag. + + :param tag_name: The name of the tag. + :type tag_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagDetails or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.TagDetails + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TagDetails"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-02-01" + + # 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'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('TagDetails', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('TagDetails', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore + + async def delete( + self, + tag_name: str, + **kwargs + ) -> None: + """Delete a subscription resource tag. + + :param tag_name: The name of the tag. + :type tag_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore + + def list( + self, + **kwargs + ) -> AsyncIterable["models.TagsListResult"]: + """Get a list of subscription resource tags. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of TagsListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-02-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('TagsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/models/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/models/__init__.py index ef78f45062ce..0fa0b4f5f587 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/models/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/models/__init__.py @@ -1,12 +1,9 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- try: @@ -19,8 +16,10 @@ from ._models_py3 import DeploymentExportResult from ._models_py3 import DeploymentExtended from ._models_py3 import DeploymentExtendedFilter + from ._models_py3 import DeploymentListResult from ._models_py3 import DeploymentOperation from ._models_py3 import DeploymentOperationProperties + from ._models_py3 import DeploymentOperationsListResult from ._models_py3 import DeploymentProperties from ._models_py3 import DeploymentPropertiesExtended from ._models_py3 import DeploymentValidateResult @@ -35,12 +34,15 @@ from ._models_py3 import ParametersLink from ._models_py3 import Plan from ._models_py3 import Provider + from ._models_py3 import ProviderListResult from ._models_py3 import ProviderResourceType from ._models_py3 import Resource from ._models_py3 import ResourceGroup from ._models_py3 import ResourceGroupExportResult from ._models_py3 import ResourceGroupFilter + from ._models_py3 import ResourceGroupListResult from ._models_py3 import ResourceGroupProperties + from ._models_py3 import ResourceListResult from ._models_py3 import ResourceManagementErrorWithDetails from ._models_py3 import ResourceProviderOperationDisplayProperties from ._models_py3 import ResourcesMoveInfo @@ -49,61 +51,62 @@ from ._models_py3 import TagCount from ._models_py3 import TagDetails from ._models_py3 import TagValue + from ._models_py3 import TagsListResult from ._models_py3 import TargetResource from ._models_py3 import TemplateHashResult from ._models_py3 import TemplateLink except (SyntaxError, ImportError): - from ._models import AliasPathType - from ._models import AliasType - from ._models import BasicDependency - from ._models import DebugSetting - from ._models import Dependency - from ._models import Deployment - from ._models import DeploymentExportResult - from ._models import DeploymentExtended - from ._models import DeploymentExtendedFilter - from ._models import DeploymentOperation - from ._models import DeploymentOperationProperties - from ._models import DeploymentProperties - from ._models import DeploymentPropertiesExtended - from ._models import DeploymentValidateResult - from ._models import ErrorAdditionalInfo - from ._models import ErrorResponse - from ._models import ExportTemplateRequest - from ._models import GenericResource - from ._models import GenericResourceExpanded - from ._models import GenericResourceFilter - from ._models import HttpMessage - from ._models import Identity - from ._models import ParametersLink - from ._models import Plan - from ._models import Provider - from ._models import ProviderResourceType - from ._models import Resource - from ._models import ResourceGroup - from ._models import ResourceGroupExportResult - from ._models import ResourceGroupFilter - from ._models import ResourceGroupProperties - from ._models import ResourceManagementErrorWithDetails - from ._models import ResourceProviderOperationDisplayProperties - from ._models import ResourcesMoveInfo - from ._models import Sku - from ._models import SubResource - from ._models import TagCount - from ._models import TagDetails - from ._models import TagValue - from ._models import TargetResource - from ._models import TemplateHashResult - from ._models import TemplateLink -from ._paged_models import DeploymentExtendedPaged -from ._paged_models import DeploymentOperationPaged -from ._paged_models import GenericResourceExpandedPaged -from ._paged_models import ProviderPaged -from ._paged_models import ResourceGroupPaged -from ._paged_models import TagDetailsPaged + from ._models import AliasPathType # type: ignore + from ._models import AliasType # type: ignore + from ._models import BasicDependency # type: ignore + from ._models import DebugSetting # type: ignore + from ._models import Dependency # type: ignore + from ._models import Deployment # type: ignore + from ._models import DeploymentExportResult # type: ignore + from ._models import DeploymentExtended # type: ignore + from ._models import DeploymentExtendedFilter # type: ignore + from ._models import DeploymentListResult # type: ignore + from ._models import DeploymentOperation # type: ignore + from ._models import DeploymentOperationProperties # type: ignore + from ._models import DeploymentOperationsListResult # type: ignore + from ._models import DeploymentProperties # type: ignore + from ._models import DeploymentPropertiesExtended # type: ignore + from ._models import DeploymentValidateResult # type: ignore + from ._models import ErrorAdditionalInfo # type: ignore + from ._models import ErrorResponse # type: ignore + from ._models import ExportTemplateRequest # type: ignore + from ._models import GenericResource # type: ignore + from ._models import GenericResourceExpanded # type: ignore + from ._models import GenericResourceFilter # type: ignore + from ._models import HttpMessage # type: ignore + from ._models import Identity # type: ignore + from ._models import ParametersLink # type: ignore + from ._models import Plan # type: ignore + from ._models import Provider # type: ignore + from ._models import ProviderListResult # type: ignore + from ._models import ProviderResourceType # type: ignore + from ._models import Resource # type: ignore + from ._models import ResourceGroup # type: ignore + from ._models import ResourceGroupExportResult # type: ignore + from ._models import ResourceGroupFilter # type: ignore + from ._models import ResourceGroupListResult # type: ignore + from ._models import ResourceGroupProperties # type: ignore + from ._models import ResourceListResult # type: ignore + from ._models import ResourceManagementErrorWithDetails # type: ignore + from ._models import ResourceProviderOperationDisplayProperties # type: ignore + from ._models import ResourcesMoveInfo # type: ignore + from ._models import Sku # type: ignore + from ._models import SubResource # type: ignore + from ._models import TagCount # type: ignore + from ._models import TagDetails # type: ignore + from ._models import TagValue # type: ignore + from ._models import TagsListResult # type: ignore + from ._models import TargetResource # type: ignore + from ._models import TemplateHashResult # type: ignore + from ._models import TemplateLink # type: ignore + from ._resource_management_client_enums import ( DeploymentMode, - ResourceIdentityType, ) __all__ = [ @@ -116,8 +119,10 @@ 'DeploymentExportResult', 'DeploymentExtended', 'DeploymentExtendedFilter', + 'DeploymentListResult', 'DeploymentOperation', 'DeploymentOperationProperties', + 'DeploymentOperationsListResult', 'DeploymentProperties', 'DeploymentPropertiesExtended', 'DeploymentValidateResult', @@ -132,12 +137,15 @@ 'ParametersLink', 'Plan', 'Provider', + 'ProviderListResult', 'ProviderResourceType', 'Resource', 'ResourceGroup', 'ResourceGroupExportResult', 'ResourceGroupFilter', + 'ResourceGroupListResult', 'ResourceGroupProperties', + 'ResourceListResult', 'ResourceManagementErrorWithDetails', 'ResourceProviderOperationDisplayProperties', 'ResourcesMoveInfo', @@ -146,15 +154,9 @@ 'TagCount', 'TagDetails', 'TagValue', + 'TagsListResult', 'TargetResource', 'TemplateHashResult', 'TemplateLink', - 'DeploymentExtendedPaged', - 'ProviderPaged', - 'GenericResourceExpandedPaged', - 'ResourceGroupPaged', - 'TagDetailsPaged', - 'DeploymentOperationPaged', 'DeploymentMode', - 'ResourceIdentityType', ] 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 b15fbf263556..61a465147949 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 @@ -1,19 +1,15 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.serialization import Model -from msrest.exceptions import HttpOperationError +import msrest.serialization -class AliasPathType(Model): +class AliasPathType(msrest.serialization.Model): """AliasPathType. :param path: The path of an alias. @@ -27,20 +23,22 @@ class AliasPathType(Model): 'api_versions': {'key': 'apiVersions', 'type': '[str]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(AliasPathType, self).__init__(**kwargs) self.path = kwargs.get('path', None) self.api_versions = kwargs.get('api_versions', None) -class AliasType(Model): +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] + :type paths: list[~azure.mgmt.resource.resources.v2016_02_01.models.AliasPathType] """ _attribute_map = { @@ -48,13 +46,16 @@ class AliasType(Model): 'paths': {'key': 'paths', 'type': '[AliasPathType]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(AliasType, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.paths = kwargs.get('paths', None) -class BasicDependency(Model): +class BasicDependency(msrest.serialization.Model): """Deployment dependency information. :param id: The ID of the dependency. @@ -71,43 +72,17 @@ class BasicDependency(Model): 'resource_name': {'key': 'resourceName', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(BasicDependency, self).__init__(**kwargs) self.id = kwargs.get('id', None) self.resource_type = kwargs.get('resource_type', None) self.resource_name = kwargs.get('resource_name', None) -class CloudError(Model): - """An error response for a resource management request. - - :param error: - :type error: - ~azure.mgmt.resource.resources.v2016_02_01.models.ErrorResponse - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorResponse'}, - } - - def __init__(self, **kwargs): - super(CloudError, self).__init__(**kwargs) - self.error = kwargs.get('error', None) - - -class CloudErrorException(HttpOperationError): - """Server responsed with exception of type: 'CloudError'. - - :param deserialize: A deserializer - :param response: Server response to be deserialized. - """ - - def __init__(self, deserialize, response, *args): - - super(CloudErrorException, self).__init__(deserialize, response, 'CloudError', *args) - - -class DebugSetting(Model): +class DebugSetting(msrest.serialization.Model): """DebugSetting. :param detail_level: The debug detail level. @@ -118,17 +93,19 @@ class DebugSetting(Model): 'detail_level': {'key': 'detailLevel', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DebugSetting, self).__init__(**kwargs) self.detail_level = kwargs.get('detail_level', None) -class Dependency(Model): +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] + :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. @@ -144,7 +121,10 @@ class Dependency(Model): 'resource_name': {'key': 'resourceName', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Dependency, self).__init__(**kwargs) self.depends_on = kwargs.get('depends_on', None) self.id = kwargs.get('id', None) @@ -152,24 +132,26 @@ def __init__(self, **kwargs): self.resource_name = kwargs.get('resource_name', None) -class Deployment(Model): +class Deployment(msrest.serialization.Model): """Deployment operation parameters. :param properties: The deployment properties. - :type properties: - ~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentProperties + :type properties: ~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentProperties """ _attribute_map = { 'properties': {'key': 'properties', 'type': 'DeploymentProperties'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Deployment, self).__init__(**kwargs) self.properties = kwargs.get('properties', None) -class DeploymentExportResult(Model): +class DeploymentExportResult(msrest.serialization.Model): """DeploymentExportResult. :param template: The template content. @@ -180,16 +162,18 @@ class DeploymentExportResult(Model): 'template': {'key': 'template', 'type': 'object'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentExportResult, self).__init__(**kwargs) self.template = kwargs.get('template', None) -class DeploymentExtended(Model): +class DeploymentExtended(msrest.serialization.Model): """Deployment information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. @@ -213,14 +197,17 @@ class DeploymentExtended(Model): 'properties': {'key': 'properties', 'type': 'DeploymentPropertiesExtended'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentExtended, self).__init__(**kwargs) self.id = None - self.name = kwargs.get('name', None) + self.name = kwargs['name'] self.properties = kwargs.get('properties', None) -class DeploymentExtendedFilter(Model): +class DeploymentExtendedFilter(msrest.serialization.Model): """Deployment filter. :param provisioning_state: The provisioning state. @@ -231,12 +218,38 @@ class DeploymentExtendedFilter(Model): 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentExtendedFilter, self).__init__(**kwargs) self.provisioning_state = kwargs.get('provisioning_state', None) -class DeploymentOperation(Model): +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 + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[DeploymentExtended]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(DeploymentListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class DeploymentOperation(msrest.serialization.Model): """Deployment operation information. :param id: Full deployment operation id. @@ -254,20 +267,23 @@ class DeploymentOperation(Model): 'properties': {'key': 'properties', 'type': 'DeploymentOperationProperties'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentOperation, self).__init__(**kwargs) self.id = kwargs.get('id', None) self.operation_id = kwargs.get('operation_id', None) self.properties = kwargs.get('properties', None) -class DeploymentOperationProperties(Model): +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 + :type timestamp: ~datetime.datetime :param service_request_id: Deployment operation service request id. :type service_request_id: str :param status_code: Operation status code. @@ -275,14 +291,11 @@ class DeploymentOperationProperties(Model): :param status_message: Operation status message. :type status_message: object :param target_resource: The target resource. - :type target_resource: - ~azure.mgmt.resource.resources.v2016_02_01.models.TargetResource + :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 + :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 + :type response: ~azure.mgmt.resource.resources.v2016_02_01.models.HttpMessage """ _attribute_map = { @@ -296,7 +309,10 @@ class DeploymentOperationProperties(Model): 'response': {'key': 'response', 'type': 'HttpMessage'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentOperationProperties, self).__init__(**kwargs) self.provisioning_state = kwargs.get('provisioning_state', None) self.timestamp = kwargs.get('timestamp', None) @@ -308,32 +324,48 @@ def __init__(self, **kwargs): self.response = kwargs.get('response', None) -class DeploymentProperties(Model): +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 + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[DeploymentOperation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(DeploymentOperationsListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class DeploymentProperties(msrest.serialization.Model): """Deployment properties. 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 only one of Template or TemplateLink. + :param template: The template content. It can be a JObject or a well formed JSON string. Use + only one of Template or TemplateLink. :type template: object - :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 only one of Parameters or ParametersLink. + :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 + only one of Parameters or ParametersLink. :type parameters: object - :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 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 + :type debug_setting: ~azure.mgmt.resource.resources.v2016_02_01.models.DebugSetting """ _validation = { @@ -345,21 +377,24 @@ class DeploymentProperties(Model): 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, 'parameters': {'key': 'parameters', 'type': 'object'}, 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, - 'mode': {'key': 'mode', 'type': 'DeploymentMode'}, + 'mode': {'key': 'mode', 'type': 'str'}, 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentProperties, self).__init__(**kwargs) self.template = kwargs.get('template', None) self.template_link = kwargs.get('template_link', None) self.parameters = kwargs.get('parameters', None) self.parameters_link = kwargs.get('parameters_link', None) - self.mode = kwargs.get('mode', None) + self.mode = kwargs['mode'] self.debug_setting = kwargs.get('debug_setting', None) -class DeploymentPropertiesExtended(Model): +class DeploymentPropertiesExtended(msrest.serialization.Model): """Deployment properties with additional details. :param provisioning_state: The state of the provisioning. @@ -367,37 +402,27 @@ class DeploymentPropertiesExtended(Model): :param correlation_id: The correlation ID of the deployment. :type correlation_id: str :param timestamp: The timestamp of the template deployment. - :type timestamp: datetime + :type timestamp: ~datetime.datetime :param outputs: Key/value pairs that represent deployment output. :type outputs: object - :param providers: The list of resource providers needed for the - deployment. - :type providers: - list[~azure.mgmt.resource.resources.v2016_02_01.models.Provider] + :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 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: object - :param 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. + :param 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: object - :param 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 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 + :type debug_setting: ~azure.mgmt.resource.resources.v2016_02_01.models.DebugSetting """ _attribute_map = { @@ -411,11 +436,14 @@ class DeploymentPropertiesExtended(Model): 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, 'parameters': {'key': 'parameters', 'type': 'object'}, 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, - 'mode': {'key': 'mode', 'type': 'DeploymentMode'}, + 'mode': {'key': 'mode', 'type': 'str'}, 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentPropertiesExtended, self).__init__(**kwargs) self.provisioning_state = kwargs.get('provisioning_state', None) self.correlation_id = kwargs.get('correlation_id', None) @@ -431,7 +459,7 @@ def __init__(self, **kwargs): self.debug_setting = kwargs.get('debug_setting', None) -class DeploymentValidateResult(Model): +class DeploymentValidateResult(msrest.serialization.Model): """Information from validate template deployment response. :param error: Validation error. @@ -447,17 +475,19 @@ class DeploymentValidateResult(Model): 'properties': {'key': 'properties', 'type': 'DeploymentPropertiesExtended'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentValidateResult, self).__init__(**kwargs) self.error = kwargs.get('error', None) self.properties = kwargs.get('properties', None) -class ErrorAdditionalInfo(Model): +class ErrorAdditionalInfo(msrest.serialization.Model): """The resource management error additional info. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar type: The additional info type. :vartype type: str @@ -475,17 +505,19 @@ class ErrorAdditionalInfo(Model): 'info': {'key': 'info', 'type': 'object'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None -class ErrorResponse(Model): +class ErrorResponse(msrest.serialization.Model): """The resource management error response. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar code: The error code. :vartype code: str @@ -494,8 +526,7 @@ class ErrorResponse(Model): :ivar target: The error target. :vartype target: str :ivar details: The error details. - :vartype details: - list[~azure.mgmt.resource.resources.v2016_02_01.models.ErrorResponse] + :vartype details: list[~azure.mgmt.resource.resources.v2016_02_01.models.ErrorResponse] :ivar additional_info: The error additional info. :vartype additional_info: list[~azure.mgmt.resource.resources.v2016_02_01.models.ErrorAdditionalInfo] @@ -517,7 +548,10 @@ class ErrorResponse(Model): 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ErrorResponse, self).__init__(**kwargs) self.code = None self.message = None @@ -526,16 +560,15 @@ def __init__(self, **kwargs): self.additional_info = None -class ExportTemplateRequest(Model): +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, supply an array with single entry '*'. + :param 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', 'SkipResourceNameParameterization', - 'SkipAllParameterization' + :param options: The export template options. A CSV-formatted list containing zero or more of + the following: 'IncludeParameterDefaultValue', 'IncludeComments', + 'SkipResourceNameParameterization', 'SkipAllParameterization'. :type options: str """ @@ -544,27 +577,29 @@ class ExportTemplateRequest(Model): 'options': {'key': 'options', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ExportTemplateRequest, self).__init__(**kwargs) self.resources = kwargs.get('resources', None) self.options = kwargs.get('options', None) -class Resource(Model): +class Resource(msrest.serialization.Model): """Resource. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource Id + :ivar id: Resource Id. :vartype id: str - :ivar name: Resource name + :ivar name: Resource name. :vartype name: str - :ivar type: Resource type + :ivar type: Resource type. :vartype type: str - :param location: Resource location + :param location: Resource location. :type location: str - :param tags: Resource tags + :param tags: A set of tags. Resource tags. :type tags: dict[str, str] """ @@ -582,7 +617,10 @@ class Resource(Model): 'tags': {'key': 'tags', 'type': '{str}'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -594,18 +632,17 @@ def __init__(self, **kwargs): class GenericResource(Resource): """Resource information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource Id + :ivar id: Resource Id. :vartype id: str - :ivar name: Resource name + :ivar name: Resource name. :vartype name: str - :ivar type: Resource type + :ivar type: Resource type. :vartype type: str - :param location: Resource location + :param location: Resource location. :type location: str - :param tags: Resource tags + :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 @@ -641,7 +678,10 @@ class GenericResource(Resource): 'identity': {'key': 'identity', 'type': 'Identity'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(GenericResource, self).__init__(**kwargs) self.plan = kwargs.get('plan', None) self.properties = kwargs.get('properties', None) @@ -654,18 +694,17 @@ def __init__(self, **kwargs): class GenericResourceExpanded(GenericResource): """Resource information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource Id + :ivar id: Resource Id. :vartype id: str - :ivar name: Resource name + :ivar name: Resource name. :vartype name: str - :ivar type: Resource type + :ivar type: Resource type. :vartype type: str - :param location: Resource location + :param location: Resource location. :type location: str - :param tags: Resource tags + :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 @@ -679,14 +718,14 @@ class GenericResourceExpanded(GenericResource): :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 created_time: The created time of the resource. This is only present - if requested via the $expand query parameter. - :vartype created_time: datetime - :ivar changed_time: The changed time of the resource. This is only present - if requested via the $expand query parameter. - :vartype changed_time: datetime - :ivar provisioning_state: The provisioning state of the resource. This is - only present if requested via the $expand query parameter. + :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 + :ivar changed_time: The changed time of the resource. This is only present if requested via the + $expand query parameter. + :vartype changed_time: ~datetime.datetime + :ivar provisioning_state: The provisioning state of the resource. This is only present if + requested via the $expand query parameter. :vartype provisioning_state: str """ @@ -716,14 +755,17 @@ class GenericResourceExpanded(GenericResource): 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(GenericResourceExpanded, self).__init__(**kwargs) self.created_time = None self.changed_time = None self.provisioning_state = None -class GenericResourceFilter(Model): +class GenericResourceFilter(msrest.serialization.Model): """Resource filter. :param resource_type: The resource type. @@ -740,14 +782,17 @@ class GenericResourceFilter(Model): 'tagvalue': {'key': 'tagvalue', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(GenericResourceFilter, self).__init__(**kwargs) self.resource_type = kwargs.get('resource_type', None) self.tagname = kwargs.get('tagname', None) self.tagvalue = kwargs.get('tagvalue', None) -class HttpMessage(Model): +class HttpMessage(msrest.serialization.Model): """HttpMessage. :param content: HTTP message content. @@ -758,53 +803,58 @@ class HttpMessage(Model): 'content': {'key': 'content', 'type': 'object'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(HttpMessage, self).__init__(**kwargs) self.content = kwargs.get('content', None) -class Identity(Model): +class Identity(msrest.serialization.Model): """Identity for the resource. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar principal_id: The principal id of resource identity. :vartype principal_id: str :ivar tenant_id: The tenant id of resource. :vartype tenant_id: str - :param type: The identity type. Possible values include: 'SystemAssigned' - :type type: str or - ~azure.mgmt.resource.resources.v2016_02_01.models.ResourceIdentityType + :ivar type: The identity type. Default value: "SystemAssigned". + :vartype type: str """ _validation = { 'principal_id': {'readonly': True}, 'tenant_id': {'readonly': True}, + 'type': {'constant': True}, } _attribute_map = { 'principal_id': {'key': 'principalId', 'type': 'str'}, 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'ResourceIdentityType'}, + 'type': {'key': 'type', 'type': 'str'}, } - def __init__(self, **kwargs): + type = "SystemAssigned" + + def __init__( + self, + **kwargs + ): super(Identity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None - self.type = kwargs.get('type', None) -class ParametersLink(Model): +class ParametersLink(msrest.serialization.Model): """Entity representing the reference to the deployment parameters. 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. + :param content_version: If included it must match the ContentVersion in the template. :type content_version: str """ @@ -817,13 +867,16 @@ class ParametersLink(Model): 'content_version': {'key': 'contentVersion', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ParametersLink, self).__init__(**kwargs) - self.uri = kwargs.get('uri', None) + self.uri = kwargs['uri'] self.content_version = kwargs.get('content_version', None) -class Plan(Model): +class Plan(msrest.serialization.Model): """Plan for the resource. :param name: The plan ID. @@ -843,7 +896,10 @@ class Plan(Model): 'promotion_code': {'key': 'promotionCode', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Plan, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.publisher = kwargs.get('publisher', None) @@ -851,7 +907,7 @@ def __init__(self, **kwargs): self.promotion_code = kwargs.get('promotion_code', None) -class Provider(Model): +class Provider(msrest.serialization.Model): """Resource provider information. :param id: The provider id. @@ -872,7 +928,10 @@ class Provider(Model): 'resource_types': {'key': 'resourceTypes', 'type': '[ProviderResourceType]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Provider, self).__init__(**kwargs) self.id = kwargs.get('id', None) self.namespace = kwargs.get('namespace', None) @@ -880,17 +939,38 @@ def __init__(self, **kwargs): self.resource_types = kwargs.get('resource_types', None) -class ProviderResourceType(Model): +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 + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Provider]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ProviderListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +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. + :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] + :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. @@ -905,7 +985,10 @@ class ProviderResourceType(Model): 'properties': {'key': 'properties', 'type': '{str}'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ProviderResourceType, self).__init__(**kwargs) self.resource_type = kwargs.get('resource_type', None) self.locations = kwargs.get('locations', None) @@ -914,11 +997,10 @@ def __init__(self, **kwargs): self.properties = kwargs.get('properties', None) -class ResourceGroup(Model): +class ResourceGroup(msrest.serialization.Model): """Resource group information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. @@ -926,15 +1008,13 @@ class ResourceGroup(Model): :vartype id: str :param name: The Name of the resource group. :type name: str - :param 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 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. + :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 + 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: The tags attached to the resource group. + :param tags: A set of tags. The tags attached to the resource group. :type tags: dict[str, str] """ @@ -951,16 +1031,19 @@ class ResourceGroup(Model): 'tags': {'key': 'tags', 'type': '{str}'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ResourceGroup, self).__init__(**kwargs) self.id = None self.name = kwargs.get('name', None) self.properties = kwargs.get('properties', None) - self.location = kwargs.get('location', None) + self.location = kwargs['location'] self.tags = kwargs.get('tags', None) -class ResourceGroupExportResult(Model): +class ResourceGroupExportResult(msrest.serialization.Model): """ResourceGroupExportResult. :param template: The template content. @@ -975,13 +1058,16 @@ class ResourceGroupExportResult(Model): 'error': {'key': 'error', 'type': 'ResourceManagementErrorWithDetails'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ResourceGroupExportResult, self).__init__(**kwargs) self.template = kwargs.get('template', None) self.error = kwargs.get('error', None) -class ResourceGroupFilter(Model): +class ResourceGroupFilter(msrest.serialization.Model): """Resource group filter. :param tag_name: The tag name. @@ -995,17 +1081,48 @@ class ResourceGroupFilter(Model): 'tag_value': {'key': 'tagValue', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ResourceGroupFilter, self).__init__(**kwargs) self.tag_name = kwargs.get('tag_name', None) self.tag_value = kwargs.get('tag_value', None) -class ResourceGroupProperties(Model): +class ResourceGroupListResult(msrest.serialization.Model): + """List of resource groups. + + 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 + """ + + _validation = { + 'next_link': {'required': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ResourceGroup]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ResourceGroupListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs['next_link'] + + +class ResourceGroupProperties(msrest.serialization.Model): """The resource group properties. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar provisioning_state: The provisioning state. :vartype provisioning_state: str @@ -1019,12 +1136,44 @@ class ResourceGroupProperties(Model): 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ResourceGroupProperties, self).__init__(**kwargs) self.provisioning_state = None -class ResourceManagementErrorWithDetails(Model): +class ResourceListResult(msrest.serialization.Model): + """List of resource groups. + + 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 + """ + + _validation = { + 'next_link': {'required': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[GenericResourceExpanded]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ResourceListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs['next_link'] + + +class ResourceManagementErrorWithDetails(msrest.serialization.Model): """ResourceManagementErrorWithDetails. All required parameters must be populated in order to send to Azure. @@ -1052,15 +1201,18 @@ class ResourceManagementErrorWithDetails(Model): 'details': {'key': 'details', 'type': '[ResourceManagementErrorWithDetails]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ResourceManagementErrorWithDetails, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) + self.code = kwargs['code'] + self.message = kwargs['message'] self.target = kwargs.get('target', None) self.details = kwargs.get('details', None) -class ResourceProviderOperationDisplayProperties(Model): +class ResourceProviderOperationDisplayProperties(msrest.serialization.Model): """Resource provider operation's display properties. :param publisher: Operation description. @@ -1083,7 +1235,10 @@ class ResourceProviderOperationDisplayProperties(Model): 'description': {'key': 'description', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ResourceProviderOperationDisplayProperties, self).__init__(**kwargs) self.publisher = kwargs.get('publisher', None) self.provider = kwargs.get('provider', None) @@ -1092,7 +1247,7 @@ def __init__(self, **kwargs): self.description = kwargs.get('description', None) -class ResourcesMoveInfo(Model): +class ResourcesMoveInfo(msrest.serialization.Model): """Parameters of move resources. :param resources: The ids of the resources. @@ -1106,13 +1261,16 @@ class ResourcesMoveInfo(Model): 'target_resource_group': {'key': 'targetResourceGroup', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ResourcesMoveInfo, self).__init__(**kwargs) self.resources = kwargs.get('resources', None) self.target_resource_group = kwargs.get('target_resource_group', None) -class Sku(Model): +class Sku(msrest.serialization.Model): """Sku for the resource. :param name: The sku name. @@ -1138,7 +1296,10 @@ class Sku(Model): 'capacity': {'key': 'capacity', 'type': 'int'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Sku, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.tier = kwargs.get('tier', None) @@ -1148,10 +1309,10 @@ def __init__(self, **kwargs): self.capacity = kwargs.get('capacity', None) -class SubResource(Model): +class SubResource(msrest.serialization.Model): """SubResource. - :param id: Resource Id + :param id: Resource Id. :type id: str """ @@ -1159,12 +1320,15 @@ class SubResource(Model): 'id': {'key': 'id', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(SubResource, self).__init__(**kwargs) self.id = kwargs.get('id', None) -class TagCount(Model): +class TagCount(msrest.serialization.Model): """Tag count. :param type: Type of count. @@ -1178,17 +1342,19 @@ class TagCount(Model): 'value': {'key': 'value', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(TagCount, self).__init__(**kwargs) self.type = kwargs.get('type', None) self.value = kwargs.get('value', None) -class TagDetails(Model): +class TagDetails(msrest.serialization.Model): """Tag details. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The tag ID. :vartype id: str @@ -1197,8 +1363,7 @@ class TagDetails(Model): :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] + :type values: list[~azure.mgmt.resource.resources.v2016_02_01.models.TagValue] """ _validation = { @@ -1212,7 +1377,10 @@ class TagDetails(Model): 'values': {'key': 'values', 'type': '[TagValue]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(TagDetails, self).__init__(**kwargs) self.id = None self.tag_name = kwargs.get('tag_name', None) @@ -1220,11 +1388,39 @@ def __init__(self, **kwargs): self.values = kwargs.get('values', None) -class TagValue(Model): +class TagsListResult(msrest.serialization.Model): + """List of subscription tags. + + 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 + """ + + _validation = { + 'next_link': {'required': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[TagDetails]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(TagsListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs['next_link'] + + +class TagValue(msrest.serialization.Model): """Tag information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The tag ID. :vartype id: str @@ -1244,14 +1440,17 @@ class TagValue(Model): 'count': {'key': 'count', 'type': 'TagCount'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(TagValue, self).__init__(**kwargs) self.id = None self.tag_value = kwargs.get('tag_value', None) self.count = kwargs.get('count', None) -class TargetResource(Model): +class TargetResource(msrest.serialization.Model): """Target resource. :param id: The ID of the resource. @@ -1268,16 +1467,18 @@ class TargetResource(Model): 'resource_type': {'key': 'resourceType', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(TargetResource, self).__init__(**kwargs) self.id = kwargs.get('id', None) self.resource_name = kwargs.get('resource_name', None) self.resource_type = kwargs.get('resource_type', None) -class TemplateHashResult(Model): - """Result of the request to calculate template hash. It contains a string of - minified template and its hash. +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 @@ -1290,21 +1491,23 @@ class TemplateHashResult(Model): 'template_hash': {'key': 'templateHash', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(TemplateHashResult, self).__init__(**kwargs) self.minified_template = kwargs.get('minified_template', None) self.template_hash = kwargs.get('template_hash', None) -class TemplateLink(Model): +class TemplateLink(msrest.serialization.Model): """Entity representing the reference to the template. 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. + :param content_version: If included it must match the ContentVersion in the template. :type content_version: str """ @@ -1317,7 +1520,10 @@ class TemplateLink(Model): 'content_version': {'key': 'contentVersion', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(TemplateLink, self).__init__(**kwargs) - self.uri = kwargs.get('uri', None) + 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 6acccb2d6013..edbf263a65b5 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 @@ -1,19 +1,20 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.serialization import Model -from msrest.exceptions import HttpOperationError +import datetime +from typing import Dict, List, Optional, Union +import msrest.serialization -class AliasPathType(Model): +from ._resource_management_client_enums import * + + +class AliasPathType(msrest.serialization.Model): """AliasPathType. :param path: The path of an alias. @@ -27,20 +28,25 @@ class AliasPathType(Model): 'api_versions': {'key': 'apiVersions', 'type': '[str]'}, } - def __init__(self, *, path: str=None, api_versions=None, **kwargs) -> None: + def __init__( + self, + *, + path: Optional[str] = None, + api_versions: Optional[List[str]] = None, + **kwargs + ): super(AliasPathType, self).__init__(**kwargs) self.path = path self.api_versions = api_versions -class AliasType(Model): +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] + :type paths: list[~azure.mgmt.resource.resources.v2016_02_01.models.AliasPathType] """ _attribute_map = { @@ -48,13 +54,19 @@ class AliasType(Model): 'paths': {'key': 'paths', 'type': '[AliasPathType]'}, } - def __init__(self, *, name: str=None, paths=None, **kwargs) -> None: + def __init__( + self, + *, + name: Optional[str] = None, + paths: Optional[List["AliasPathType"]] = None, + **kwargs + ): super(AliasType, self).__init__(**kwargs) self.name = name self.paths = paths -class BasicDependency(Model): +class BasicDependency(msrest.serialization.Model): """Deployment dependency information. :param id: The ID of the dependency. @@ -71,43 +83,21 @@ class BasicDependency(Model): 'resource_name': {'key': 'resourceName', 'type': 'str'}, } - def __init__(self, *, id: str=None, resource_type: str=None, resource_name: str=None, **kwargs) -> None: + def __init__( + self, + *, + id: Optional[str] = None, + resource_type: Optional[str] = None, + resource_name: Optional[str] = None, + **kwargs + ): super(BasicDependency, self).__init__(**kwargs) self.id = id self.resource_type = resource_type self.resource_name = resource_name -class CloudError(Model): - """An error response for a resource management request. - - :param error: - :type error: - ~azure.mgmt.resource.resources.v2016_02_01.models.ErrorResponse - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorResponse'}, - } - - def __init__(self, *, error=None, **kwargs) -> None: - super(CloudError, self).__init__(**kwargs) - self.error = error - - -class CloudErrorException(HttpOperationError): - """Server responsed with exception of type: 'CloudError'. - - :param deserialize: A deserializer - :param response: Server response to be deserialized. - """ - - def __init__(self, deserialize, response, *args): - - super(CloudErrorException, self).__init__(deserialize, response, 'CloudError', *args) - - -class DebugSetting(Model): +class DebugSetting(msrest.serialization.Model): """DebugSetting. :param detail_level: The debug detail level. @@ -118,17 +108,21 @@ class DebugSetting(Model): 'detail_level': {'key': 'detailLevel', 'type': 'str'}, } - def __init__(self, *, detail_level: str=None, **kwargs) -> None: + def __init__( + self, + *, + detail_level: Optional[str] = None, + **kwargs + ): super(DebugSetting, self).__init__(**kwargs) self.detail_level = detail_level -class Dependency(Model): +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] + :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. @@ -144,7 +138,15 @@ class Dependency(Model): 'resource_name': {'key': 'resourceName', 'type': 'str'}, } - def __init__(self, *, depends_on=None, id: str=None, resource_type: str=None, resource_name: str=None, **kwargs) -> None: + def __init__( + self, + *, + depends_on: Optional[List["BasicDependency"]] = None, + id: Optional[str] = None, + resource_type: Optional[str] = None, + resource_name: Optional[str] = None, + **kwargs + ): super(Dependency, self).__init__(**kwargs) self.depends_on = depends_on self.id = id @@ -152,24 +154,28 @@ def __init__(self, *, depends_on=None, id: str=None, resource_type: str=None, re self.resource_name = resource_name -class Deployment(Model): +class Deployment(msrest.serialization.Model): """Deployment operation parameters. :param properties: The deployment properties. - :type properties: - ~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentProperties + :type properties: ~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentProperties """ _attribute_map = { 'properties': {'key': 'properties', 'type': 'DeploymentProperties'}, } - def __init__(self, *, properties=None, **kwargs) -> None: + def __init__( + self, + *, + properties: Optional["DeploymentProperties"] = None, + **kwargs + ): super(Deployment, self).__init__(**kwargs) self.properties = properties -class DeploymentExportResult(Model): +class DeploymentExportResult(msrest.serialization.Model): """DeploymentExportResult. :param template: The template content. @@ -180,16 +186,20 @@ class DeploymentExportResult(Model): 'template': {'key': 'template', 'type': 'object'}, } - def __init__(self, *, template=None, **kwargs) -> None: + def __init__( + self, + *, + template: Optional[object] = None, + **kwargs + ): super(DeploymentExportResult, self).__init__(**kwargs) self.template = template -class DeploymentExtended(Model): +class DeploymentExtended(msrest.serialization.Model): """Deployment information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. @@ -213,14 +223,20 @@ class DeploymentExtended(Model): 'properties': {'key': 'properties', 'type': 'DeploymentPropertiesExtended'}, } - def __init__(self, *, name: str, properties=None, **kwargs) -> None: + def __init__( + self, + *, + name: str, + properties: Optional["DeploymentPropertiesExtended"] = None, + **kwargs + ): super(DeploymentExtended, self).__init__(**kwargs) self.id = None self.name = name self.properties = properties -class DeploymentExtendedFilter(Model): +class DeploymentExtendedFilter(msrest.serialization.Model): """Deployment filter. :param provisioning_state: The provisioning state. @@ -231,12 +247,43 @@ class DeploymentExtendedFilter(Model): 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, } - def __init__(self, *, provisioning_state: str=None, **kwargs) -> None: + def __init__( + self, + *, + provisioning_state: Optional[str] = None, + **kwargs + ): super(DeploymentExtendedFilter, self).__init__(**kwargs) self.provisioning_state = provisioning_state -class DeploymentOperation(Model): +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 + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[DeploymentExtended]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["DeploymentExtended"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(DeploymentListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class DeploymentOperation(msrest.serialization.Model): """Deployment operation information. :param id: Full deployment operation id. @@ -254,20 +301,27 @@ class DeploymentOperation(Model): 'properties': {'key': 'properties', 'type': 'DeploymentOperationProperties'}, } - def __init__(self, *, id: str=None, operation_id: str=None, properties=None, **kwargs) -> None: + def __init__( + self, + *, + id: Optional[str] = None, + operation_id: Optional[str] = None, + properties: Optional["DeploymentOperationProperties"] = None, + **kwargs + ): super(DeploymentOperation, self).__init__(**kwargs) self.id = id self.operation_id = operation_id self.properties = properties -class DeploymentOperationProperties(Model): +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 + :type timestamp: ~datetime.datetime :param service_request_id: Deployment operation service request id. :type service_request_id: str :param status_code: Operation status code. @@ -275,14 +329,11 @@ class DeploymentOperationProperties(Model): :param status_message: Operation status message. :type status_message: object :param target_resource: The target resource. - :type target_resource: - ~azure.mgmt.resource.resources.v2016_02_01.models.TargetResource + :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 + :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 + :type response: ~azure.mgmt.resource.resources.v2016_02_01.models.HttpMessage """ _attribute_map = { @@ -296,7 +347,19 @@ class DeploymentOperationProperties(Model): 'response': {'key': 'response', 'type': 'HttpMessage'}, } - def __init__(self, *, provisioning_state: str=None, timestamp=None, service_request_id: str=None, status_code: str=None, status_message=None, target_resource=None, request=None, response=None, **kwargs) -> None: + def __init__( + self, + *, + provisioning_state: Optional[str] = None, + timestamp: Optional[datetime.datetime] = None, + service_request_id: Optional[str] = None, + status_code: Optional[str] = None, + status_message: Optional[object] = None, + target_resource: Optional["TargetResource"] = None, + request: Optional["HttpMessage"] = None, + response: Optional["HttpMessage"] = None, + **kwargs + ): super(DeploymentOperationProperties, self).__init__(**kwargs) self.provisioning_state = provisioning_state self.timestamp = timestamp @@ -308,32 +371,51 @@ def __init__(self, *, provisioning_state: str=None, timestamp=None, service_requ self.response = response -class DeploymentProperties(Model): +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 + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[DeploymentOperation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["DeploymentOperation"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(DeploymentOperationsListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class DeploymentProperties(msrest.serialization.Model): """Deployment properties. 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 only one of Template or TemplateLink. + :param template: The template content. It can be a JObject or a well formed JSON string. Use + only one of Template or TemplateLink. :type template: object - :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 only one of Parameters or ParametersLink. + :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 + only one of Parameters or ParametersLink. :type parameters: object - :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 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 + :type debug_setting: ~azure.mgmt.resource.resources.v2016_02_01.models.DebugSetting """ _validation = { @@ -345,11 +427,21 @@ class DeploymentProperties(Model): 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, 'parameters': {'key': 'parameters', 'type': 'object'}, 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, - 'mode': {'key': 'mode', 'type': 'DeploymentMode'}, + 'mode': {'key': 'mode', 'type': 'str'}, 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, } - def __init__(self, *, mode, template=None, template_link=None, parameters=None, parameters_link=None, debug_setting=None, **kwargs) -> None: + def __init__( + self, + *, + mode: Union[str, "DeploymentMode"], + template: Optional[object] = None, + template_link: Optional["TemplateLink"] = None, + parameters: Optional[object] = None, + parameters_link: Optional["ParametersLink"] = None, + debug_setting: Optional["DebugSetting"] = None, + **kwargs + ): super(DeploymentProperties, self).__init__(**kwargs) self.template = template self.template_link = template_link @@ -359,7 +451,7 @@ def __init__(self, *, mode, template=None, template_link=None, parameters=None, self.debug_setting = debug_setting -class DeploymentPropertiesExtended(Model): +class DeploymentPropertiesExtended(msrest.serialization.Model): """Deployment properties with additional details. :param provisioning_state: The state of the provisioning. @@ -367,37 +459,27 @@ class DeploymentPropertiesExtended(Model): :param correlation_id: The correlation ID of the deployment. :type correlation_id: str :param timestamp: The timestamp of the template deployment. - :type timestamp: datetime + :type timestamp: ~datetime.datetime :param outputs: Key/value pairs that represent deployment output. :type outputs: object - :param providers: The list of resource providers needed for the - deployment. - :type providers: - list[~azure.mgmt.resource.resources.v2016_02_01.models.Provider] + :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 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: object - :param 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. + :param 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: object - :param 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 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 + :type debug_setting: ~azure.mgmt.resource.resources.v2016_02_01.models.DebugSetting """ _attribute_map = { @@ -411,11 +493,27 @@ class DeploymentPropertiesExtended(Model): 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, 'parameters': {'key': 'parameters', 'type': 'object'}, 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, - 'mode': {'key': 'mode', 'type': 'DeploymentMode'}, + 'mode': {'key': 'mode', 'type': 'str'}, 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, } - def __init__(self, *, provisioning_state: str=None, correlation_id: str=None, timestamp=None, outputs=None, providers=None, dependencies=None, template=None, template_link=None, parameters=None, parameters_link=None, mode=None, debug_setting=None, **kwargs) -> None: + def __init__( + self, + *, + provisioning_state: Optional[str] = None, + correlation_id: Optional[str] = None, + timestamp: Optional[datetime.datetime] = None, + outputs: Optional[object] = None, + providers: Optional[List["Provider"]] = None, + dependencies: Optional[List["Dependency"]] = None, + template: Optional[object] = None, + template_link: Optional["TemplateLink"] = None, + parameters: Optional[object] = None, + parameters_link: Optional["ParametersLink"] = None, + mode: Optional[Union[str, "DeploymentMode"]] = None, + debug_setting: Optional["DebugSetting"] = None, + **kwargs + ): super(DeploymentPropertiesExtended, self).__init__(**kwargs) self.provisioning_state = provisioning_state self.correlation_id = correlation_id @@ -431,7 +529,7 @@ def __init__(self, *, provisioning_state: str=None, correlation_id: str=None, ti self.debug_setting = debug_setting -class DeploymentValidateResult(Model): +class DeploymentValidateResult(msrest.serialization.Model): """Information from validate template deployment response. :param error: Validation error. @@ -447,17 +545,22 @@ class DeploymentValidateResult(Model): 'properties': {'key': 'properties', 'type': 'DeploymentPropertiesExtended'}, } - def __init__(self, *, error=None, properties=None, **kwargs) -> None: + def __init__( + self, + *, + error: Optional["ResourceManagementErrorWithDetails"] = None, + properties: Optional["DeploymentPropertiesExtended"] = None, + **kwargs + ): super(DeploymentValidateResult, self).__init__(**kwargs) self.error = error self.properties = properties -class ErrorAdditionalInfo(Model): +class ErrorAdditionalInfo(msrest.serialization.Model): """The resource management error additional info. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar type: The additional info type. :vartype type: str @@ -475,17 +578,19 @@ class ErrorAdditionalInfo(Model): 'info': {'key': 'info', 'type': 'object'}, } - def __init__(self, **kwargs) -> None: + def __init__( + self, + **kwargs + ): super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None -class ErrorResponse(Model): +class ErrorResponse(msrest.serialization.Model): """The resource management error response. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar code: The error code. :vartype code: str @@ -494,8 +599,7 @@ class ErrorResponse(Model): :ivar target: The error target. :vartype target: str :ivar details: The error details. - :vartype details: - list[~azure.mgmt.resource.resources.v2016_02_01.models.ErrorResponse] + :vartype details: list[~azure.mgmt.resource.resources.v2016_02_01.models.ErrorResponse] :ivar additional_info: The error additional info. :vartype additional_info: list[~azure.mgmt.resource.resources.v2016_02_01.models.ErrorAdditionalInfo] @@ -517,7 +621,10 @@ class ErrorResponse(Model): 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, } - def __init__(self, **kwargs) -> None: + def __init__( + self, + **kwargs + ): super(ErrorResponse, self).__init__(**kwargs) self.code = None self.message = None @@ -526,16 +633,15 @@ def __init__(self, **kwargs) -> None: self.additional_info = None -class ExportTemplateRequest(Model): +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, supply an array with single entry '*'. + :param 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', 'SkipResourceNameParameterization', - 'SkipAllParameterization' + :param options: The export template options. A CSV-formatted list containing zero or more of + the following: 'IncludeParameterDefaultValue', 'IncludeComments', + 'SkipResourceNameParameterization', 'SkipAllParameterization'. :type options: str """ @@ -544,27 +650,32 @@ class ExportTemplateRequest(Model): 'options': {'key': 'options', 'type': 'str'}, } - def __init__(self, *, resources=None, options: str=None, **kwargs) -> None: + def __init__( + self, + *, + resources: Optional[List[str]] = None, + options: Optional[str] = None, + **kwargs + ): super(ExportTemplateRequest, self).__init__(**kwargs) self.resources = resources self.options = options -class Resource(Model): +class Resource(msrest.serialization.Model): """Resource. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource Id + :ivar id: Resource Id. :vartype id: str - :ivar name: Resource name + :ivar name: Resource name. :vartype name: str - :ivar type: Resource type + :ivar type: Resource type. :vartype type: str - :param location: Resource location + :param location: Resource location. :type location: str - :param tags: Resource tags + :param tags: A set of tags. Resource tags. :type tags: dict[str, str] """ @@ -582,7 +693,13 @@ class Resource(Model): 'tags': {'key': 'tags', 'type': '{str}'}, } - def __init__(self, *, location: str=None, tags=None, **kwargs) -> None: + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -594,18 +711,17 @@ def __init__(self, *, location: str=None, tags=None, **kwargs) -> None: class GenericResource(Resource): """Resource information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource Id + :ivar id: Resource Id. :vartype id: str - :ivar name: Resource name + :ivar name: Resource name. :vartype name: str - :ivar type: Resource type + :ivar type: Resource type. :vartype type: str - :param location: Resource location + :param location: Resource location. :type location: str - :param tags: Resource tags + :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 @@ -641,7 +757,19 @@ class GenericResource(Resource): 'identity': {'key': 'identity', 'type': 'Identity'}, } - def __init__(self, *, location: str=None, tags=None, plan=None, properties=None, kind: str=None, managed_by: str=None, sku=None, identity=None, **kwargs) -> None: + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + plan: Optional["Plan"] = None, + properties: Optional[object] = None, + kind: Optional[str] = None, + managed_by: Optional[str] = None, + sku: Optional["Sku"] = None, + identity: Optional["Identity"] = None, + **kwargs + ): super(GenericResource, self).__init__(location=location, tags=tags, **kwargs) self.plan = plan self.properties = properties @@ -654,18 +782,17 @@ def __init__(self, *, location: str=None, tags=None, plan=None, properties=None, class GenericResourceExpanded(GenericResource): """Resource information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource Id + :ivar id: Resource Id. :vartype id: str - :ivar name: Resource name + :ivar name: Resource name. :vartype name: str - :ivar type: Resource type + :ivar type: Resource type. :vartype type: str - :param location: Resource location + :param location: Resource location. :type location: str - :param tags: Resource tags + :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 @@ -679,14 +806,14 @@ class GenericResourceExpanded(GenericResource): :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 created_time: The created time of the resource. This is only present - if requested via the $expand query parameter. - :vartype created_time: datetime - :ivar changed_time: The changed time of the resource. This is only present - if requested via the $expand query parameter. - :vartype changed_time: datetime - :ivar provisioning_state: The provisioning state of the resource. This is - only present if requested via the $expand query parameter. + :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 + :ivar changed_time: The changed time of the resource. This is only present if requested via the + $expand query parameter. + :vartype changed_time: ~datetime.datetime + :ivar provisioning_state: The provisioning state of the resource. This is only present if + requested via the $expand query parameter. :vartype provisioning_state: str """ @@ -716,14 +843,26 @@ class GenericResourceExpanded(GenericResource): 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, } - def __init__(self, *, location: str=None, tags=None, plan=None, properties=None, kind: str=None, managed_by: str=None, sku=None, identity=None, **kwargs) -> None: + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + plan: Optional["Plan"] = None, + properties: Optional[object] = None, + kind: Optional[str] = None, + managed_by: Optional[str] = None, + sku: Optional["Sku"] = None, + identity: Optional["Identity"] = None, + **kwargs + ): 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 self.provisioning_state = None -class GenericResourceFilter(Model): +class GenericResourceFilter(msrest.serialization.Model): """Resource filter. :param resource_type: The resource type. @@ -740,14 +879,21 @@ class GenericResourceFilter(Model): 'tagvalue': {'key': 'tagvalue', 'type': 'str'}, } - def __init__(self, *, resource_type: str=None, tagname: str=None, tagvalue: str=None, **kwargs) -> None: + def __init__( + self, + *, + resource_type: Optional[str] = None, + tagname: Optional[str] = None, + tagvalue: Optional[str] = None, + **kwargs + ): super(GenericResourceFilter, self).__init__(**kwargs) self.resource_type = resource_type self.tagname = tagname self.tagvalue = tagvalue -class HttpMessage(Model): +class HttpMessage(msrest.serialization.Model): """HttpMessage. :param content: HTTP message content. @@ -758,53 +904,60 @@ class HttpMessage(Model): 'content': {'key': 'content', 'type': 'object'}, } - def __init__(self, *, content=None, **kwargs) -> None: + def __init__( + self, + *, + content: Optional[object] = None, + **kwargs + ): super(HttpMessage, self).__init__(**kwargs) self.content = content -class Identity(Model): +class Identity(msrest.serialization.Model): """Identity for the resource. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar principal_id: The principal id of resource identity. :vartype principal_id: str :ivar tenant_id: The tenant id of resource. :vartype tenant_id: str - :param type: The identity type. Possible values include: 'SystemAssigned' - :type type: str or - ~azure.mgmt.resource.resources.v2016_02_01.models.ResourceIdentityType + :ivar type: The identity type. Default value: "SystemAssigned". + :vartype type: str """ _validation = { 'principal_id': {'readonly': True}, 'tenant_id': {'readonly': True}, + 'type': {'constant': True}, } _attribute_map = { 'principal_id': {'key': 'principalId', 'type': 'str'}, 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'ResourceIdentityType'}, + 'type': {'key': 'type', 'type': 'str'}, } - def __init__(self, *, type=None, **kwargs) -> None: + type = "SystemAssigned" + + def __init__( + self, + **kwargs + ): super(Identity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None - self.type = type -class ParametersLink(Model): +class ParametersLink(msrest.serialization.Model): """Entity representing the reference to the deployment parameters. 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. + :param content_version: If included it must match the ContentVersion in the template. :type content_version: str """ @@ -817,13 +970,19 @@ class ParametersLink(Model): 'content_version': {'key': 'contentVersion', 'type': 'str'}, } - def __init__(self, *, uri: str, content_version: str=None, **kwargs) -> None: + def __init__( + self, + *, + uri: str, + content_version: Optional[str] = None, + **kwargs + ): super(ParametersLink, self).__init__(**kwargs) self.uri = uri self.content_version = content_version -class Plan(Model): +class Plan(msrest.serialization.Model): """Plan for the resource. :param name: The plan ID. @@ -843,7 +1002,15 @@ class Plan(Model): 'promotion_code': {'key': 'promotionCode', 'type': 'str'}, } - def __init__(self, *, name: str=None, publisher: str=None, product: str=None, promotion_code: str=None, **kwargs) -> None: + def __init__( + self, + *, + name: Optional[str] = None, + publisher: Optional[str] = None, + product: Optional[str] = None, + promotion_code: Optional[str] = None, + **kwargs + ): super(Plan, self).__init__(**kwargs) self.name = name self.publisher = publisher @@ -851,7 +1018,7 @@ def __init__(self, *, name: str=None, publisher: str=None, product: str=None, pr self.promotion_code = promotion_code -class Provider(Model): +class Provider(msrest.serialization.Model): """Resource provider information. :param id: The provider id. @@ -872,7 +1039,15 @@ class Provider(Model): 'resource_types': {'key': 'resourceTypes', 'type': '[ProviderResourceType]'}, } - def __init__(self, *, id: str=None, namespace: str=None, registration_state: str=None, resource_types=None, **kwargs) -> None: + def __init__( + self, + *, + id: Optional[str] = None, + namespace: Optional[str] = None, + registration_state: Optional[str] = None, + resource_types: Optional[List["ProviderResourceType"]] = None, + **kwargs + ): super(Provider, self).__init__(**kwargs) self.id = id self.namespace = namespace @@ -880,17 +1055,41 @@ def __init__(self, *, id: str=None, namespace: str=None, registration_state: str self.resource_types = resource_types -class ProviderResourceType(Model): +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 + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Provider]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["Provider"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(ProviderListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +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. + :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] + :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. @@ -905,7 +1104,16 @@ class ProviderResourceType(Model): 'properties': {'key': 'properties', 'type': '{str}'}, } - def __init__(self, *, resource_type: str=None, locations=None, aliases=None, api_versions=None, properties=None, **kwargs) -> None: + def __init__( + self, + *, + resource_type: Optional[str] = None, + locations: Optional[List[str]] = None, + aliases: Optional[List["AliasType"]] = None, + api_versions: Optional[List[str]] = None, + properties: Optional[Dict[str, str]] = None, + **kwargs + ): super(ProviderResourceType, self).__init__(**kwargs) self.resource_type = resource_type self.locations = locations @@ -914,11 +1122,10 @@ def __init__(self, *, resource_type: str=None, locations=None, aliases=None, api self.properties = properties -class ResourceGroup(Model): +class ResourceGroup(msrest.serialization.Model): """Resource group information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. @@ -926,15 +1133,13 @@ class ResourceGroup(Model): :vartype id: str :param name: The Name of the resource group. :type name: str - :param 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 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. + :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 + 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: The tags attached to the resource group. + :param tags: A set of tags. The tags attached to the resource group. :type tags: dict[str, str] """ @@ -951,7 +1156,15 @@ class ResourceGroup(Model): 'tags': {'key': 'tags', 'type': '{str}'}, } - def __init__(self, *, location: str, name: str=None, properties=None, tags=None, **kwargs) -> None: + def __init__( + self, + *, + location: str, + name: Optional[str] = None, + properties: Optional["ResourceGroupProperties"] = None, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): super(ResourceGroup, self).__init__(**kwargs) self.id = None self.name = name @@ -960,7 +1173,7 @@ def __init__(self, *, location: str, name: str=None, properties=None, tags=None, self.tags = tags -class ResourceGroupExportResult(Model): +class ResourceGroupExportResult(msrest.serialization.Model): """ResourceGroupExportResult. :param template: The template content. @@ -975,13 +1188,19 @@ class ResourceGroupExportResult(Model): 'error': {'key': 'error', 'type': 'ResourceManagementErrorWithDetails'}, } - def __init__(self, *, template=None, error=None, **kwargs) -> None: + def __init__( + self, + *, + template: Optional[object] = None, + error: Optional["ResourceManagementErrorWithDetails"] = None, + **kwargs + ): super(ResourceGroupExportResult, self).__init__(**kwargs) self.template = template self.error = error -class ResourceGroupFilter(Model): +class ResourceGroupFilter(msrest.serialization.Model): """Resource group filter. :param tag_name: The tag name. @@ -995,17 +1214,54 @@ class ResourceGroupFilter(Model): 'tag_value': {'key': 'tagValue', 'type': 'str'}, } - def __init__(self, *, tag_name: str=None, tag_value: str=None, **kwargs) -> None: + def __init__( + self, + *, + tag_name: Optional[str] = None, + tag_value: Optional[str] = None, + **kwargs + ): super(ResourceGroupFilter, self).__init__(**kwargs) self.tag_name = tag_name self.tag_value = tag_value -class ResourceGroupProperties(Model): +class ResourceGroupListResult(msrest.serialization.Model): + """List of resource groups. + + 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 + """ + + _validation = { + 'next_link': {'required': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ResourceGroup]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + next_link: str, + value: Optional[List["ResourceGroup"]] = None, + **kwargs + ): + super(ResourceGroupListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ResourceGroupProperties(msrest.serialization.Model): """The resource group properties. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar provisioning_state: The provisioning state. :vartype provisioning_state: str @@ -1019,12 +1275,47 @@ class ResourceGroupProperties(Model): 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, } - def __init__(self, **kwargs) -> None: + def __init__( + self, + **kwargs + ): super(ResourceGroupProperties, self).__init__(**kwargs) self.provisioning_state = None -class ResourceManagementErrorWithDetails(Model): +class ResourceListResult(msrest.serialization.Model): + """List of resource groups. + + 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 + """ + + _validation = { + 'next_link': {'required': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[GenericResourceExpanded]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + next_link: str, + value: Optional[List["GenericResourceExpanded"]] = None, + **kwargs + ): + super(ResourceListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ResourceManagementErrorWithDetails(msrest.serialization.Model): """ResourceManagementErrorWithDetails. All required parameters must be populated in order to send to Azure. @@ -1052,7 +1343,15 @@ class ResourceManagementErrorWithDetails(Model): 'details': {'key': 'details', 'type': '[ResourceManagementErrorWithDetails]'}, } - def __init__(self, *, code: str, message: str, target: str=None, details=None, **kwargs) -> None: + def __init__( + self, + *, + code: str, + message: str, + target: Optional[str] = None, + details: Optional[List["ResourceManagementErrorWithDetails"]] = None, + **kwargs + ): super(ResourceManagementErrorWithDetails, self).__init__(**kwargs) self.code = code self.message = message @@ -1060,7 +1359,7 @@ def __init__(self, *, code: str, message: str, target: str=None, details=None, * self.details = details -class ResourceProviderOperationDisplayProperties(Model): +class ResourceProviderOperationDisplayProperties(msrest.serialization.Model): """Resource provider operation's display properties. :param publisher: Operation description. @@ -1083,7 +1382,16 @@ class ResourceProviderOperationDisplayProperties(Model): 'description': {'key': 'description', 'type': 'str'}, } - def __init__(self, *, publisher: str=None, provider: str=None, resource: str=None, operation: str=None, description: str=None, **kwargs) -> None: + def __init__( + self, + *, + publisher: Optional[str] = None, + provider: Optional[str] = None, + resource: Optional[str] = None, + operation: Optional[str] = None, + description: Optional[str] = None, + **kwargs + ): super(ResourceProviderOperationDisplayProperties, self).__init__(**kwargs) self.publisher = publisher self.provider = provider @@ -1092,7 +1400,7 @@ def __init__(self, *, publisher: str=None, provider: str=None, resource: str=Non self.description = description -class ResourcesMoveInfo(Model): +class ResourcesMoveInfo(msrest.serialization.Model): """Parameters of move resources. :param resources: The ids of the resources. @@ -1106,13 +1414,19 @@ class ResourcesMoveInfo(Model): 'target_resource_group': {'key': 'targetResourceGroup', 'type': 'str'}, } - def __init__(self, *, resources=None, target_resource_group: str=None, **kwargs) -> None: + def __init__( + self, + *, + resources: Optional[List[str]] = None, + target_resource_group: Optional[str] = None, + **kwargs + ): super(ResourcesMoveInfo, self).__init__(**kwargs) self.resources = resources self.target_resource_group = target_resource_group -class Sku(Model): +class Sku(msrest.serialization.Model): """Sku for the resource. :param name: The sku name. @@ -1138,7 +1452,17 @@ class Sku(Model): 'capacity': {'key': 'capacity', 'type': 'int'}, } - def __init__(self, *, name: str=None, tier: str=None, size: str=None, family: str=None, model: str=None, capacity: int=None, **kwargs) -> None: + def __init__( + self, + *, + name: Optional[str] = None, + tier: Optional[str] = None, + size: Optional[str] = None, + family: Optional[str] = None, + model: Optional[str] = None, + capacity: Optional[int] = None, + **kwargs + ): super(Sku, self).__init__(**kwargs) self.name = name self.tier = tier @@ -1148,10 +1472,10 @@ def __init__(self, *, name: str=None, tier: str=None, size: str=None, family: st self.capacity = capacity -class SubResource(Model): +class SubResource(msrest.serialization.Model): """SubResource. - :param id: Resource Id + :param id: Resource Id. :type id: str """ @@ -1159,12 +1483,17 @@ class SubResource(Model): 'id': {'key': 'id', 'type': 'str'}, } - def __init__(self, *, id: str=None, **kwargs) -> None: + def __init__( + self, + *, + id: Optional[str] = None, + **kwargs + ): super(SubResource, self).__init__(**kwargs) self.id = id -class TagCount(Model): +class TagCount(msrest.serialization.Model): """Tag count. :param type: Type of count. @@ -1178,17 +1507,22 @@ class TagCount(Model): 'value': {'key': 'value', 'type': 'str'}, } - def __init__(self, *, type: str=None, value: str=None, **kwargs) -> None: + def __init__( + self, + *, + type: Optional[str] = None, + value: Optional[str] = None, + **kwargs + ): super(TagCount, self).__init__(**kwargs) self.type = type self.value = value -class TagDetails(Model): +class TagDetails(msrest.serialization.Model): """Tag details. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The tag ID. :vartype id: str @@ -1197,8 +1531,7 @@ class TagDetails(Model): :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] + :type values: list[~azure.mgmt.resource.resources.v2016_02_01.models.TagValue] """ _validation = { @@ -1212,7 +1545,14 @@ class TagDetails(Model): 'values': {'key': 'values', 'type': '[TagValue]'}, } - def __init__(self, *, tag_name: str=None, count=None, values=None, **kwargs) -> None: + def __init__( + self, + *, + tag_name: Optional[str] = None, + count: Optional["TagCount"] = None, + values: Optional[List["TagValue"]] = None, + **kwargs + ): super(TagDetails, self).__init__(**kwargs) self.id = None self.tag_name = tag_name @@ -1220,11 +1560,42 @@ def __init__(self, *, tag_name: str=None, count=None, values=None, **kwargs) -> self.values = values -class TagValue(Model): +class TagsListResult(msrest.serialization.Model): + """List of subscription tags. + + 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 + """ + + _validation = { + 'next_link': {'required': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[TagDetails]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + next_link: str, + value: Optional[List["TagDetails"]] = None, + **kwargs + ): + super(TagsListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class TagValue(msrest.serialization.Model): """Tag information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The tag ID. :vartype id: str @@ -1244,14 +1615,20 @@ class TagValue(Model): 'count': {'key': 'count', 'type': 'TagCount'}, } - def __init__(self, *, tag_value: str=None, count=None, **kwargs) -> None: + def __init__( + self, + *, + tag_value: Optional[str] = None, + count: Optional["TagCount"] = None, + **kwargs + ): super(TagValue, self).__init__(**kwargs) self.id = None self.tag_value = tag_value self.count = count -class TargetResource(Model): +class TargetResource(msrest.serialization.Model): """Target resource. :param id: The ID of the resource. @@ -1268,16 +1645,22 @@ class TargetResource(Model): 'resource_type': {'key': 'resourceType', 'type': 'str'}, } - def __init__(self, *, id: str=None, resource_name: str=None, resource_type: str=None, **kwargs) -> None: + def __init__( + self, + *, + id: Optional[str] = None, + resource_name: Optional[str] = None, + resource_type: Optional[str] = None, + **kwargs + ): super(TargetResource, self).__init__(**kwargs) self.id = id self.resource_name = resource_name self.resource_type = resource_type -class TemplateHashResult(Model): - """Result of the request to calculate template hash. It contains a string of - minified template and its hash. +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 @@ -1290,21 +1673,26 @@ class TemplateHashResult(Model): 'template_hash': {'key': 'templateHash', 'type': 'str'}, } - def __init__(self, *, minified_template: str=None, template_hash: str=None, **kwargs) -> None: + def __init__( + self, + *, + minified_template: Optional[str] = None, + template_hash: Optional[str] = None, + **kwargs + ): super(TemplateHashResult, self).__init__(**kwargs) self.minified_template = minified_template self.template_hash = template_hash -class TemplateLink(Model): +class TemplateLink(msrest.serialization.Model): """Entity representing the reference to the template. 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. + :param content_version: If included it must match the ContentVersion in the template. :type content_version: str """ @@ -1317,7 +1705,13 @@ class TemplateLink(Model): 'content_version': {'key': 'contentVersion', 'type': 'str'}, } - def __init__(self, *, uri: str, content_version: str=None, **kwargs) -> None: + def __init__( + self, + *, + uri: str, + content_version: Optional[str] = None, + **kwargs + ): 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/_paged_models.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/models/_paged_models.py deleted file mode 100644 index 7d038125f963..000000000000 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/models/_paged_models.py +++ /dev/null @@ -1,92 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.paging import Paged - - -class DeploymentExtendedPaged(Paged): - """ - A paging container for iterating over a list of :class:`DeploymentExtended ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[DeploymentExtended]'} - } - - def __init__(self, *args, **kwargs): - - super(DeploymentExtendedPaged, self).__init__(*args, **kwargs) -class ProviderPaged(Paged): - """ - A paging container for iterating over a list of :class:`Provider ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[Provider]'} - } - - def __init__(self, *args, **kwargs): - - super(ProviderPaged, self).__init__(*args, **kwargs) -class GenericResourceExpandedPaged(Paged): - """ - A paging container for iterating over a list of :class:`GenericResourceExpanded ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[GenericResourceExpanded]'} - } - - def __init__(self, *args, **kwargs): - - super(GenericResourceExpandedPaged, self).__init__(*args, **kwargs) -class ResourceGroupPaged(Paged): - """ - A paging container for iterating over a list of :class:`ResourceGroup ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[ResourceGroup]'} - } - - def __init__(self, *args, **kwargs): - - super(ResourceGroupPaged, self).__init__(*args, **kwargs) -class TagDetailsPaged(Paged): - """ - A paging container for iterating over a list of :class:`TagDetails ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[TagDetails]'} - } - - def __init__(self, *args, **kwargs): - - super(TagDetailsPaged, self).__init__(*args, **kwargs) -class DeploymentOperationPaged(Paged): - """ - A paging container for iterating over a list of :class:`DeploymentOperation ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[DeploymentOperation]'} - } - - def __init__(self, *args, **kwargs): - - super(DeploymentOperationPaged, self).__init__(*args, **kwargs) 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 3b6a0e19d760..39882d3cee61 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 @@ -1,23 +1,16 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from enum import Enum - class DeploymentMode(str, Enum): + """The deployment mode. + """ incremental = "Incremental" complete = "Complete" - - -class ResourceIdentityType(str, Enum): - - system_assigned = "SystemAssigned" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/operations/__init__.py index 0a2b1735bca3..a84dcb38191b 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/operations/__init__.py @@ -1,12 +1,9 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from ._deployments_operations import DeploymentsOperations @@ -14,7 +11,7 @@ from ._resource_groups_operations import ResourceGroupsOperations from ._resources_operations import ResourcesOperations from ._tags_operations import TagsOperations -from ._deployment_operations import DeploymentOperations +from ._deployment_operations_operations import DeploymentOperationsOperations __all__ = [ 'DeploymentsOperations', @@ -22,5 +19,5 @@ 'ResourceGroupsOperations', 'ResourcesOperations', 'TagsOperations', - 'DeploymentOperations', + 'DeploymentOperationsOperations', ] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/operations/_deployment_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/operations/_deployment_operations.py deleted file mode 100644 index 669ce2189335..000000000000 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/operations/_deployment_operations.py +++ /dev/null @@ -1,183 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError - -from .. import models - - -class DeploymentOperations(object): - """DeploymentOperations operations. - - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. - - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - :ivar api_version: Client Api Version. Constant value: "2016-02-01". - """ - - models = models - - def __init__(self, client, config, serializer, deserializer): - - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self.api_version = "2016-02-01" - - self.config = config - - def get( - self, resource_group_name, deployment_name, operation_id, custom_headers=None, raw=False, **operation_config): - """Get a list of deployments operations. - - :param resource_group_name: The name of the resource group. The name - is case insensitive. - :type resource_group_name: str - :param deployment_name: The name of the deployment. - :type deployment_name: str - :param operation_id: Operation Id. - :type operation_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentOperation or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentOperation - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` - """ - # Construct URL - url = self.get.metadata['url'] - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) - - if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentOperation', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}'} - - def list( - self, resource_group_name, deployment_name, top=None, custom_headers=None, raw=False, **operation_config): - """Gets a list of deployments operations. - - :param resource_group_name: The name of the resource group. The name - is case insensitive. - :type resource_group_name: str - :param deployment_name: The name of the deployment. - :type deployment_name: str - :param top: Query parameters. - :type top: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of DeploymentOperation - :rtype: - ~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentOperationPaged[~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentOperation] - :raises: :class:`CloudError` - """ - def prepare_request(next_link=None): - if not next_link: - # Construct URL - url = self.list.metadata['url'] - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_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 = {} - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - else: - url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) - return request - - def internal_paging(next_link=None): - request = prepare_request(next_link) - - response = self._client.send(request, stream=False, **operation_config) - - if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response - - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.DeploymentOperationPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations'} 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 new file mode 100644 index 000000000000..7ab799403349 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/operations/_deployment_operations_operations.py @@ -0,0 +1,184 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class DeploymentOperationsOperations(object): + """DeploymentOperationsOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2016_02_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def get( + self, + resource_group_name, # type: str + deployment_name, # type: str + operation_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentOperation" + """Get a list of deployments operations. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param operation_id: Operation Id. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentOperation or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentOperation + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentOperation"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-02-01" + + # Construct URL + url = self.get.metadata['url'] # type: 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'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentOperation', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + def list( + self, + resource_group_name, # type: str + deployment_name, # type: str + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.DeploymentOperationsListResult"] + """Gets a list of deployments operations. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-02-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentOperationsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations'} # type: ignore 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 fba82dac15e4..55c62e841e7d 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 @@ -1,675 +1,676 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError -from msrest.polling import LROPoller, NoPolling -from msrestazure.polling.arm_polling import ARMPolling +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class DeploymentsOperations(object): """DeploymentsOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2016_02_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: Client Api Version. Constant value: "2016-02-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2016-02-01" - - self.config = config - + self._config = config def _delete_initial( - self, resource_group_name, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-02-01" + # Construct URL - url = self.delete.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [202, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore - def delete( - self, resource_group_name, deployment_name, custom_headers=None, raw=False, polling=True, **operation_config): + def begin_delete( + self, + resource_group_name, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> LROPoller """Delete deployment. - :param resource_group_name: The name of the resource group. The name - is case insensitive. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param deployment_name: The name of the deployment to be deleted. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns None or - ClientRawResponse if raw==True - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._delete_initial( resource_group_name=resource_group_name, deployment_name=deployment_name, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore def check_existence( - self, resource_group_name, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Checks whether deployment exists. - :param resource_group_name: The name of the resource group to check. - The name is case insensitive. + :param resource_group_name: The name of the resource group to check. The name is case + insensitive. :type resource_group_name: str :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: bool or ClientRawResponse if raw=true - :rtype: bool or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-02-01" + # Construct URL - url = self.check_existence.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204, 404]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = (response.status_code == 204) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - return deserialized - check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + if cls: + return cls(pipeline_response, None, {}) + + 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, deployment_name, properties=None, custom_headers=None, raw=False, **operation_config): - parameters = models.Deployment(properties=properties) + self, + resource_group_name, # type: str + deployment_name, # type: str + properties=None, # type: Optional["models.DeploymentProperties"] + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentExtended" + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.Deployment(properties=properties) + api_version = "2016-02-01" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.create_or_update.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'Deployment') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 201]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', response) + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', response) + deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - - def create_or_update( - self, resource_group_name, deployment_name, properties=None, custom_headers=None, raw=False, polling=True, **operation_config): + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + def begin_create_or_update( + self, + resource_group_name, # type: str + deployment_name, # type: str + properties=None, # type: Optional["models.DeploymentProperties"] + **kwargs # type: Any + ): + # type: (...) -> LROPoller """Create a named template deployment using a template. - :param resource_group_name: The name of the resource group. The name - is case insensitive. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param deployment_name: The name of the deployment. :type deployment_name: str :param properties: The deployment properties. - :type properties: - ~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentProperties - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :type properties: ~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentProperties + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns DeploymentExtended or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentExtended] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentExtended]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 DeploymentExtended + :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] + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._create_or_update_initial( resource_group_name=resource_group_name, deployment_name=deployment_name, properties=properties, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - deserialized = self._deserialize('DeploymentExtended', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore def get( - self, resource_group_name, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentExtended" """Get a deployment. - :param resource_group_name: The name of the resource group to get. The - name is case insensitive. + :param resource_group_name: The name of the resource group to get. The name is case + insensitive. :type resource_group_name: str :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentExtended or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentExtended - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExtended or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentExtended + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-02-01" + # Construct URL - url = self.get.metadata['url'] + url = self.get.metadata['url'] # type: 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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', response) + deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore def cancel( - self, resource_group_name, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Cancel a currently running template deployment. - :param resource_group_name: The name of the resource group. The name - is case insensitive. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-02-01" + # Construct URL - url = self.cancel.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - cancel.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} + if cls: + return cls(pipeline_response, None, {}) + + cancel.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore def validate( - self, resource_group_name, deployment_name, properties=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + deployment_name, # type: str + properties=None, # type: Optional["models.DeploymentProperties"] + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentValidateResult" """Validate a deployment template. - :param resource_group_name: The name of the resource group. The name - is case insensitive. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param deployment_name: The name of the deployment. :type deployment_name: str :param properties: The deployment properties. - :type properties: - ~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentProperties - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentValidateResult or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentValidateResult - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :type properties: ~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentProperties + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentValidateResult + :raises: ~azure.core.exceptions.HttpResponseError """ - parameters = models.Deployment(properties=properties) + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentValidateResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.Deployment(properties=properties) + api_version = "2016-02-01" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.validate.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'Deployment') # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 400]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', response) + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', response) + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - validate.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} + validate.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore def export_template( - self, resource_group_name, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentExportResult" """Exports a deployment template. - :param resource_group_name: The name of the resource group. The name - is case insensitive. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentExportResult or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentExportResult - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentExportResult + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExportResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-02-01" + # Construct URL - url = self.export_template.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentExportResult', response) + deserialized = self._deserialize('DeploymentExportResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} + export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore def list( - self, resource_group_name, filter=None, top=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.DeploymentListResult"] """Get a list of deployments. - :param resource_group_name: The name of the resource group to filter - by. The name is case insensitive. + :param resource_group_name: The name of the resource group to filter by. The name is case + insensitive. :type resource_group_name: str :param filter: The filter to apply on the operation. :type filter: str - :param top: Query parameters. If null is passed returns all - deployments. + :param top: Query parameters. If null is passed returns all deployments. :type top: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of DeploymentExtended - :rtype: - ~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentExtendedPaged[~azure.mgmt.resource.resources.v2016_02_01.models.DeploymentExtended] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-02-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.DeploymentExtendedPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/'} # type: ignore def calculate_template_hash( - self, template, custom_headers=None, raw=False, **operation_config): + self, + template, # type: object + **kwargs # type: Any + ): + # type: (...) -> "models.TemplateHashResult" """Calculate the hash of the given template. :param template: The template provided to calculate hash. :type template: object - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: TemplateHashResult or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2016_02_01.models.TemplateHashResult - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateHashResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.TemplateHashResult + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TemplateHashResult"] + error_map = {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.calculate_template_hash.metadata['url'] + url = self.calculate_template_hash.metadata['url'] # type: ignore # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(template, 'object') # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('TemplateHashResult', response) + deserialized = self._deserialize('TemplateHashResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - calculate_template_hash.metadata = {'url': '/providers/Microsoft.Resources/calculateTemplateHash'} + 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 e5367ba741e0..a12ec0419b8e 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 @@ -1,298 +1,286 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class ProvidersOperations(object): """ProvidersOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2016_02_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: Client Api Version. Constant value: "2016-02-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2016-02-01" - - self.config = config + self._config = config def unregister( - self, resource_provider_namespace, custom_headers=None, raw=False, **operation_config): + self, + resource_provider_namespace, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.Provider" """Unregisters provider from a subscription. - :param resource_provider_namespace: Namespace of the resource - provider. + :param resource_provider_namespace: Namespace of the resource provider. :type resource_provider_namespace: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: Provider or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.Provider or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Provider or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.Provider + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Provider"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-02-01" + # Construct URL - url = self.unregister.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('Provider', response) + deserialized = self._deserialize('Provider', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - unregister.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister'} + unregister.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister'} # type: ignore def register( - self, resource_provider_namespace, custom_headers=None, raw=False, **operation_config): + self, + resource_provider_namespace, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.Provider" """Registers provider to be used with a subscription. - :param resource_provider_namespace: Namespace of the resource - provider. + :param resource_provider_namespace: Namespace of the resource provider. :type resource_provider_namespace: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: Provider or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.Provider or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Provider or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.Provider + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Provider"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-02-01" + # Construct URL - url = self.register.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('Provider', response) + deserialized = self._deserialize('Provider', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - register.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register'} + register.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register'} # type: ignore def list( - self, top=None, expand=None, custom_headers=None, raw=False, **operation_config): + self, + top=None, # type: Optional[int] + expand=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.ProviderListResult"] """Gets a list of resource providers. - :param top: Query parameters. If null is passed returns all - deployments. + :param top: Query parameters. If null is passed returns all deployments. :type top: int - :param expand: The $expand query parameter. e.g. To include property - aliases in response, use $expand=resourceTypes/aliases. + :param expand: The $expand query parameter. e.g. To include property aliases in response, use + $expand=resourceTypes/aliases. :type expand: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of Provider - :rtype: - ~azure.mgmt.resource.resources.v2016_02_01.models.ProviderPaged[~azure.mgmt.resource.resources.v2016_02_01.models.Provider] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of ProviderListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-02-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['url'] + url = self.list.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_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 = {} + 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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('ProviderListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.ProviderPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers'} # type: ignore def get( - self, resource_provider_namespace, expand=None, custom_headers=None, raw=False, **operation_config): + self, + resource_provider_namespace, # type: str + expand=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.Provider" """Gets a resource provider. - :param resource_provider_namespace: Namespace of the resource - provider. + :param resource_provider_namespace: Namespace of the resource provider. :type resource_provider_namespace: str - :param expand: The $expand query parameter. e.g. To include property - aliases in response, use $expand=resourceTypes/aliases. + :param expand: The $expand query parameter. e.g. To include property aliases in response, use + $expand=resourceTypes/aliases. :type expand: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: Provider or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.Provider or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Provider or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.Provider + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Provider"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-02-01" + # Construct URL - url = self.get.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('Provider', response) + deserialized = self._deserialize('Provider', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}'} + 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 cb0261bf625d..17e455dd1639 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 @@ -1,607 +1,595 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError -from msrest.polling import LROPoller, NoPolling -from msrestazure.polling.arm_polling import ARMPolling +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, List, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class ResourceGroupsOperations(object): """ResourceGroupsOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2016_02_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: Client Api Version. Constant value: "2016-02-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2016-02-01" - - self.config = config + self._config = config def list_resources( - self, resource_group_name, filter=None, expand=None, top=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + filter=None, # type: Optional[str] + expand=None, # type: Optional[str] + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.ResourceListResult"] """Get all of the resources under a subscription. - :param resource_group_name: Query parameters. If null is passed - returns all resource groups. + :param resource_group_name: Query parameters. If null is passed returns all resource groups. :type resource_group_name: str :param filter: The filter to apply on the operation. :type filter: str - :param expand: Comma-separated list of additional properties to be - included in the response. Valid values include `createdTime`, - `changedTime` and `provisioningState`. For example, - `$expand=createdTime,changedTime`. + :param expand: Comma-separated list of additional properties to be included in the response. + Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, + ``$expand=createdTime,changedTime``. :type expand: str - :param top: Query parameters. If null is passed returns all resource - groups. + :param top: Query parameters. If null is passed returns all resource groups. :type top: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of GenericResourceExpanded - :rtype: - ~azure.mgmt.resource.resources.v2016_02_01.models.GenericResourceExpandedPaged[~azure.mgmt.resource.resources.v2016_02_01.models.GenericResourceExpanded] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of ResourceListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-02-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_resources.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('ResourceListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.GenericResourceExpandedPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources'} + return ItemPaged( + get_next, extract_data + ) + list_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources'} # type: ignore def check_existence( - self, resource_group_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Checks whether resource group exists. - :param resource_group_name: The name of the resource group to check. - The name is case insensitive. + :param resource_group_name: The name of the resource group to check. The name is case + insensitive. :type resource_group_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: bool or ClientRawResponse if raw=true - :rtype: bool or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-02-01" + # Construct URL - url = self.check_existence.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204, 404]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = (response.status_code == 204) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - return deserialized - check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore def create_or_update( - self, resource_group_name, parameters, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + parameters, # type: "models.ResourceGroup" + **kwargs # type: Any + ): + # type: (...) -> "models.ResourceGroup" """Create a resource group. - :param resource_group_name: The name of the resource group to be - created or updated. + :param resource_group_name: The name of the resource group to be created or updated. :type resource_group_name: str - :param parameters: Parameters supplied to the create or update - resource group service operation. - :type parameters: - ~azure.mgmt.resource.resources.v2016_02_01.models.ResourceGroup - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: ResourceGroup or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2016_02_01.models.ResourceGroup or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :param parameters: Parameters supplied to the create or update resource group service + operation. + :type parameters: ~azure.mgmt.resource.resources.v2016_02_01.models.ResourceGroup + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.ResourceGroup + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceGroup"] + error_map = {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.create_or_update.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'ResourceGroup') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 201]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ResourceGroup', response) + deserialized = self._deserialize('ResourceGroup', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('ResourceGroup', response) + deserialized = self._deserialize('ResourceGroup', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} - + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore def _delete_initial( - self, resource_group_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-02-01" + # Construct URL - url = self.delete.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 202]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore - def delete( - self, resource_group_name, custom_headers=None, raw=False, polling=True, **operation_config): + def begin_delete( + self, + resource_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> LROPoller """Delete resource group. - :param resource_group_name: The name of the resource group to be - deleted. The name is case insensitive. + :param resource_group_name: The name of the resource group to be deleted. The name is case + insensitive. :type resource_group_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns None or - ClientRawResponse if raw==True - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._delete_initial( resource_group_name=resource_group_name, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore def get( - self, resource_group_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.ResourceGroup" """Get a resource group. - :param resource_group_name: The name of the resource group to get. The - name is case insensitive. + :param resource_group_name: The name of the resource group to get. The name is case + insensitive. :type resource_group_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: ResourceGroup or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2016_02_01.models.ResourceGroup or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.ResourceGroup + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceGroup"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-02-01" + # Construct URL - url = self.get.metadata['url'] + url = self.get.metadata['url'] # type: 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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('ResourceGroup', response) + deserialized = self._deserialize('ResourceGroup', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore def patch( - self, resource_group_name, parameters, custom_headers=None, raw=False, **operation_config): - """Resource groups can be updated through a simple PATCH operation to a - group address. The format of the request is the same as that for - creating a resource groups, though if a field is unspecified current - value will be carried over. . - - :param resource_group_name: The name of the resource group to be - created or updated. The name is case insensitive. + self, + resource_group_name, # type: str + parameters, # type: "models.ResourceGroup" + **kwargs # type: Any + ): + # type: (...) -> "models.ResourceGroup" + """Resource groups can be updated through a simple PATCH operation to a group address. The format of the request is the same as that for creating a resource groups, though if a field is unspecified current value will be carried over. + + :param resource_group_name: The name of the resource group to be created or updated. The name + is case insensitive. :type resource_group_name: str - :param parameters: Parameters supplied to the update state resource - group service operation. - :type parameters: - ~azure.mgmt.resource.resources.v2016_02_01.models.ResourceGroup - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: ResourceGroup or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2016_02_01.models.ResourceGroup or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :param parameters: Parameters supplied to the update state resource group service operation. + :type parameters: ~azure.mgmt.resource.resources.v2016_02_01.models.ResourceGroup + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.ResourceGroup + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceGroup"] + error_map = {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.patch.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'ResourceGroup') # Construct and send request - request = self._client.patch(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('ResourceGroup', response) + deserialized = self._deserialize('ResourceGroup', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - patch.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} + patch.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore def export_template( - self, resource_group_name, resources=None, options=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + resources=None, # type: Optional[List[str]] + options=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.ResourceGroupExportResult" """Captures the specified resource group as a template. - :param resource_group_name: The name of the resource group to be - created or updated. + :param resource_group_name: The name of the resource group to be created or updated. :type resource_group_name: str - :param resources: The IDs of the resources to filter the export by. To - export all resources, supply an array with single entry '*'. + :param 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', - 'SkipResourceNameParameterization', 'SkipAllParameterization' + :param options: The export template options. A CSV-formatted list containing zero or more of + the following: 'IncludeParameterDefaultValue', 'IncludeComments', + 'SkipResourceNameParameterization', 'SkipAllParameterization'. :type options: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: ResourceGroupExportResult or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2016_02_01.models.ResourceGroupExportResult - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroupExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.ResourceGroupExportResult + :raises: ~azure.core.exceptions.HttpResponseError """ - parameters = models.ExportTemplateRequest(resources=resources, options=options) + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceGroupExportResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.ExportTemplateRequest(resources=resources, options=options) + api_version = "2016-02-01" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.export_template.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'ExportTemplateRequest') # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('ResourceGroupExportResult', response) + deserialized = self._deserialize('ResourceGroupExportResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate'} + export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate'} # type: ignore def list( - self, filter=None, top=None, custom_headers=None, raw=False, **operation_config): + self, + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.ResourceGroupListResult"] """Gets a collection of resource groups. :param filter: The filter to apply on the operation. :type filter: str - :param top: Query parameters. If null is passed returns all resource - groups. + :param top: Query parameters. If null is passed returns all resource groups. :type top: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of ResourceGroup - :rtype: - ~azure.mgmt.resource.resources.v2016_02_01.models.ResourceGroupPaged[~azure.mgmt.resource.resources.v2016_02_01.models.ResourceGroup] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-02-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['url'] + url = self.list.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_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 = {} + 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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('ResourceGroupListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.ResourceGroupPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups'} # type: ignore 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 65173414cf16..be6ece0e2668 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 @@ -1,93 +1,111 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError -from msrest.polling import LROPoller, NoPolling -from msrestazure.polling.arm_polling import ARMPolling +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, List, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class ResourcesOperations(object): """ResourcesOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2016_02_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: Client Api Version. Constant value: "2016-02-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2016-02-01" - - self.config = config - + self._config = config def _move_resources_initial( - self, source_resource_group_name, resources=None, target_resource_group=None, custom_headers=None, raw=False, **operation_config): - parameters = models.ResourcesMoveInfo(resources=resources, target_resource_group=target_resource_group) + self, + source_resource_group_name, # type: str + resources=None, # type: Optional[List[str]] + target_resource_group=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.ResourcesMoveInfo(resources=resources, target_resource_group=target_resource_group) + api_version = "2016-02-01" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.move_resources.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'ResourcesMoveInfo') + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [202, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + _move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore - def move_resources( - self, source_resource_group_name, resources=None, target_resource_group=None, custom_headers=None, raw=False, polling=True, **operation_config): - """Move resources from one resource group to another. The resources being - moved should all be in the same resource group. + def begin_move_resources( + self, + source_resource_group_name, # type: str + resources=None, # type: Optional[List[str]] + target_resource_group=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """Move resources from one resource group to another. The resources being moved should all be in the same resource group. :param source_resource_group_name: Source resource group name. :type source_resource_group_name: str @@ -95,128 +113,133 @@ def move_resources( :type resources: list[str] :param target_resource_group: The target resource group. :type target_resource_group: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns None or - ClientRawResponse if raw==True - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._move_resources_initial( source_resource_group_name=source_resource_group_name, resources=resources, target_resource_group=target_resource_group, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} + begin_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore def list( - self, filter=None, expand=None, top=None, custom_headers=None, raw=False, **operation_config): + self, + filter=None, # type: Optional[str] + expand=None, # type: Optional[str] + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.ResourceListResult"] """Get all of the resources under a subscription. :param filter: The filter to apply on the operation. :type filter: str - :param expand: Comma-separated list of additional properties to be - included in the response. Valid values include `createdTime`, - `changedTime` and `provisioningState`. For example, - `$expand=createdTime,changedTime`. + :param expand: Comma-separated list of additional properties to be included in the response. + Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, + ``$expand=createdTime,changedTime``. :type expand: str - :param top: Query parameters. If null is passed returns all resource - groups. + :param top: Query parameters. If null is passed returns all resource groups. :type top: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of GenericResourceExpanded - :rtype: - ~azure.mgmt.resource.resources.v2016_02_01.models.GenericResourceExpandedPaged[~azure.mgmt.resource.resources.v2016_02_01.models.GenericResourceExpanded] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of ResourceListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-02-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['url'] + url = self.list.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_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 = {} + 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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('ResourceListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.GenericResourceExpandedPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resources'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resources'} # type: ignore def check_existence( - self, resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, api_version, custom_headers=None, raw=False, **operation_config): + self, + 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: (...) -> None """Checks whether resource exists. - :param resource_group_name: The name of the resource group. The name - is case insensitive. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param resource_provider_namespace: Resource identity. :type resource_provider_namespace: str @@ -226,64 +249,63 @@ def check_existence( :type resource_type: str :param resource_name: Resource identity. :type resource_name: str - :param api_version: - :type api_version: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: bool or ClientRawResponse if raw=true - :rtype: bool or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-02-01" + # Construct URL - url = self.check_existence.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204, 404]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = (response.status_code == 204) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - return deserialized - check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - def delete( - self, resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, api_version, custom_headers=None, raw=False, **operation_config): - """Delete resource and all of its resources. . + if cls: + return cls(pipeline_response, None, {}) - :param resource_group_name: The name of the resource group. The name - is case insensitive. + return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + def delete( + self, + 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: (...) -> None + """Delete resource and all of its resources. + + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param resource_provider_namespace: Resource identity. :type resource_provider_namespace: str @@ -293,62 +315,63 @@ def delete( :type resource_type: str :param resource_name: Resource identity. :type resource_name: str - :param api_version: - :type api_version: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-02-01" + # Construct URL - url = self.delete.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore def create_or_update( - self, resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, api_version, parameters, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + parameters, # type: "models.GenericResource" + **kwargs # type: Any + ): + # type: (...) -> "models.GenericResource" """Create a resource. - :param resource_group_name: The name of the resource group. The name - is case insensitive. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param resource_provider_namespace: Resource identity. :type resource_provider_namespace: str @@ -358,136 +381,144 @@ def create_or_update( :type resource_type: str :param resource_name: Resource identity. :type resource_name: str - :param api_version: - :type api_version: str :param parameters: Create or update resource parameters. - :type parameters: - ~azure.mgmt.resource.resources.v2016_02_01.models.GenericResource - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: GenericResource or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2016_02_01.models.GenericResource or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :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 + :return: GenericResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.GenericResource + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {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.create_or_update.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'GenericResource') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 201]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GenericResource', response) + deserialized = self._deserialize('GenericResource', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('GenericResource', response) + deserialized = self._deserialize('GenericResource', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} - + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore def _update_initial( - self, resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, api_version, parameters, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + parameters, # type: "models.GenericResource" + **kwargs # type: Any + ): + # type: (...) -> "models.GenericResource" + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {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.update.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'GenericResource') # Construct and send request - request = self._client.patch(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 202]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('GenericResource', response) + deserialized = self._deserialize('GenericResource', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - - def update( - self, resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, api_version, parameters, custom_headers=None, raw=False, polling=True, **operation_config): + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + def begin_update( + self, + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + parameters, # type: "models.GenericResource" + **kwargs # type: Any + ): + # type: (...) -> LROPoller """Updates a resource. - :param resource_group_name: The name of the resource group for the - resource. The name is case insensitive. + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource - provider. + :param resource_provider_namespace: The namespace of the resource provider. :type resource_provider_namespace: str :param parent_resource_path: The parent resource identity. :type parent_resource_path: str @@ -495,61 +526,60 @@ def update( :type resource_type: str :param resource_name: The name of the resource to update. :type resource_name: str - :param api_version: The API version to use for the operation. - :type api_version: str :param parameters: Parameters for updating the resource. - :type parameters: - ~azure.mgmt.resource.resources.v2016_02_01.models.GenericResource - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :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 polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns GenericResource or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.resource.resources.v2016_02_01.models.GenericResource] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.resource.resources.v2016_02_01.models.GenericResource]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 GenericResource + :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] + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._update_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, - api_version=api_version, parameters=parameters, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - deserialized = self._deserialize('GenericResource', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('GenericResource', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore def get( - self, resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, api_version, custom_headers=None, raw=False, **operation_config): + self, + 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: (...) -> "models.GenericResource" """Returns a resource belonging to a resource group. - :param resource_group_name: The name of the resource group. The name - is case insensitive. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param resource_provider_namespace: Resource identity. :type resource_provider_namespace: str @@ -559,61 +589,49 @@ def get( :type resource_type: str :param resource_name: Resource identity. :type resource_name: str - :param api_version: - :type api_version: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: GenericResource or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2016_02_01.models.GenericResource or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GenericResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.GenericResource + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-02-01" + # Construct URL - url = self.get.metadata['url'] + url = self.get.metadata['url'] # type: 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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('GenericResource', response) + deserialized = self._deserialize('GenericResource', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} + 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 f453f85f89bf..ebe32ab0da5f 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 @@ -1,332 +1,332 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class TagsOperations(object): """TagsOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2016_02_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: Client Api Version. Constant value: "2016-02-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2016-02-01" - - self.config = config + self._config = config def delete_value( - self, tag_name, tag_value, custom_headers=None, raw=False, **operation_config): + self, + tag_name, # type: str + tag_value, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Delete a subscription resource tag value. :param tag_name: The name of the tag. :type tag_name: str :param tag_value: The value of the tag. :type tag_value: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-02-01" + # Construct URL - url = self.delete_value.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} + delete_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore def create_or_update_value( - self, tag_name, tag_value, custom_headers=None, raw=False, **operation_config): + self, + tag_name, # type: str + tag_value, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.TagValue" """Create a subscription resource tag value. :param tag_name: The name of the tag. :type tag_name: str :param tag_value: The value of the tag. :type tag_value: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: TagValue or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.TagValue or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagValue or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.TagValue + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TagValue"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-02-01" + # Construct URL - url = self.create_or_update_value.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.put(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 201]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('TagValue', response) + deserialized = self._deserialize('TagValue', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('TagValue', response) + deserialized = self._deserialize('TagValue', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} + create_or_update_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore def create_or_update( - self, tag_name, custom_headers=None, raw=False, **operation_config): + self, + tag_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.TagDetails" """Create a subscription resource tag. :param tag_name: The name of the tag. :type tag_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: TagDetails or ClientRawResponse if raw=true + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagDetails or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.TagDetails - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TagDetails"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-02-01" + # Construct URL - url = self.create_or_update.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.put(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 201]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('TagDetails', response) + deserialized = self._deserialize('TagDetails', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('TagDetails', response) + deserialized = self._deserialize('TagDetails', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore def delete( - self, tag_name, custom_headers=None, raw=False, **operation_config): + self, + tag_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Delete a subscription resource tag. :param tag_name: The name of the tag. :type tag_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-02-01" + # Construct URL - url = self.delete.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} + delete.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore def list( - self, custom_headers=None, raw=False, **operation_config): + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.TagsListResult"] """Get a list of subscription resource tags. - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of TagDetails - :rtype: - ~azure.mgmt.resource.resources.v2016_02_01.models.TagDetailsPaged[~azure.mgmt.resource.resources.v2016_02_01.models.TagDetails] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of TagsListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-02-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['url'] + url = self.list.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('TagsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.TagDetailsPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/py.typed b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file 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 deleted file mode 100644 index c5a0f253483c..000000000000 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_02_01/version.py +++ /dev/null @@ -1,13 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -VERSION = "2016-02-01" - 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 68bc897193ac..fde2ed4c3b83 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 @@ -1,19 +1,16 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._configuration import ResourceManagementClientConfiguration from ._resource_management_client import ResourceManagementClient -__all__ = ['ResourceManagementClient', 'ResourceManagementClientConfiguration'] - -from .version import VERSION - -__version__ = VERSION +__all__ = ['ResourceManagementClient'] +try: + from ._patch import patch_sdk + patch_sdk() +except ImportError: + pass 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 3b326f792363..6ba6c0f5fd90 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 @@ -1,48 +1,69 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrestazure import AzureConfiguration -from .version import VERSION +from typing import TYPE_CHECKING +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + + from azure.core.credentials import TokenCredential + +VERSION = "unknown" + +class ResourceManagementClientConfiguration(Configuration): + """Configuration for ResourceManagementClient. -class ResourceManagementClientConfiguration(AzureConfiguration): - """Configuration for ResourceManagementClient Note that all parameters used to create this instance are saved as instance attributes. - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` + :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 """ def __init__( - self, credentials, subscription_id, base_url=None): - - if credentials is None: - raise ValueError("Parameter 'credentials' must not be None.") + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + 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.") - if not base_url: - base_url = 'https://management.azure.com' + super(ResourceManagementClientConfiguration, self).__init__(**kwargs) - super(ResourceManagementClientConfiguration, self).__init__(base_url) - - # Starting Autorest.Python 4.0.64, make connection pool activated by default - self.keep_alive = True - - self.add_user_agent('azure-mgmt-resource/{}'.format(VERSION)) - self.add_user_agent('Azure-SDK-For-Python') - - self.credentials = credentials + self.credential = credential self.subscription_id = subscription_id + self.api_version = "2016-09-01" + self.credential_scopes = ['https://management.azure.com/.default'] + self.credential_scopes.extend(kwargs.pop('credential_scopes', [])) + kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + 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) 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 new file mode 100644 index 000000000000..a88654d51848 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/_metadata.json @@ -0,0 +1,58 @@ +{ + "chosen_version": "2016-09-01", + "total_api_version_list": ["2016-09-01"], + "client": { + "name": "ResourceManagementClient", + "filename": "_resource_management_client", + "description": "Provides operations for working with resources and resource groups." + }, + "global_parameters": { + "sync_method": { + "credential": { + "method_signature": "credential, # type: \"TokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials.TokenCredential", + "required": true + }, + "subscription_id": { + "method_signature": "subscription_id, # type: str", + "description": "The ID of the target subscription.", + "docstring_type": "str", + "required": true + } + }, + "async_method": { + "credential": { + "method_signature": "credential, # type: \"AsyncTokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + }, + "subscription_id": { + "method_signature": "subscription_id, # type: str", + "description": "The ID of the target subscription.", + "docstring_type": "str", + "required": true + } + }, + "constant": { + }, + "call": "credential, subscription_id" + }, + "config": { + "credential": true, + "credential_scopes": ["https://management.azure.com/.default"] + }, + "operation_groups": { + "deployments": "DeploymentsOperations", + "providers": "ProvidersOperations", + "resource_groups": "ResourceGroupsOperations", + "resources": "ResourcesOperations", + "tags": "TagsOperations", + "deployment_operations": "DeploymentOperationsOperations" + }, + "operation_mixins": { + }, + "sync_imports": "None", + "async_imports": "None" +} \ 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 7792f1b0f3d4..1ab414d234b3 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 @@ -1,16 +1,19 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.service_client import SDKClient -from msrest import Serializer, Deserializer +from typing import TYPE_CHECKING + +from azure.mgmt.core import ARMPipelineClient +from msrest import Deserializer, Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional from ._configuration import ResourceManagementClientConfiguration from .operations import DeploymentsOperations @@ -18,57 +21,72 @@ from .operations import ResourceGroupsOperations from .operations import ResourcesOperations from .operations import TagsOperations -from .operations import DeploymentOperations +from .operations import DeploymentOperationsOperations from . import models -class ResourceManagementClient(SDKClient): +class ResourceManagementClient(object): """Provides operations for working with resources and resource groups. - :ivar config: Configuration for client. - :vartype config: ResourceManagementClientConfiguration - - :ivar deployments: Deployments operations + :ivar deployments: DeploymentsOperations operations :vartype deployments: azure.mgmt.resource.resources.v2016_09_01.operations.DeploymentsOperations - :ivar providers: Providers operations + :ivar providers: ProvidersOperations operations :vartype providers: azure.mgmt.resource.resources.v2016_09_01.operations.ProvidersOperations - :ivar resource_groups: ResourceGroups operations + :ivar resource_groups: ResourceGroupsOperations operations :vartype resource_groups: azure.mgmt.resource.resources.v2016_09_01.operations.ResourceGroupsOperations - :ivar resources: Resources operations + :ivar resources: ResourcesOperations operations :vartype resources: azure.mgmt.resource.resources.v2016_09_01.operations.ResourcesOperations - :ivar tags: Tags operations + :ivar tags: TagsOperations operations :vartype tags: azure.mgmt.resource.resources.v2016_09_01.operations.TagsOperations - :ivar deployment_operations: DeploymentOperations operations - :vartype deployment_operations: azure.mgmt.resource.resources.v2016_09_01.operations.DeploymentOperations - - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` + :ivar deployment_operations: DeploymentOperationsOperations operations + :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. """ def __init__( - self, credentials, subscription_id, base_url=None): - - self.config = ResourceManagementClientConfiguration(credentials, subscription_id, base_url) - super(ResourceManagementClient, self).__init__(self.config.credentials, self.config) + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = 'https://management.azure.com' + self._config = ResourceManagementClientConfiguration(credential, 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.api_version = '2016-09-01' self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self.deployments = DeploymentsOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.providers = ProvidersOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.resource_groups = ResourceGroupsOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.resources = ResourcesOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.tags = TagsOperations( - self._client, self.config, self._serialize, self._deserialize) - self.deployment_operations = DeploymentOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) + self.deployment_operations = DeploymentOperationsOperations( + self._client, self._config, self._serialize, self._deserialize) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> ResourceManagementClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) 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 new file mode 100644 index 000000000000..7f9b1bac71c5 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/__init__.py @@ -0,0 +1,10 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._resource_management_client_async import ResourceManagementClient +__all__ = ['ResourceManagementClient'] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/_configuration_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/_configuration_async.py new file mode 100644 index 000000000000..ea4079439c97 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/_configuration_async.py @@ -0,0 +1,65 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + +VERSION = "unknown" + +class ResourceManagementClientConfiguration(Configuration): + """Configuration for ResourceManagementClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :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 + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + 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 + self.api_version = "2016-09-01" + self.credential_scopes = ['https://management.azure.com/.default'] + self.credential_scopes.extend(kwargs.pop('credential_scopes', [])) + kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs: Any + ) -> None: + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + 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) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/_resource_management_client_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/_resource_management_client_async.py new file mode 100644 index 000000000000..9e3592db8120 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/_resource_management_client_async.py @@ -0,0 +1,84 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, Optional + +from azure.mgmt.core import AsyncARMPipelineClient +from msrest import Deserializer, Serializer + +from ._configuration_async import ResourceManagementClientConfiguration +from .operations_async import DeploymentsOperations +from .operations_async import ProvidersOperations +from .operations_async import ResourceGroupsOperations +from .operations_async import ResourcesOperations +from .operations_async import TagsOperations +from .operations_async import DeploymentOperationsOperations +from .. import models + + +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.aio.operations_async.DeploymentsOperations + :ivar providers: ProvidersOperations operations + :vartype providers: azure.mgmt.resource.resources.v2016_09_01.aio.operations_async.ProvidersOperations + :ivar resource_groups: ResourceGroupsOperations operations + :vartype resource_groups: azure.mgmt.resource.resources.v2016_09_01.aio.operations_async.ResourceGroupsOperations + :ivar resources: ResourcesOperations operations + :vartype resources: azure.mgmt.resource.resources.v2016_09_01.aio.operations_async.ResourcesOperations + :ivar tags: TagsOperations operations + :vartype tags: azure.mgmt.resource.resources.v2016_09_01.aio.operations_async.TagsOperations + :ivar deployment_operations: DeploymentOperationsOperations operations + :vartype deployment_operations: azure.mgmt.resource.resources.v2016_09_01.aio.operations_async.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. + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: Optional[str] = None, + **kwargs: 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) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + + self.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 close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "ResourceManagementClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/operations_async/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/operations_async/__init__.py new file mode 100644 index 000000000000..443d3be2d8df --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/operations_async/__init__.py @@ -0,0 +1,23 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._deployments_operations_async import DeploymentsOperations +from ._providers_operations_async import ProvidersOperations +from ._resource_groups_operations_async import ResourceGroupsOperations +from ._resources_operations_async import ResourcesOperations +from ._tags_operations_async import TagsOperations +from ._deployment_operations_operations_async import DeploymentOperationsOperations + +__all__ = [ + 'DeploymentsOperations', + 'ProvidersOperations', + 'ResourceGroupsOperations', + 'ResourcesOperations', + 'TagsOperations', + 'DeploymentOperationsOperations', +] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/operations_async/_deployment_operations_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/operations_async/_deployment_operations_operations_async.py new file mode 100644 index 000000000000..f7935d7b2d78 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/operations_async/_deployment_operations_operations_async.py @@ -0,0 +1,178 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import 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 ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class DeploymentOperationsOperations: + """DeploymentOperationsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2016_09_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def get( + self, + resource_group_name: str, + deployment_name: str, + operation_id: str, + **kwargs + ) -> "models.DeploymentOperation": + """Gets a deployments operation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param operation_id: The ID of the operation to get. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentOperation or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentOperation + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentOperation"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-09-01" + + # Construct URL + url = self.get.metadata['url'] # type: 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentOperation', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + def list( + self, + resource_group_name: str, + deployment_name: str, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.DeploymentOperationsListResult"]: + """Gets all deployments operations for a deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment with the operation to get. + :type deployment_name: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-09-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentOperationsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/operations_async/_deployments_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/operations_async/_deployments_operations_async.py new file mode 100644 index 000000000000..89fbdf06796e --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/operations_async/_deployments_operations_async.py @@ -0,0 +1,670 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.polling import AsyncNoPolling, AsyncPollingMethod, async_poller +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class DeploymentsOperations: + """DeploymentsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2016_09_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def _delete_initial( + self, + resource_group_name: str, + deployment_name: str, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def delete( + self, + resource_group_name: str, + deployment_name: str, + **kwargs + ) -> None: + """A template deployment that is currently running cannot be deleted. Deleting a template deployment removes the associated deployment operations. Deleting a template deployment does not affect the state of the resource group. This is an asynchronous operation that returns a status of 202 until the template deployment is successfully deleted. The Location response header contains the URI that is used to obtain the status of the process. While the process is running, a call to the URI in the Location header returns a status of 202. When the process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. + + Deletes a deployment from the deployment history. + + :param resource_group_name: The name of the resource group with the deployment to delete. The + name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment to delete. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def check_existence( + self, + resource_group_name: str, + deployment_name: str, + **kwargs + ) -> None: + """Checks whether the deployment exists. + + :param resource_group_name: The name of the resource group with the deployment to check. The + name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment to check. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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] + + # Construct and send request + 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 + + if response.status_code not in [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + 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, + deployment_name: str, + properties: "models.DeploymentProperties", + **kwargs + ) -> "models.DeploymentExtended": + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.Deployment(properties=properties) + api_version = "2016-09-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def create_or_update( + self, + resource_group_name: str, + deployment_name: str, + properties: "models.DeploymentProperties", + **kwargs + ) -> "models.DeploymentExtended": + """You can provide the template and parameters directly in the request or link to JSON files. + + Deploys resources to a resource group. + + :param resource_group_name: The name of the resource group to deploy the resources to. The name + is case insensitive. The resource group must already exist. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param properties: The deployment properties. + :type properties: ~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentProperties + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: DeploymentExtended + :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentExtended + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + properties=properties, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def get( + self, + resource_group_name: str, + deployment_name: str, + **kwargs + ) -> "models.DeploymentExtended": + """Gets a deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment to get. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExtended or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentExtended + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-09-01" + + # Construct URL + url = self.get.metadata['url'] # type: 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def cancel( + self, + resource_group_name: str, + deployment_name: str, + **kwargs + ) -> None: + """You can cancel a deployment only if the provisioningState is Accepted or Running. After the deployment is canceled, the provisioningState is set to Canceled. Canceling a template deployment stops the currently running template deployment and leaves the resource group partially deployed. + + Cancels a currently running template deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment to cancel. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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] + + # Construct and send request + 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 [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + cancel.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + + async def validate( + self, + resource_group_name: str, + deployment_name: str, + properties: "models.DeploymentProperties", + **kwargs + ) -> "models.DeploymentValidateResult": + """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param properties: The deployment properties. + :type properties: ~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentProperties + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentValidateResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentValidateResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.Deployment(properties=properties) + api_version = "2016-09-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 400]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + + if response.status_code == 400: + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + validate.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + async def export_template( + self, + resource_group_name: str, + deployment_name: str, + **kwargs + ) -> "models.DeploymentExportResult": + """Exports the template used for specified deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment from which to get the template. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentExportResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExportResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-09-01" + + # 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'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + def list( + self, + resource_group_name: str, + filter: Optional[str] = None, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.DeploymentListResult"]: + """Get all the deployments for a resource group. + + :param resource_group_name: The name of the resource group with the deployments to get. The + name is case insensitive. + :type resource_group_name: str + :param filter: The filter to apply on the operation. For example, you can use + $filter=provisioningState eq '{state}'. + :type filter: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-09-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/'} # type: ignore + + async def calculate_template_hash( + self, + template: object, + **kwargs + ) -> "models.TemplateHashResult": + """Calculate the hash of the given template. + + :param template: The template provided to calculate hash. + :type template: object + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateHashResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.TemplateHashResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TemplateHashResult"] + error_map = {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.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'] = 'application/json' + + # Construct and send request + 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) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('TemplateHashResult', pipeline_response) + + if cls: + 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_async/_providers_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/operations_async/_providers_operations_async.py new file mode 100644 index 000000000000..d75397247cba --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/operations_async/_providers_operations_async.py @@ -0,0 +1,279 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import 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 ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ProvidersOperations: + """ProvidersOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2016_09_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def unregister( + self, + resource_provider_namespace: str, + **kwargs + ) -> "models.Provider": + """Unregisters a subscription from a resource provider. + + :param resource_provider_namespace: The namespace of the resource provider to unregister. + :type resource_provider_namespace: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Provider or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.Provider + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Provider"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-09-01" + + # 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'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Provider', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + unregister.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister'} # type: ignore + + async def register( + self, + resource_provider_namespace: str, + **kwargs + ) -> "models.Provider": + """Registers a subscription with a resource provider. + + :param resource_provider_namespace: The namespace of the resource provider to register. + :type resource_provider_namespace: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Provider or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.Provider + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Provider"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-09-01" + + # 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'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Provider', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + register.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register'} # type: ignore + + def list( + self, + top: Optional[int] = None, + expand: Optional[str] = None, + **kwargs + ) -> AsyncIterable["models.ProviderListResult"]: + """Gets all resource providers for a subscription. + + :param top: The number of results to return. If null is passed returns all deployments. + :type top: int + :param expand: The properties to include in the results. For example, use &$expand=metadata in + the query string to retrieve resource provider metadata. To include property aliases in + response, use $expand=resourceTypes/aliases. + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of ProviderListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-09-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ProviderListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers'} # type: ignore + + async def get( + self, + resource_provider_namespace: str, + expand: Optional[str] = None, + **kwargs + ) -> "models.Provider": + """Gets the specified resource provider. + + :param resource_provider_namespace: The namespace of the resource provider. + :type resource_provider_namespace: str + :param expand: The $expand query parameter. For example, to include property aliases in + response, use $expand=resourceTypes/aliases. + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Provider or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.Provider + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Provider"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-09-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Provider', pipeline_response) + + if cls: + 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_async/_resource_groups_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/operations_async/_resource_groups_operations_async.py new file mode 100644 index 000000000000..26b7eba00acd --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/operations_async/_resource_groups_operations_async.py @@ -0,0 +1,585 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, List, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.polling import AsyncNoPolling, AsyncPollingMethod, async_poller +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ResourceGroupsOperations: + """ResourceGroupsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2016_09_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list_resources( + self, + resource_group_name: str, + filter: Optional[str] = None, + expand: Optional[str] = None, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.ResourceListResult"]: + """Get all the resources for a resource group. + + :param resource_group_name: The resource group with the resources to get. + :type resource_group_name: str + :param filter: The filter to apply on the operation. + :type filter: str + :param expand: Comma-separated list of additional properties to be included in the response. + Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, + ``$expand=createdTime,changedTime``. + :type expand: str + :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 ResourceListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-09-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ResourceListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources'} # type: ignore + + async def check_existence( + self, + resource_group_name: str, + **kwargs + ) -> None: + """Checks whether a resource group exists. + + :param resource_group_name: The name of the resource group to check. 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: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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] + + # Construct and send request + 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 + + if response.status_code not in [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + async def create_or_update( + self, + resource_group_name: str, + parameters: "models.ResourceGroup", + **kwargs + ) -> "models.ResourceGroup": + """Creates a resource group. + + :param resource_group_name: The name of the resource group to create or update. + :type resource_group_name: str + :param parameters: Parameters supplied to the create or update a resource group. + :type parameters: ~azure.mgmt.resource.resources.v2016_09_01.models.ResourceGroup + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.ResourceGroup + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceGroup"] + error_map = {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.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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ResourceGroup', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ResourceGroup', pipeline_response) + + if cls: + 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, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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] + + # Construct and send request + 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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + async def delete( + self, + resource_group_name: str, + **kwargs + ) -> None: + """When you delete a resource group, all of its resources are also deleted. Deleting a resource group deletes all of its template deployments and currently stored operations. + + Deletes a resource group. + + :param resource_group_name: The name of the resource group to delete. 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 + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + async def get( + self, + resource_group_name: str, + **kwargs + ) -> "models.ResourceGroup": + """Gets a resource group. + + :param resource_group_name: The name of the resource group to get. 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: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.ResourceGroup + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceGroup"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-09-01" + + # Construct URL + url = self.get.metadata['url'] # type: 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ResourceGroup', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + async def patch( + self, + resource_group_name: str, + parameters: "models.ResourceGroup", + **kwargs + ) -> "models.ResourceGroup": + """Resource groups can be updated through a simple PATCH operation to a group address. The format of the request is the same as that for creating a resource group. If a field is unspecified, the current value is retained. + + Updates a resource group. + + :param resource_group_name: The name of the resource group to update. The name is case + insensitive. + :type resource_group_name: str + :param parameters: Parameters supplied to update a resource group. + :type parameters: ~azure.mgmt.resource.resources.v2016_09_01.models.ResourceGroup + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.ResourceGroup + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceGroup"] + error_map = {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.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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ResourceGroup', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + patch.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + async def export_template( + self, + resource_group_name: str, + resources: Optional[List[str]] = None, + options: Optional[str] = None, + **kwargs + ) -> "models.ResourceGroupExportResult": + """Captures the specified resource group as a template. + + :param resource_group_name: The name of the resource group to export as a template. + :type resource_group_name: str + :param 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', + 'SkipResourceNameParameterization', 'SkipAllParameterization'. + :type options: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroupExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.ResourceGroupExportResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceGroupExportResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.ExportTemplateRequest(resources=resources, options=options) + api_version = "2016-09-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ResourceGroupExportResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate'} # type: ignore + + def list( + self, + filter: Optional[str] = None, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.ResourceGroupListResult"]: + """Gets all the resource groups for a subscription. + + :param filter: The filter to apply on the operation. + :type filter: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-09-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ResourceGroupListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/operations_async/_resources_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/operations_async/_resources_operations_async.py new file mode 100644 index 000000000000..84805b9c7f44 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/operations_async/_resources_operations_async.py @@ -0,0 +1,1100 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, List, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.polling import AsyncNoPolling, AsyncPollingMethod, async_poller +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ResourcesOperations: + """ResourcesOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2016_09_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def _move_resources_initial( + self, + source_resource_group_name: str, + resources: Optional[List[str]] = None, + target_resource_group: Optional[str] = None, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.ResourcesMoveInfo(resources=resources, target_resource_group=target_resource_group) + 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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + + # Construct and send request + 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 + + if response.status_code not in [202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore + + async def move_resources( + self, + source_resource_group_name: str, + resources: Optional[List[str]] = None, + target_resource_group: Optional[str] = None, + **kwargs + ) -> None: + """The resources to move must be in the same source resource group. The target resource group may be in a different subscription. When moving resources, both the source group and the target group are locked for the duration of the operation. Write and delete operations are blocked on the groups until the move completes. + + Moves resources from one resource group to another resource group. + + :param source_resource_group_name: The name of the resource group containing the resources to + move. + :type source_resource_group_name: str + :param resources: The IDs of the resources. + :type resources: list[str] + :param target_resource_group: The target resource group. + :type target_resource_group: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._move_resources_initial( + source_resource_group_name=source_resource_group_name, + resources=resources, + target_resource_group=target_resource_group, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore + + def list( + self, + filter: Optional[str] = None, + expand: Optional[str] = None, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.ResourceListResult"]: + """Get all the resources in a subscription. + + :param filter: The filter to apply on the operation. + :type filter: str + :param expand: Comma-separated list of additional properties to be included in the response. + Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, + ``$expand=createdTime,changedTime``. + :type expand: str + :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 ResourceListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-09-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ResourceListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resources'} # type: ignore + + async def check_existence( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + **kwargs + ) -> None: + """Checks whether a resource exists. + + :param resource_group_name: The name of the resource group containing the resource to check. + The name is case insensitive. + :type resource_group_name: str + :param resource_provider_namespace: The resource provider of the resource to check. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. + :type parent_resource_path: str + :param resource_type: The resource type. + :type resource_type: str + :param resource_name: The name of the resource to check whether it exists. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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\._\(\)]+$'), + 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), + 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_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] + + # Construct and send request + 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 + + if response.status_code not in [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + 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, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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\._\(\)]+$'), + 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), + 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + async def delete( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + **kwargs + ) -> None: + """Deletes a resource. + + :param resource_group_name: The name of the resource group that contains the resource to + delete. The name is case insensitive. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. + :type parent_resource_path: str + :param resource_type: The resource type. + :type resource_type: str + :param resource_name: The name of the resource to delete. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._delete_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, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + parameters: "models.GenericResource", + **kwargs + ) -> "models.GenericResource": + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {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._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'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 201, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('GenericResource', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + async def create_or_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + parameters: "models.GenericResource", + **kwargs + ) -> "models.GenericResource": + """Creates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to create. + :type resource_type: str + :param resource_name: The name of the resource to create. + :type resource_name: str + :param parameters: Parameters for creating or updating the resource. + :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 polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: GenericResource + :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._create_or_update_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, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + 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, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + parameters: "models.GenericResource", + **kwargs + ) -> "models.GenericResource": + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {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._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'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + async def update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + parameters: "models.GenericResource", + **kwargs + ) -> "models.GenericResource": + """Updates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to update. + :type resource_type: str + :param resource_name: The name of the resource to update. + :type resource_name: str + :param parameters: Parameters for updating the resource. + :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 polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: GenericResource + :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._update_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, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + async def get( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + **kwargs + ) -> "models.GenericResource": + """Gets a resource. + + :param resource_group_name: The name of the resource group containing the resource to get. The + name is case insensitive. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. + :type parent_resource_path: str + :param resource_type: The resource type of the resource. + :type resource_type: str + :param resource_name: The name of the resource to get. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GenericResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-09-01" + + # Construct URL + url = self.get.metadata['url'] # type: 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + async def check_existence_by_id( + self, + resource_id: str, + **kwargs + ) -> None: + """Checks by ID whether a resource exists. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + :type resource_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-09-01" + + # 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] + + # Construct and send request + 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 + + if response.status_code not in [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + 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, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-09-01" + + # 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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + async def delete_by_id( + self, + resource_id: str, + **kwargs + ) -> None: + """Deletes a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + :type resource_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._delete_by_id_initial( + resource_id=resource_id, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + delete_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + + async def _create_or_update_by_id_initial( + self, + resource_id: str, + parameters: "models.GenericResource", + **kwargs + ) -> "models.GenericResource": + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {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._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) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 201, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('GenericResource', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + async def create_or_update_by_id( + self, + resource_id: str, + parameters: "models.GenericResource", + **kwargs + ) -> "models.GenericResource": + """Create a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + :type resource_id: str + :param parameters: Create or update resource parameters. + :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 polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: GenericResource + :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._create_or_update_by_id_initial( + resource_id=resource_id, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + create_or_update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + + async def _update_by_id_initial( + self, + resource_id: str, + parameters: "models.GenericResource", + **kwargs + ) -> "models.GenericResource": + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {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._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) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + async def update_by_id( + self, + resource_id: str, + parameters: "models.GenericResource", + **kwargs + ) -> "models.GenericResource": + """Updates a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + :type resource_id: str + :param parameters: Update resource parameters. + :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 polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: GenericResource + :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._update_by_id_initial( + resource_id=resource_id, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + + async def get_by_id( + self, + resource_id: str, + **kwargs + ) -> "models.GenericResource": + """Gets a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + :type resource_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GenericResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-09-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + 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_async/_tags_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/operations_async/_tags_operations_async.py new file mode 100644 index 000000000000..230aa5ae98cc --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/aio/operations_async/_tags_operations_async.py @@ -0,0 +1,327 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import 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 ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class TagsOperations: + """TagsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2016_09_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def delete_value( + self, + tag_name: str, + tag_value: str, + **kwargs + ) -> None: + """Deletes a tag value. + + :param tag_name: The name of the tag. + :type tag_name: str + :param tag_value: The value of the tag to delete. + :type tag_value: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore + + async def create_or_update_value( + self, + tag_name: str, + tag_value: str, + **kwargs + ) -> "models.TagValue": + """Creates a tag value. The name of the tag must already exist. + + :param tag_name: The name of the tag. + :type tag_name: str + :param tag_value: The value of the tag to create. + :type tag_value: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagValue or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.TagValue + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TagValue"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-09-01" + + # 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'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('TagValue', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('TagValue', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore + + async def create_or_update( + self, + tag_name: str, + **kwargs + ) -> "models.TagDetails": + """The tag name can have a maximum of 512 characters and is case insensitive. Tag names created by Azure have prefixes of microsoft, azure, or windows. You cannot create tags with one of these prefixes. + + Creates a tag in the subscription. + + :param tag_name: The name of the tag to create. + :type tag_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagDetails or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.TagDetails + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TagDetails"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-09-01" + + # 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'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('TagDetails', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('TagDetails', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore + + async def delete( + self, + tag_name: str, + **kwargs + ) -> None: + """You must remove all values from a resource tag before you can delete it. + + Deletes a tag from the subscription. + + :param tag_name: The name of the tag. + :type tag_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore + + def list( + self, + **kwargs + ) -> AsyncIterable["models.TagsListResult"]: + """Gets the names and values of all resource tags that are defined in a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of TagsListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-09-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('TagsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/models/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/models/__init__.py index ef78f45062ce..0fa0b4f5f587 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/models/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/models/__init__.py @@ -1,12 +1,9 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- try: @@ -19,8 +16,10 @@ from ._models_py3 import DeploymentExportResult from ._models_py3 import DeploymentExtended from ._models_py3 import DeploymentExtendedFilter + from ._models_py3 import DeploymentListResult from ._models_py3 import DeploymentOperation from ._models_py3 import DeploymentOperationProperties + from ._models_py3 import DeploymentOperationsListResult from ._models_py3 import DeploymentProperties from ._models_py3 import DeploymentPropertiesExtended from ._models_py3 import DeploymentValidateResult @@ -35,12 +34,15 @@ from ._models_py3 import ParametersLink from ._models_py3 import Plan from ._models_py3 import Provider + from ._models_py3 import ProviderListResult from ._models_py3 import ProviderResourceType from ._models_py3 import Resource from ._models_py3 import ResourceGroup from ._models_py3 import ResourceGroupExportResult from ._models_py3 import ResourceGroupFilter + from ._models_py3 import ResourceGroupListResult from ._models_py3 import ResourceGroupProperties + from ._models_py3 import ResourceListResult from ._models_py3 import ResourceManagementErrorWithDetails from ._models_py3 import ResourceProviderOperationDisplayProperties from ._models_py3 import ResourcesMoveInfo @@ -49,61 +51,62 @@ from ._models_py3 import TagCount from ._models_py3 import TagDetails from ._models_py3 import TagValue + from ._models_py3 import TagsListResult from ._models_py3 import TargetResource from ._models_py3 import TemplateHashResult from ._models_py3 import TemplateLink except (SyntaxError, ImportError): - from ._models import AliasPathType - from ._models import AliasType - from ._models import BasicDependency - from ._models import DebugSetting - from ._models import Dependency - from ._models import Deployment - from ._models import DeploymentExportResult - from ._models import DeploymentExtended - from ._models import DeploymentExtendedFilter - from ._models import DeploymentOperation - from ._models import DeploymentOperationProperties - from ._models import DeploymentProperties - from ._models import DeploymentPropertiesExtended - from ._models import DeploymentValidateResult - from ._models import ErrorAdditionalInfo - from ._models import ErrorResponse - from ._models import ExportTemplateRequest - from ._models import GenericResource - from ._models import GenericResourceExpanded - from ._models import GenericResourceFilter - from ._models import HttpMessage - from ._models import Identity - from ._models import ParametersLink - from ._models import Plan - from ._models import Provider - from ._models import ProviderResourceType - from ._models import Resource - from ._models import ResourceGroup - from ._models import ResourceGroupExportResult - from ._models import ResourceGroupFilter - from ._models import ResourceGroupProperties - from ._models import ResourceManagementErrorWithDetails - from ._models import ResourceProviderOperationDisplayProperties - from ._models import ResourcesMoveInfo - from ._models import Sku - from ._models import SubResource - from ._models import TagCount - from ._models import TagDetails - from ._models import TagValue - from ._models import TargetResource - from ._models import TemplateHashResult - from ._models import TemplateLink -from ._paged_models import DeploymentExtendedPaged -from ._paged_models import DeploymentOperationPaged -from ._paged_models import GenericResourceExpandedPaged -from ._paged_models import ProviderPaged -from ._paged_models import ResourceGroupPaged -from ._paged_models import TagDetailsPaged + from ._models import AliasPathType # type: ignore + from ._models import AliasType # type: ignore + from ._models import BasicDependency # type: ignore + from ._models import DebugSetting # type: ignore + from ._models import Dependency # type: ignore + from ._models import Deployment # type: ignore + from ._models import DeploymentExportResult # type: ignore + from ._models import DeploymentExtended # type: ignore + from ._models import DeploymentExtendedFilter # type: ignore + from ._models import DeploymentListResult # type: ignore + from ._models import DeploymentOperation # type: ignore + from ._models import DeploymentOperationProperties # type: ignore + from ._models import DeploymentOperationsListResult # type: ignore + from ._models import DeploymentProperties # type: ignore + from ._models import DeploymentPropertiesExtended # type: ignore + from ._models import DeploymentValidateResult # type: ignore + from ._models import ErrorAdditionalInfo # type: ignore + from ._models import ErrorResponse # type: ignore + from ._models import ExportTemplateRequest # type: ignore + from ._models import GenericResource # type: ignore + from ._models import GenericResourceExpanded # type: ignore + from ._models import GenericResourceFilter # type: ignore + from ._models import HttpMessage # type: ignore + from ._models import Identity # type: ignore + from ._models import ParametersLink # type: ignore + from ._models import Plan # type: ignore + from ._models import Provider # type: ignore + from ._models import ProviderListResult # type: ignore + from ._models import ProviderResourceType # type: ignore + from ._models import Resource # type: ignore + from ._models import ResourceGroup # type: ignore + from ._models import ResourceGroupExportResult # type: ignore + from ._models import ResourceGroupFilter # type: ignore + from ._models import ResourceGroupListResult # type: ignore + from ._models import ResourceGroupProperties # type: ignore + from ._models import ResourceListResult # type: ignore + from ._models import ResourceManagementErrorWithDetails # type: ignore + from ._models import ResourceProviderOperationDisplayProperties # type: ignore + from ._models import ResourcesMoveInfo # type: ignore + from ._models import Sku # type: ignore + from ._models import SubResource # type: ignore + from ._models import TagCount # type: ignore + from ._models import TagDetails # type: ignore + from ._models import TagValue # type: ignore + from ._models import TagsListResult # type: ignore + from ._models import TargetResource # type: ignore + from ._models import TemplateHashResult # type: ignore + from ._models import TemplateLink # type: ignore + from ._resource_management_client_enums import ( DeploymentMode, - ResourceIdentityType, ) __all__ = [ @@ -116,8 +119,10 @@ 'DeploymentExportResult', 'DeploymentExtended', 'DeploymentExtendedFilter', + 'DeploymentListResult', 'DeploymentOperation', 'DeploymentOperationProperties', + 'DeploymentOperationsListResult', 'DeploymentProperties', 'DeploymentPropertiesExtended', 'DeploymentValidateResult', @@ -132,12 +137,15 @@ 'ParametersLink', 'Plan', 'Provider', + 'ProviderListResult', 'ProviderResourceType', 'Resource', 'ResourceGroup', 'ResourceGroupExportResult', 'ResourceGroupFilter', + 'ResourceGroupListResult', 'ResourceGroupProperties', + 'ResourceListResult', 'ResourceManagementErrorWithDetails', 'ResourceProviderOperationDisplayProperties', 'ResourcesMoveInfo', @@ -146,15 +154,9 @@ 'TagCount', 'TagDetails', 'TagValue', + 'TagsListResult', 'TargetResource', 'TemplateHashResult', 'TemplateLink', - 'DeploymentExtendedPaged', - 'ProviderPaged', - 'GenericResourceExpandedPaged', - 'ResourceGroupPaged', - 'TagDetailsPaged', - 'DeploymentOperationPaged', 'DeploymentMode', - 'ResourceIdentityType', ] 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 846b25951e64..44aff0e4dfa9 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 @@ -1,20 +1,16 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.serialization import Model -from msrest.exceptions import HttpOperationError +import msrest.serialization -class AliasPathType(Model): - """The type of the paths for alias. . +class AliasPathType(msrest.serialization.Model): + """The type of the paths for alias. :param path: The path of an alias. :type path: str @@ -27,20 +23,22 @@ class AliasPathType(Model): 'api_versions': {'key': 'apiVersions', 'type': '[str]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(AliasPathType, self).__init__(**kwargs) self.path = kwargs.get('path', None) self.api_versions = kwargs.get('api_versions', None) -class AliasType(Model): - """The alias type. . +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] + :type paths: list[~azure.mgmt.resource.resources.v2016_09_01.models.AliasPathType] """ _attribute_map = { @@ -48,13 +46,16 @@ class AliasType(Model): 'paths': {'key': 'paths', 'type': '[AliasPathType]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(AliasType, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.paths = kwargs.get('paths', None) -class BasicDependency(Model): +class BasicDependency(msrest.serialization.Model): """Deployment dependency information. :param id: The ID of the dependency. @@ -71,52 +72,25 @@ class BasicDependency(Model): 'resource_name': {'key': 'resourceName', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(BasicDependency, self).__init__(**kwargs) self.id = kwargs.get('id', None) self.resource_type = kwargs.get('resource_type', None) self.resource_name = kwargs.get('resource_name', None) -class CloudError(Model): - """An error response for a resource management request. - - :param error: - :type error: - ~azure.mgmt.resource.resources.v2016_09_01.models.ErrorResponse - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorResponse'}, - } - - def __init__(self, **kwargs): - super(CloudError, self).__init__(**kwargs) - self.error = kwargs.get('error', None) - - -class CloudErrorException(HttpOperationError): - """Server responsed with exception of type: 'CloudError'. - - :param deserialize: A deserializer - :param response: Server response to be deserialized. - """ - - def __init__(self, deserialize, response, *args): - - super(CloudErrorException, self).__init__(deserialize, response, 'CloudError', *args) - - -class DebugSetting(Model): +class DebugSetting(msrest.serialization.Model): """DebugSetting. - :param 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. + :param 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 """ @@ -124,17 +98,19 @@ class DebugSetting(Model): 'detail_level': {'key': 'detailLevel', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DebugSetting, self).__init__(**kwargs) self.detail_level = kwargs.get('detail_level', None) -class Dependency(Model): +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] + :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. @@ -150,7 +126,10 @@ class Dependency(Model): 'resource_name': {'key': 'resourceName', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Dependency, self).__init__(**kwargs) self.depends_on = kwargs.get('depends_on', None) self.id = kwargs.get('id', None) @@ -158,14 +137,13 @@ def __init__(self, **kwargs): self.resource_name = kwargs.get('resource_name', None) -class Deployment(Model): +class Deployment(msrest.serialization.Model): """Deployment operation parameters. 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 + :type properties: ~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentProperties """ _validation = { @@ -176,13 +154,16 @@ class Deployment(Model): 'properties': {'key': 'properties', 'type': 'DeploymentProperties'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Deployment, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) + self.properties = kwargs['properties'] -class DeploymentExportResult(Model): - """The deployment export result. . +class DeploymentExportResult(msrest.serialization.Model): + """The deployment export result. :param template: The template content. :type template: object @@ -192,16 +173,18 @@ class DeploymentExportResult(Model): 'template': {'key': 'template', 'type': 'object'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentExportResult, self).__init__(**kwargs) self.template = kwargs.get('template', None) -class DeploymentExtended(Model): +class DeploymentExtended(msrest.serialization.Model): """Deployment information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. @@ -225,14 +208,17 @@ class DeploymentExtended(Model): 'properties': {'key': 'properties', 'type': 'DeploymentPropertiesExtended'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentExtended, self).__init__(**kwargs) self.id = None - self.name = kwargs.get('name', None) + self.name = kwargs['name'] self.properties = kwargs.get('properties', None) -class DeploymentExtendedFilter(Model): +class DeploymentExtendedFilter(msrest.serialization.Model): """Deployment filter. :param provisioning_state: The provisioning state. @@ -243,16 +229,47 @@ class DeploymentExtendedFilter(Model): 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentExtendedFilter, self).__init__(**kwargs) self.provisioning_state = kwargs.get('provisioning_state', None) -class DeploymentOperation(Model): +class DeploymentListResult(msrest.serialization.Model): + """List of deployments. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[DeploymentExtended]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(DeploymentListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = None + + +class DeploymentOperation(msrest.serialization.Model): """Deployment operation information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Full deployment operation ID. :vartype id: str @@ -274,23 +291,25 @@ class DeploymentOperation(Model): 'properties': {'key': 'properties', 'type': 'DeploymentOperationProperties'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentOperation, self).__init__(**kwargs) self.id = None self.operation_id = None self.properties = kwargs.get('properties', None) -class DeploymentOperationProperties(Model): +class DeploymentOperationProperties(msrest.serialization.Model): """Deployment operation properties. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar provisioning_state: The state of the provisioning. :vartype provisioning_state: str :ivar timestamp: The date and time of the operation. - :vartype timestamp: datetime + :vartype timestamp: ~datetime.datetime :ivar service_request_id: Deployment operation service request id. :vartype service_request_id: str :ivar status_code: Operation status code. @@ -298,14 +317,11 @@ class DeploymentOperationProperties(Model): :ivar status_message: Operation status message. :vartype status_message: object :ivar target_resource: The target resource. - :vartype target_resource: - ~azure.mgmt.resource.resources.v2016_09_01.models.TargetResource + :vartype target_resource: ~azure.mgmt.resource.resources.v2016_09_01.models.TargetResource :ivar request: The HTTP request message. - :vartype request: - ~azure.mgmt.resource.resources.v2016_09_01.models.HttpMessage + :vartype request: ~azure.mgmt.resource.resources.v2016_09_01.models.HttpMessage :ivar response: The HTTP response message. - :vartype response: - ~azure.mgmt.resource.resources.v2016_09_01.models.HttpMessage + :vartype response: ~azure.mgmt.resource.resources.v2016_09_01.models.HttpMessage """ _validation = { @@ -330,7 +346,10 @@ class DeploymentOperationProperties(Model): 'response': {'key': 'response', 'type': 'HttpMessage'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentOperationProperties, self).__init__(**kwargs) self.provisioning_state = None self.timestamp = None @@ -342,45 +361,66 @@ def __init__(self, **kwargs): self.response = None -class DeploymentProperties(Model): +class DeploymentOperationsListResult(msrest.serialization.Model): + """List of deployment operations. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[DeploymentOperation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(DeploymentOperationsListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = None + + +class DeploymentProperties(msrest.serialization.Model): """Deployment properties. 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 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. + :param 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: object - :param 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. 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. + :param 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. + 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: object - :param 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 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 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 + 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 + :type debug_setting: ~azure.mgmt.resource.resources.v2016_09_01.models.DebugSetting """ _validation = { @@ -392,62 +432,55 @@ class DeploymentProperties(Model): 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, 'parameters': {'key': 'parameters', 'type': 'object'}, 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, - 'mode': {'key': 'mode', 'type': 'DeploymentMode'}, + 'mode': {'key': 'mode', 'type': 'str'}, 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentProperties, self).__init__(**kwargs) self.template = kwargs.get('template', None) self.template_link = kwargs.get('template_link', None) self.parameters = kwargs.get('parameters', None) self.parameters_link = kwargs.get('parameters_link', None) - self.mode = kwargs.get('mode', None) + self.mode = kwargs['mode'] self.debug_setting = kwargs.get('debug_setting', None) -class DeploymentPropertiesExtended(Model): +class DeploymentPropertiesExtended(msrest.serialization.Model): """Deployment properties with additional details. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :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 + :vartype timestamp: ~datetime.datetime :param outputs: Key/value pairs that represent deployment output. :type outputs: object - :param providers: The list of resource providers needed for the - deployment. - :type providers: - list[~azure.mgmt.resource.resources.v2016_09_01.models.Provider] + :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 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: object - :param 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. + :param 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: object - :param 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 include: 'Incremental', 'Complete' - :type mode: str or - ~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentMode + :param 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 + 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 + :type debug_setting: ~azure.mgmt.resource.resources.v2016_09_01.models.DebugSetting """ _validation = { @@ -467,11 +500,14 @@ class DeploymentPropertiesExtended(Model): 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, 'parameters': {'key': 'parameters', 'type': 'object'}, 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, - 'mode': {'key': 'mode', 'type': 'DeploymentMode'}, + 'mode': {'key': 'mode', 'type': 'str'}, 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentPropertiesExtended, self).__init__(**kwargs) self.provisioning_state = None self.correlation_id = None @@ -487,7 +523,7 @@ def __init__(self, **kwargs): self.debug_setting = kwargs.get('debug_setting', None) -class DeploymentValidateResult(Model): +class DeploymentValidateResult(msrest.serialization.Model): """Information from validate template deployment response. :param error: Validation error. @@ -503,17 +539,19 @@ class DeploymentValidateResult(Model): 'properties': {'key': 'properties', 'type': 'DeploymentPropertiesExtended'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentValidateResult, self).__init__(**kwargs) self.error = kwargs.get('error', None) self.properties = kwargs.get('properties', None) -class ErrorAdditionalInfo(Model): +class ErrorAdditionalInfo(msrest.serialization.Model): """The resource management error additional info. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar type: The additional info type. :vartype type: str @@ -531,17 +569,19 @@ class ErrorAdditionalInfo(Model): 'info': {'key': 'info', 'type': 'object'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None -class ErrorResponse(Model): +class ErrorResponse(msrest.serialization.Model): """The resource management error response. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar code: The error code. :vartype code: str @@ -550,8 +590,7 @@ class ErrorResponse(Model): :ivar target: The error target. :vartype target: str :ivar details: The error details. - :vartype details: - list[~azure.mgmt.resource.resources.v2016_09_01.models.ErrorResponse] + :vartype details: list[~azure.mgmt.resource.resources.v2016_09_01.models.ErrorResponse] :ivar additional_info: The error additional info. :vartype additional_info: list[~azure.mgmt.resource.resources.v2016_09_01.models.ErrorAdditionalInfo] @@ -573,7 +612,10 @@ class ErrorResponse(Model): 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ErrorResponse, self).__init__(**kwargs) self.code = None self.message = None @@ -582,16 +624,15 @@ def __init__(self, **kwargs): self.additional_info = None -class ExportTemplateRequest(Model): +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, supply an array with single entry '*'. + :param 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', 'SkipResourceNameParameterization', - 'SkipAllParameterization' + :param options: The export template options. A CSV-formatted list containing zero or more of + the following: 'IncludeParameterDefaultValue', 'IncludeComments', + 'SkipResourceNameParameterization', 'SkipAllParameterization'. :type options: str """ @@ -600,27 +641,29 @@ class ExportTemplateRequest(Model): 'options': {'key': 'options', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ExportTemplateRequest, self).__init__(**kwargs) self.resources = kwargs.get('resources', None) self.options = kwargs.get('options', None) -class Resource(Model): +class Resource(msrest.serialization.Model): """Resource. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID + :ivar id: Resource ID. :vartype id: str - :ivar name: Resource name + :ivar name: Resource name. :vartype name: str - :ivar type: Resource type + :ivar type: Resource type. :vartype type: str - :param location: Resource location + :param location: Resource location. :type location: str - :param tags: Resource tags + :param tags: A set of tags. Resource tags. :type tags: dict[str, str] """ @@ -638,7 +681,10 @@ class Resource(Model): 'tags': {'key': 'tags', 'type': '{str}'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -650,18 +696,17 @@ def __init__(self, **kwargs): class GenericResource(Resource): """Resource information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID + :ivar id: Resource ID. :vartype id: str - :ivar name: Resource name + :ivar name: Resource name. :vartype name: str - :ivar type: Resource type + :ivar type: Resource type. :vartype type: str - :param location: Resource location + :param location: Resource location. :type location: str - :param tags: Resource tags + :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 @@ -698,7 +743,10 @@ class GenericResource(Resource): 'identity': {'key': 'identity', 'type': 'Identity'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(GenericResource, self).__init__(**kwargs) self.plan = kwargs.get('plan', None) self.properties = kwargs.get('properties', None) @@ -711,18 +759,17 @@ def __init__(self, **kwargs): class GenericResourceExpanded(GenericResource): """Resource information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID + :ivar id: Resource ID. :vartype id: str - :ivar name: Resource name + :ivar name: Resource name. :vartype name: str - :ivar type: Resource type + :ivar type: Resource type. :vartype type: str - :param location: Resource location + :param location: Resource location. :type location: str - :param tags: Resource tags + :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 @@ -736,14 +783,14 @@ class GenericResourceExpanded(GenericResource): :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 created_time: The created time of the resource. This is only present - if requested via the $expand query parameter. - :vartype created_time: datetime - :ivar changed_time: The changed time of the resource. This is only present - if requested via the $expand query parameter. - :vartype changed_time: datetime - :ivar provisioning_state: The provisioning state of the resource. This is - only present if requested via the $expand query parameter. + :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 + :ivar changed_time: The changed time of the resource. This is only present if requested via the + $expand query parameter. + :vartype changed_time: ~datetime.datetime + :ivar provisioning_state: The provisioning state of the resource. This is only present if + requested via the $expand query parameter. :vartype provisioning_state: str """ @@ -774,14 +821,17 @@ class GenericResourceExpanded(GenericResource): 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(GenericResourceExpanded, self).__init__(**kwargs) self.created_time = None self.changed_time = None self.provisioning_state = None -class GenericResourceFilter(Model): +class GenericResourceFilter(msrest.serialization.Model): """Resource filter. :param resource_type: The resource type. @@ -798,14 +848,17 @@ class GenericResourceFilter(Model): 'tagvalue': {'key': 'tagvalue', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(GenericResourceFilter, self).__init__(**kwargs) self.resource_type = kwargs.get('resource_type', None) self.tagname = kwargs.get('tagname', None) self.tagvalue = kwargs.get('tagvalue', None) -class HttpMessage(Model): +class HttpMessage(msrest.serialization.Model): """HttpMessage. :param content: HTTP message content. @@ -816,53 +869,58 @@ class HttpMessage(Model): 'content': {'key': 'content', 'type': 'object'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(HttpMessage, self).__init__(**kwargs) self.content = kwargs.get('content', None) -class Identity(Model): +class Identity(msrest.serialization.Model): """Identity for the resource. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar principal_id: The principal ID of resource identity. :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :param type: The identity type. Possible values include: 'SystemAssigned' - :type type: str or - ~azure.mgmt.resource.resources.v2016_09_01.models.ResourceIdentityType + :ivar type: The identity type. Default value: "SystemAssigned". + :vartype type: str """ _validation = { 'principal_id': {'readonly': True}, 'tenant_id': {'readonly': True}, + 'type': {'constant': True}, } _attribute_map = { 'principal_id': {'key': 'principalId', 'type': 'str'}, 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'ResourceIdentityType'}, + 'type': {'key': 'type', 'type': 'str'}, } - def __init__(self, **kwargs): + type = "SystemAssigned" + + def __init__( + self, + **kwargs + ): super(Identity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None - self.type = kwargs.get('type', None) -class ParametersLink(Model): +class ParametersLink(msrest.serialization.Model): """Entity representing the reference to the deployment parameters. 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. + :param content_version: If included, must match the ContentVersion in the template. :type content_version: str """ @@ -875,13 +933,16 @@ class ParametersLink(Model): 'content_version': {'key': 'contentVersion', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ParametersLink, self).__init__(**kwargs) - self.uri = kwargs.get('uri', None) + self.uri = kwargs['uri'] self.content_version = kwargs.get('content_version', None) -class Plan(Model): +class Plan(msrest.serialization.Model): """Plan for the resource. :param name: The plan ID. @@ -901,7 +962,10 @@ class Plan(Model): 'promotion_code': {'key': 'promotionCode', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Plan, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.publisher = kwargs.get('publisher', None) @@ -909,11 +973,10 @@ def __init__(self, **kwargs): self.promotion_code = kwargs.get('promotion_code', None) -class Provider(Model): +class Provider(msrest.serialization.Model): """Resource provider information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The provider ID. :vartype id: str @@ -939,7 +1002,10 @@ class Provider(Model): 'resource_types': {'key': 'resourceTypes', 'type': '[ProviderResourceType]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Provider, self).__init__(**kwargs) self.id = None self.namespace = kwargs.get('namespace', None) @@ -947,17 +1013,44 @@ def __init__(self, **kwargs): self.resource_types = None -class ProviderResourceType(Model): +class ProviderListResult(msrest.serialization.Model): + """List of resource providers. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Provider]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ProviderListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = None + + +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. + :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] + :type aliases: list[~azure.mgmt.resource.resources.v2016_09_01.models.AliasType] :param api_versions: The API version. :type api_versions: list[str] :param properties: The properties. @@ -972,7 +1065,10 @@ class ProviderResourceType(Model): 'properties': {'key': 'properties', 'type': '{str}'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ProviderResourceType, self).__init__(**kwargs) self.resource_type = kwargs.get('resource_type', None) self.locations = kwargs.get('locations', None) @@ -981,11 +1077,10 @@ def __init__(self, **kwargs): self.properties = kwargs.get('properties', None) -class ResourceGroup(Model): +class ResourceGroup(msrest.serialization.Model): """Resource group information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. @@ -993,17 +1088,14 @@ class ResourceGroup(Model): :vartype id: str :param name: The name of the resource group. :type name: str - :param 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 resource group has been created. It must be one of - the supported Azure locations. + :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 + 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. + :param managed_by: The ID of the resource that manages this resource group. :type managed_by: str - :param tags: The tags attached to the resource group. + :param tags: A set of tags. The tags attached to the resource group. :type tags: dict[str, str] """ @@ -1021,17 +1113,20 @@ class ResourceGroup(Model): 'tags': {'key': 'tags', 'type': '{str}'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ResourceGroup, self).__init__(**kwargs) self.id = None self.name = kwargs.get('name', None) self.properties = kwargs.get('properties', None) - self.location = kwargs.get('location', None) + self.location = kwargs['location'] self.managed_by = kwargs.get('managed_by', None) self.tags = kwargs.get('tags', None) -class ResourceGroupExportResult(Model): +class ResourceGroupExportResult(msrest.serialization.Model): """ResourceGroupExportResult. :param template: The template content. @@ -1046,13 +1141,16 @@ class ResourceGroupExportResult(Model): 'error': {'key': 'error', 'type': 'ResourceManagementErrorWithDetails'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ResourceGroupExportResult, self).__init__(**kwargs) self.template = kwargs.get('template', None) self.error = kwargs.get('error', None) -class ResourceGroupFilter(Model): +class ResourceGroupFilter(msrest.serialization.Model): """Resource group filter. :param tag_name: The tag name. @@ -1066,17 +1164,48 @@ class ResourceGroupFilter(Model): 'tag_value': {'key': 'tagValue', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ResourceGroupFilter, self).__init__(**kwargs) self.tag_name = kwargs.get('tag_name', None) self.tag_value = kwargs.get('tag_value', None) -class ResourceGroupProperties(Model): +class ResourceGroupListResult(msrest.serialization.Model): + """List of resource groups. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ResourceGroup]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ResourceGroupListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = None + + +class ResourceGroupProperties(msrest.serialization.Model): """The resource group properties. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar provisioning_state: The provisioning state. :vartype provisioning_state: str @@ -1090,16 +1219,47 @@ class ResourceGroupProperties(Model): 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ResourceGroupProperties, self).__init__(**kwargs) self.provisioning_state = None -class ResourceManagementErrorWithDetails(Model): +class ResourceListResult(msrest.serialization.Model): + """List of resource groups. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[GenericResourceExpanded]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ResourceListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = None + + +class ResourceManagementErrorWithDetails(msrest.serialization.Model): """ResourceManagementErrorWithDetails. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar code: The error code returned when exporting the template. :vartype code: str @@ -1126,7 +1286,10 @@ class ResourceManagementErrorWithDetails(Model): 'details': {'key': 'details', 'type': '[ResourceManagementErrorWithDetails]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ResourceManagementErrorWithDetails, self).__init__(**kwargs) self.code = None self.message = None @@ -1134,7 +1297,7 @@ def __init__(self, **kwargs): self.details = None -class ResourceProviderOperationDisplayProperties(Model): +class ResourceProviderOperationDisplayProperties(msrest.serialization.Model): """Resource provider operation's display properties. :param publisher: Operation description. @@ -1157,7 +1320,10 @@ class ResourceProviderOperationDisplayProperties(Model): 'description': {'key': 'description', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ResourceProviderOperationDisplayProperties, self).__init__(**kwargs) self.publisher = kwargs.get('publisher', None) self.provider = kwargs.get('provider', None) @@ -1166,7 +1332,7 @@ def __init__(self, **kwargs): self.description = kwargs.get('description', None) -class ResourcesMoveInfo(Model): +class ResourcesMoveInfo(msrest.serialization.Model): """Parameters of move resources. :param resources: The IDs of the resources. @@ -1180,13 +1346,16 @@ class ResourcesMoveInfo(Model): 'target_resource_group': {'key': 'targetResourceGroup', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ResourcesMoveInfo, self).__init__(**kwargs) self.resources = kwargs.get('resources', None) self.target_resource_group = kwargs.get('target_resource_group', None) -class Sku(Model): +class Sku(msrest.serialization.Model): """SKU for the resource. :param name: The SKU name. @@ -1212,7 +1381,10 @@ class Sku(Model): 'capacity': {'key': 'capacity', 'type': 'int'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Sku, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.tier = kwargs.get('tier', None) @@ -1222,10 +1394,10 @@ def __init__(self, **kwargs): self.capacity = kwargs.get('capacity', None) -class SubResource(Model): +class SubResource(msrest.serialization.Model): """SubResource. - :param id: Resource ID + :param id: Resource ID. :type id: str """ @@ -1233,12 +1405,15 @@ class SubResource(Model): 'id': {'key': 'id', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(SubResource, self).__init__(**kwargs) self.id = kwargs.get('id', None) -class TagCount(Model): +class TagCount(msrest.serialization.Model): """Tag count. :param type: Type of count. @@ -1252,29 +1427,29 @@ class TagCount(Model): 'value': {'key': 'value', 'type': 'int'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(TagCount, self).__init__(**kwargs) self.type = kwargs.get('type', None) self.value = kwargs.get('value', None) -class TagDetails(Model): +class TagDetails(msrest.serialization.Model): """Tag details. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :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 created and has no associated resources, the value - is 0. + :param 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] + :type values: list[~azure.mgmt.resource.resources.v2016_09_01.models.TagValue] """ _validation = { @@ -1288,7 +1463,10 @@ class TagDetails(Model): 'values': {'key': 'values', 'type': '[TagValue]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(TagDetails, self).__init__(**kwargs) self.id = None self.tag_name = kwargs.get('tag_name', None) @@ -1296,11 +1474,39 @@ def __init__(self, **kwargs): self.values = kwargs.get('values', None) -class TagValue(Model): +class TagsListResult(msrest.serialization.Model): + """List of subscription tags. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[TagDetails]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(TagsListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = None + + +class TagValue(msrest.serialization.Model): """Tag information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The tag ID. :vartype id: str @@ -1320,14 +1526,17 @@ class TagValue(Model): 'count': {'key': 'count', 'type': 'TagCount'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(TagValue, self).__init__(**kwargs) self.id = None self.tag_value = kwargs.get('tag_value', None) self.count = kwargs.get('count', None) -class TargetResource(Model): +class TargetResource(msrest.serialization.Model): """Target resource. :param id: The ID of the resource. @@ -1344,16 +1553,18 @@ class TargetResource(Model): 'resource_type': {'key': 'resourceType', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(TargetResource, self).__init__(**kwargs) self.id = kwargs.get('id', None) self.resource_name = kwargs.get('resource_name', None) self.resource_type = kwargs.get('resource_type', None) -class TemplateHashResult(Model): - """Result of the request to calculate template hash. It contains a string of - minified template and its hash. +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 @@ -1366,21 +1577,23 @@ class TemplateHashResult(Model): 'template_hash': {'key': 'templateHash', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(TemplateHashResult, self).__init__(**kwargs) self.minified_template = kwargs.get('minified_template', None) self.template_hash = kwargs.get('template_hash', None) -class TemplateLink(Model): +class TemplateLink(msrest.serialization.Model): """Entity representing the reference to the template. 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. + :param content_version: If included, must match the ContentVersion in the template. :type content_version: str """ @@ -1393,7 +1606,10 @@ class TemplateLink(Model): 'content_version': {'key': 'contentVersion', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(TemplateLink, self).__init__(**kwargs) - self.uri = kwargs.get('uri', None) + 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_09_01/models/_models_py3.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/models/_models_py3.py index d1ce868e68bf..3390b47ee2d4 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 @@ -1,20 +1,20 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.serialization import Model -from msrest.exceptions import HttpOperationError +from typing import Dict, List, Optional, Union +import msrest.serialization -class AliasPathType(Model): - """The type of the paths for alias. . +from ._resource_management_client_enums import * + + +class AliasPathType(msrest.serialization.Model): + """The type of the paths for alias. :param path: The path of an alias. :type path: str @@ -27,20 +27,25 @@ class AliasPathType(Model): 'api_versions': {'key': 'apiVersions', 'type': '[str]'}, } - def __init__(self, *, path: str=None, api_versions=None, **kwargs) -> None: + def __init__( + self, + *, + path: Optional[str] = None, + api_versions: Optional[List[str]] = None, + **kwargs + ): super(AliasPathType, self).__init__(**kwargs) self.path = path self.api_versions = api_versions -class AliasType(Model): - """The alias type. . +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] + :type paths: list[~azure.mgmt.resource.resources.v2016_09_01.models.AliasPathType] """ _attribute_map = { @@ -48,13 +53,19 @@ class AliasType(Model): 'paths': {'key': 'paths', 'type': '[AliasPathType]'}, } - def __init__(self, *, name: str=None, paths=None, **kwargs) -> None: + def __init__( + self, + *, + name: Optional[str] = None, + paths: Optional[List["AliasPathType"]] = None, + **kwargs + ): super(AliasType, self).__init__(**kwargs) self.name = name self.paths = paths -class BasicDependency(Model): +class BasicDependency(msrest.serialization.Model): """Deployment dependency information. :param id: The ID of the dependency. @@ -71,52 +82,29 @@ class BasicDependency(Model): 'resource_name': {'key': 'resourceName', 'type': 'str'}, } - def __init__(self, *, id: str=None, resource_type: str=None, resource_name: str=None, **kwargs) -> None: + def __init__( + self, + *, + id: Optional[str] = None, + resource_type: Optional[str] = None, + resource_name: Optional[str] = None, + **kwargs + ): super(BasicDependency, self).__init__(**kwargs) self.id = id self.resource_type = resource_type self.resource_name = resource_name -class CloudError(Model): - """An error response for a resource management request. - - :param error: - :type error: - ~azure.mgmt.resource.resources.v2016_09_01.models.ErrorResponse - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorResponse'}, - } - - def __init__(self, *, error=None, **kwargs) -> None: - super(CloudError, self).__init__(**kwargs) - self.error = error - - -class CloudErrorException(HttpOperationError): - """Server responsed with exception of type: 'CloudError'. - - :param deserialize: A deserializer - :param response: Server response to be deserialized. - """ - - def __init__(self, deserialize, response, *args): - - super(CloudErrorException, self).__init__(deserialize, response, 'CloudError', *args) - - -class DebugSetting(Model): +class DebugSetting(msrest.serialization.Model): """DebugSetting. - :param 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. + :param 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 """ @@ -124,17 +112,21 @@ class DebugSetting(Model): 'detail_level': {'key': 'detailLevel', 'type': 'str'}, } - def __init__(self, *, detail_level: str=None, **kwargs) -> None: + def __init__( + self, + *, + detail_level: Optional[str] = None, + **kwargs + ): super(DebugSetting, self).__init__(**kwargs) self.detail_level = detail_level -class Dependency(Model): +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] + :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. @@ -150,7 +142,15 @@ class Dependency(Model): 'resource_name': {'key': 'resourceName', 'type': 'str'}, } - def __init__(self, *, depends_on=None, id: str=None, resource_type: str=None, resource_name: str=None, **kwargs) -> None: + def __init__( + self, + *, + depends_on: Optional[List["BasicDependency"]] = None, + id: Optional[str] = None, + resource_type: Optional[str] = None, + resource_name: Optional[str] = None, + **kwargs + ): super(Dependency, self).__init__(**kwargs) self.depends_on = depends_on self.id = id @@ -158,14 +158,13 @@ def __init__(self, *, depends_on=None, id: str=None, resource_type: str=None, re self.resource_name = resource_name -class Deployment(Model): +class Deployment(msrest.serialization.Model): """Deployment operation parameters. 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 + :type properties: ~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentProperties """ _validation = { @@ -176,13 +175,18 @@ class Deployment(Model): 'properties': {'key': 'properties', 'type': 'DeploymentProperties'}, } - def __init__(self, *, properties, **kwargs) -> None: + def __init__( + self, + *, + properties: "DeploymentProperties", + **kwargs + ): super(Deployment, self).__init__(**kwargs) self.properties = properties -class DeploymentExportResult(Model): - """The deployment export result. . +class DeploymentExportResult(msrest.serialization.Model): + """The deployment export result. :param template: The template content. :type template: object @@ -192,16 +196,20 @@ class DeploymentExportResult(Model): 'template': {'key': 'template', 'type': 'object'}, } - def __init__(self, *, template=None, **kwargs) -> None: + def __init__( + self, + *, + template: Optional[object] = None, + **kwargs + ): super(DeploymentExportResult, self).__init__(**kwargs) self.template = template -class DeploymentExtended(Model): +class DeploymentExtended(msrest.serialization.Model): """Deployment information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. @@ -225,14 +233,20 @@ class DeploymentExtended(Model): 'properties': {'key': 'properties', 'type': 'DeploymentPropertiesExtended'}, } - def __init__(self, *, name: str, properties=None, **kwargs) -> None: + def __init__( + self, + *, + name: str, + properties: Optional["DeploymentPropertiesExtended"] = None, + **kwargs + ): super(DeploymentExtended, self).__init__(**kwargs) self.id = None self.name = name self.properties = properties -class DeploymentExtendedFilter(Model): +class DeploymentExtendedFilter(msrest.serialization.Model): """Deployment filter. :param provisioning_state: The provisioning state. @@ -243,16 +257,51 @@ class DeploymentExtendedFilter(Model): 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, } - def __init__(self, *, provisioning_state: str=None, **kwargs) -> None: + def __init__( + self, + *, + provisioning_state: Optional[str] = None, + **kwargs + ): super(DeploymentExtendedFilter, self).__init__(**kwargs) self.provisioning_state = provisioning_state -class DeploymentOperation(Model): +class DeploymentListResult(msrest.serialization.Model): + """List of deployments. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[DeploymentExtended]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["DeploymentExtended"]] = None, + **kwargs + ): + super(DeploymentListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class DeploymentOperation(msrest.serialization.Model): """Deployment operation information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Full deployment operation ID. :vartype id: str @@ -274,23 +323,27 @@ class DeploymentOperation(Model): 'properties': {'key': 'properties', 'type': 'DeploymentOperationProperties'}, } - def __init__(self, *, properties=None, **kwargs) -> None: + def __init__( + self, + *, + properties: Optional["DeploymentOperationProperties"] = None, + **kwargs + ): super(DeploymentOperation, self).__init__(**kwargs) self.id = None self.operation_id = None self.properties = properties -class DeploymentOperationProperties(Model): +class DeploymentOperationProperties(msrest.serialization.Model): """Deployment operation properties. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar provisioning_state: The state of the provisioning. :vartype provisioning_state: str :ivar timestamp: The date and time of the operation. - :vartype timestamp: datetime + :vartype timestamp: ~datetime.datetime :ivar service_request_id: Deployment operation service request id. :vartype service_request_id: str :ivar status_code: Operation status code. @@ -298,14 +351,11 @@ class DeploymentOperationProperties(Model): :ivar status_message: Operation status message. :vartype status_message: object :ivar target_resource: The target resource. - :vartype target_resource: - ~azure.mgmt.resource.resources.v2016_09_01.models.TargetResource + :vartype target_resource: ~azure.mgmt.resource.resources.v2016_09_01.models.TargetResource :ivar request: The HTTP request message. - :vartype request: - ~azure.mgmt.resource.resources.v2016_09_01.models.HttpMessage + :vartype request: ~azure.mgmt.resource.resources.v2016_09_01.models.HttpMessage :ivar response: The HTTP response message. - :vartype response: - ~azure.mgmt.resource.resources.v2016_09_01.models.HttpMessage + :vartype response: ~azure.mgmt.resource.resources.v2016_09_01.models.HttpMessage """ _validation = { @@ -330,7 +380,10 @@ class DeploymentOperationProperties(Model): 'response': {'key': 'response', 'type': 'HttpMessage'}, } - def __init__(self, **kwargs) -> None: + def __init__( + self, + **kwargs + ): super(DeploymentOperationProperties, self).__init__(**kwargs) self.provisioning_state = None self.timestamp = None @@ -342,45 +395,68 @@ def __init__(self, **kwargs) -> None: self.response = None -class DeploymentProperties(Model): +class DeploymentOperationsListResult(msrest.serialization.Model): + """List of deployment operations. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[DeploymentOperation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["DeploymentOperation"]] = None, + **kwargs + ): + super(DeploymentOperationsListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class DeploymentProperties(msrest.serialization.Model): """Deployment properties. 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 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. + :param 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: object - :param 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. 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. + :param 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. + 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: object - :param 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 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 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 + 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 + :type debug_setting: ~azure.mgmt.resource.resources.v2016_09_01.models.DebugSetting """ _validation = { @@ -392,11 +468,21 @@ class DeploymentProperties(Model): 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, 'parameters': {'key': 'parameters', 'type': 'object'}, 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, - 'mode': {'key': 'mode', 'type': 'DeploymentMode'}, + 'mode': {'key': 'mode', 'type': 'str'}, 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, } - def __init__(self, *, mode, template=None, template_link=None, parameters=None, parameters_link=None, debug_setting=None, **kwargs) -> None: + def __init__( + self, + *, + mode: Union[str, "DeploymentMode"], + template: Optional[object] = None, + template_link: Optional["TemplateLink"] = None, + parameters: Optional[object] = None, + parameters_link: Optional["ParametersLink"] = None, + debug_setting: Optional["DebugSetting"] = None, + **kwargs + ): super(DeploymentProperties, self).__init__(**kwargs) self.template = template self.template_link = template_link @@ -406,48 +492,38 @@ def __init__(self, *, mode, template=None, template_link=None, parameters=None, self.debug_setting = debug_setting -class DeploymentPropertiesExtended(Model): +class DeploymentPropertiesExtended(msrest.serialization.Model): """Deployment properties with additional details. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :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 + :vartype timestamp: ~datetime.datetime :param outputs: Key/value pairs that represent deployment output. :type outputs: object - :param providers: The list of resource providers needed for the - deployment. - :type providers: - list[~azure.mgmt.resource.resources.v2016_09_01.models.Provider] + :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 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: object - :param 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. + :param 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: object - :param 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 include: 'Incremental', 'Complete' - :type mode: str or - ~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentMode + :param 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 + 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 + :type debug_setting: ~azure.mgmt.resource.resources.v2016_09_01.models.DebugSetting """ _validation = { @@ -467,11 +543,24 @@ class DeploymentPropertiesExtended(Model): 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, 'parameters': {'key': 'parameters', 'type': 'object'}, 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, - 'mode': {'key': 'mode', 'type': 'DeploymentMode'}, + 'mode': {'key': 'mode', 'type': 'str'}, 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, } - def __init__(self, *, outputs=None, providers=None, dependencies=None, template=None, template_link=None, parameters=None, parameters_link=None, mode=None, debug_setting=None, **kwargs) -> None: + def __init__( + self, + *, + outputs: Optional[object] = None, + providers: Optional[List["Provider"]] = None, + dependencies: Optional[List["Dependency"]] = None, + template: Optional[object] = None, + template_link: Optional["TemplateLink"] = None, + parameters: Optional[object] = None, + parameters_link: Optional["ParametersLink"] = None, + mode: Optional[Union[str, "DeploymentMode"]] = None, + debug_setting: Optional["DebugSetting"] = None, + **kwargs + ): super(DeploymentPropertiesExtended, self).__init__(**kwargs) self.provisioning_state = None self.correlation_id = None @@ -487,7 +576,7 @@ def __init__(self, *, outputs=None, providers=None, dependencies=None, template= self.debug_setting = debug_setting -class DeploymentValidateResult(Model): +class DeploymentValidateResult(msrest.serialization.Model): """Information from validate template deployment response. :param error: Validation error. @@ -503,17 +592,22 @@ class DeploymentValidateResult(Model): 'properties': {'key': 'properties', 'type': 'DeploymentPropertiesExtended'}, } - def __init__(self, *, error=None, properties=None, **kwargs) -> None: + def __init__( + self, + *, + error: Optional["ResourceManagementErrorWithDetails"] = None, + properties: Optional["DeploymentPropertiesExtended"] = None, + **kwargs + ): super(DeploymentValidateResult, self).__init__(**kwargs) self.error = error self.properties = properties -class ErrorAdditionalInfo(Model): +class ErrorAdditionalInfo(msrest.serialization.Model): """The resource management error additional info. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar type: The additional info type. :vartype type: str @@ -531,17 +625,19 @@ class ErrorAdditionalInfo(Model): 'info': {'key': 'info', 'type': 'object'}, } - def __init__(self, **kwargs) -> None: + def __init__( + self, + **kwargs + ): super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None -class ErrorResponse(Model): +class ErrorResponse(msrest.serialization.Model): """The resource management error response. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar code: The error code. :vartype code: str @@ -550,8 +646,7 @@ class ErrorResponse(Model): :ivar target: The error target. :vartype target: str :ivar details: The error details. - :vartype details: - list[~azure.mgmt.resource.resources.v2016_09_01.models.ErrorResponse] + :vartype details: list[~azure.mgmt.resource.resources.v2016_09_01.models.ErrorResponse] :ivar additional_info: The error additional info. :vartype additional_info: list[~azure.mgmt.resource.resources.v2016_09_01.models.ErrorAdditionalInfo] @@ -573,7 +668,10 @@ class ErrorResponse(Model): 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, } - def __init__(self, **kwargs) -> None: + def __init__( + self, + **kwargs + ): super(ErrorResponse, self).__init__(**kwargs) self.code = None self.message = None @@ -582,16 +680,15 @@ def __init__(self, **kwargs) -> None: self.additional_info = None -class ExportTemplateRequest(Model): +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, supply an array with single entry '*'. + :param 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', 'SkipResourceNameParameterization', - 'SkipAllParameterization' + :param options: The export template options. A CSV-formatted list containing zero or more of + the following: 'IncludeParameterDefaultValue', 'IncludeComments', + 'SkipResourceNameParameterization', 'SkipAllParameterization'. :type options: str """ @@ -600,27 +697,32 @@ class ExportTemplateRequest(Model): 'options': {'key': 'options', 'type': 'str'}, } - def __init__(self, *, resources=None, options: str=None, **kwargs) -> None: + def __init__( + self, + *, + resources: Optional[List[str]] = None, + options: Optional[str] = None, + **kwargs + ): super(ExportTemplateRequest, self).__init__(**kwargs) self.resources = resources self.options = options -class Resource(Model): +class Resource(msrest.serialization.Model): """Resource. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID + :ivar id: Resource ID. :vartype id: str - :ivar name: Resource name + :ivar name: Resource name. :vartype name: str - :ivar type: Resource type + :ivar type: Resource type. :vartype type: str - :param location: Resource location + :param location: Resource location. :type location: str - :param tags: Resource tags + :param tags: A set of tags. Resource tags. :type tags: dict[str, str] """ @@ -638,7 +740,13 @@ class Resource(Model): 'tags': {'key': 'tags', 'type': '{str}'}, } - def __init__(self, *, location: str=None, tags=None, **kwargs) -> None: + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -650,18 +758,17 @@ def __init__(self, *, location: str=None, tags=None, **kwargs) -> None: class GenericResource(Resource): """Resource information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID + :ivar id: Resource ID. :vartype id: str - :ivar name: Resource name + :ivar name: Resource name. :vartype name: str - :ivar type: Resource type + :ivar type: Resource type. :vartype type: str - :param location: Resource location + :param location: Resource location. :type location: str - :param tags: Resource tags + :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 @@ -698,7 +805,19 @@ class GenericResource(Resource): 'identity': {'key': 'identity', 'type': 'Identity'}, } - def __init__(self, *, location: str=None, tags=None, plan=None, properties=None, kind: str=None, managed_by: str=None, sku=None, identity=None, **kwargs) -> None: + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + plan: Optional["Plan"] = None, + properties: Optional[object] = None, + kind: Optional[str] = None, + managed_by: Optional[str] = None, + sku: Optional["Sku"] = None, + identity: Optional["Identity"] = None, + **kwargs + ): super(GenericResource, self).__init__(location=location, tags=tags, **kwargs) self.plan = plan self.properties = properties @@ -711,18 +830,17 @@ def __init__(self, *, location: str=None, tags=None, plan=None, properties=None, class GenericResourceExpanded(GenericResource): """Resource information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID + :ivar id: Resource ID. :vartype id: str - :ivar name: Resource name + :ivar name: Resource name. :vartype name: str - :ivar type: Resource type + :ivar type: Resource type. :vartype type: str - :param location: Resource location + :param location: Resource location. :type location: str - :param tags: Resource tags + :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 @@ -736,14 +854,14 @@ class GenericResourceExpanded(GenericResource): :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 created_time: The created time of the resource. This is only present - if requested via the $expand query parameter. - :vartype created_time: datetime - :ivar changed_time: The changed time of the resource. This is only present - if requested via the $expand query parameter. - :vartype changed_time: datetime - :ivar provisioning_state: The provisioning state of the resource. This is - only present if requested via the $expand query parameter. + :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 + :ivar changed_time: The changed time of the resource. This is only present if requested via the + $expand query parameter. + :vartype changed_time: ~datetime.datetime + :ivar provisioning_state: The provisioning state of the resource. This is only present if + requested via the $expand query parameter. :vartype provisioning_state: str """ @@ -774,14 +892,26 @@ class GenericResourceExpanded(GenericResource): 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, } - def __init__(self, *, location: str=None, tags=None, plan=None, properties=None, kind: str=None, managed_by: str=None, sku=None, identity=None, **kwargs) -> None: + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + plan: Optional["Plan"] = None, + properties: Optional[object] = None, + kind: Optional[str] = None, + managed_by: Optional[str] = None, + sku: Optional["Sku"] = None, + identity: Optional["Identity"] = None, + **kwargs + ): 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 self.provisioning_state = None -class GenericResourceFilter(Model): +class GenericResourceFilter(msrest.serialization.Model): """Resource filter. :param resource_type: The resource type. @@ -798,14 +928,21 @@ class GenericResourceFilter(Model): 'tagvalue': {'key': 'tagvalue', 'type': 'str'}, } - def __init__(self, *, resource_type: str=None, tagname: str=None, tagvalue: str=None, **kwargs) -> None: + def __init__( + self, + *, + resource_type: Optional[str] = None, + tagname: Optional[str] = None, + tagvalue: Optional[str] = None, + **kwargs + ): super(GenericResourceFilter, self).__init__(**kwargs) self.resource_type = resource_type self.tagname = tagname self.tagvalue = tagvalue -class HttpMessage(Model): +class HttpMessage(msrest.serialization.Model): """HttpMessage. :param content: HTTP message content. @@ -816,53 +953,60 @@ class HttpMessage(Model): 'content': {'key': 'content', 'type': 'object'}, } - def __init__(self, *, content=None, **kwargs) -> None: + def __init__( + self, + *, + content: Optional[object] = None, + **kwargs + ): super(HttpMessage, self).__init__(**kwargs) self.content = content -class Identity(Model): +class Identity(msrest.serialization.Model): """Identity for the resource. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar principal_id: The principal ID of resource identity. :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :param type: The identity type. Possible values include: 'SystemAssigned' - :type type: str or - ~azure.mgmt.resource.resources.v2016_09_01.models.ResourceIdentityType + :ivar type: The identity type. Default value: "SystemAssigned". + :vartype type: str """ _validation = { 'principal_id': {'readonly': True}, 'tenant_id': {'readonly': True}, + 'type': {'constant': True}, } _attribute_map = { 'principal_id': {'key': 'principalId', 'type': 'str'}, 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'ResourceIdentityType'}, + 'type': {'key': 'type', 'type': 'str'}, } - def __init__(self, *, type=None, **kwargs) -> None: + type = "SystemAssigned" + + def __init__( + self, + **kwargs + ): super(Identity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None - self.type = type -class ParametersLink(Model): +class ParametersLink(msrest.serialization.Model): """Entity representing the reference to the deployment parameters. 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. + :param content_version: If included, must match the ContentVersion in the template. :type content_version: str """ @@ -875,13 +1019,19 @@ class ParametersLink(Model): 'content_version': {'key': 'contentVersion', 'type': 'str'}, } - def __init__(self, *, uri: str, content_version: str=None, **kwargs) -> None: + def __init__( + self, + *, + uri: str, + content_version: Optional[str] = None, + **kwargs + ): super(ParametersLink, self).__init__(**kwargs) self.uri = uri self.content_version = content_version -class Plan(Model): +class Plan(msrest.serialization.Model): """Plan for the resource. :param name: The plan ID. @@ -901,7 +1051,15 @@ class Plan(Model): 'promotion_code': {'key': 'promotionCode', 'type': 'str'}, } - def __init__(self, *, name: str=None, publisher: str=None, product: str=None, promotion_code: str=None, **kwargs) -> None: + def __init__( + self, + *, + name: Optional[str] = None, + publisher: Optional[str] = None, + product: Optional[str] = None, + promotion_code: Optional[str] = None, + **kwargs + ): super(Plan, self).__init__(**kwargs) self.name = name self.publisher = publisher @@ -909,11 +1067,10 @@ def __init__(self, *, name: str=None, publisher: str=None, product: str=None, pr self.promotion_code = promotion_code -class Provider(Model): +class Provider(msrest.serialization.Model): """Resource provider information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The provider ID. :vartype id: str @@ -939,7 +1096,12 @@ class Provider(Model): 'resource_types': {'key': 'resourceTypes', 'type': '[ProviderResourceType]'}, } - def __init__(self, *, namespace: str=None, **kwargs) -> None: + def __init__( + self, + *, + namespace: Optional[str] = None, + **kwargs + ): super(Provider, self).__init__(**kwargs) self.id = None self.namespace = namespace @@ -947,17 +1109,46 @@ def __init__(self, *, namespace: str=None, **kwargs) -> None: self.resource_types = None -class ProviderResourceType(Model): +class ProviderListResult(msrest.serialization.Model): + """List of resource providers. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Provider]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["Provider"]] = None, + **kwargs + ): + super(ProviderListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +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. + :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] + :type aliases: list[~azure.mgmt.resource.resources.v2016_09_01.models.AliasType] :param api_versions: The API version. :type api_versions: list[str] :param properties: The properties. @@ -972,7 +1163,16 @@ class ProviderResourceType(Model): 'properties': {'key': 'properties', 'type': '{str}'}, } - def __init__(self, *, resource_type: str=None, locations=None, aliases=None, api_versions=None, properties=None, **kwargs) -> None: + def __init__( + self, + *, + resource_type: Optional[str] = None, + locations: Optional[List[str]] = None, + aliases: Optional[List["AliasType"]] = None, + api_versions: Optional[List[str]] = None, + properties: Optional[Dict[str, str]] = None, + **kwargs + ): super(ProviderResourceType, self).__init__(**kwargs) self.resource_type = resource_type self.locations = locations @@ -981,11 +1181,10 @@ def __init__(self, *, resource_type: str=None, locations=None, aliases=None, api self.properties = properties -class ResourceGroup(Model): +class ResourceGroup(msrest.serialization.Model): """Resource group information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. @@ -993,17 +1192,14 @@ class ResourceGroup(Model): :vartype id: str :param name: The name of the resource group. :type name: str - :param 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 resource group has been created. It must be one of - the supported Azure locations. + :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 + 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. + :param managed_by: The ID of the resource that manages this resource group. :type managed_by: str - :param tags: The tags attached to the resource group. + :param tags: A set of tags. The tags attached to the resource group. :type tags: dict[str, str] """ @@ -1021,7 +1217,16 @@ class ResourceGroup(Model): 'tags': {'key': 'tags', 'type': '{str}'}, } - def __init__(self, *, location: str, name: str=None, properties=None, managed_by: str=None, tags=None, **kwargs) -> None: + def __init__( + self, + *, + location: str, + name: Optional[str] = None, + properties: Optional["ResourceGroupProperties"] = None, + managed_by: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): super(ResourceGroup, self).__init__(**kwargs) self.id = None self.name = name @@ -1031,7 +1236,7 @@ def __init__(self, *, location: str, name: str=None, properties=None, managed_by self.tags = tags -class ResourceGroupExportResult(Model): +class ResourceGroupExportResult(msrest.serialization.Model): """ResourceGroupExportResult. :param template: The template content. @@ -1046,13 +1251,19 @@ class ResourceGroupExportResult(Model): 'error': {'key': 'error', 'type': 'ResourceManagementErrorWithDetails'}, } - def __init__(self, *, template=None, error=None, **kwargs) -> None: + def __init__( + self, + *, + template: Optional[object] = None, + error: Optional["ResourceManagementErrorWithDetails"] = None, + **kwargs + ): super(ResourceGroupExportResult, self).__init__(**kwargs) self.template = template self.error = error -class ResourceGroupFilter(Model): +class ResourceGroupFilter(msrest.serialization.Model): """Resource group filter. :param tag_name: The tag name. @@ -1066,17 +1277,53 @@ class ResourceGroupFilter(Model): 'tag_value': {'key': 'tagValue', 'type': 'str'}, } - def __init__(self, *, tag_name: str=None, tag_value: str=None, **kwargs) -> None: + def __init__( + self, + *, + tag_name: Optional[str] = None, + tag_value: Optional[str] = None, + **kwargs + ): super(ResourceGroupFilter, self).__init__(**kwargs) self.tag_name = tag_name self.tag_value = tag_value -class ResourceGroupProperties(Model): +class ResourceGroupListResult(msrest.serialization.Model): + """List of resource groups. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ResourceGroup]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["ResourceGroup"]] = None, + **kwargs + ): + super(ResourceGroupListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class ResourceGroupProperties(msrest.serialization.Model): """The resource group properties. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar provisioning_state: The provisioning state. :vartype provisioning_state: str @@ -1090,16 +1337,49 @@ class ResourceGroupProperties(Model): 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, } - def __init__(self, **kwargs) -> None: + def __init__( + self, + **kwargs + ): super(ResourceGroupProperties, self).__init__(**kwargs) self.provisioning_state = None -class ResourceManagementErrorWithDetails(Model): +class ResourceListResult(msrest.serialization.Model): + """List of resource groups. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[GenericResourceExpanded]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["GenericResourceExpanded"]] = None, + **kwargs + ): + super(ResourceListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class ResourceManagementErrorWithDetails(msrest.serialization.Model): """ResourceManagementErrorWithDetails. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar code: The error code returned when exporting the template. :vartype code: str @@ -1126,7 +1406,10 @@ class ResourceManagementErrorWithDetails(Model): 'details': {'key': 'details', 'type': '[ResourceManagementErrorWithDetails]'}, } - def __init__(self, **kwargs) -> None: + def __init__( + self, + **kwargs + ): super(ResourceManagementErrorWithDetails, self).__init__(**kwargs) self.code = None self.message = None @@ -1134,7 +1417,7 @@ def __init__(self, **kwargs) -> None: self.details = None -class ResourceProviderOperationDisplayProperties(Model): +class ResourceProviderOperationDisplayProperties(msrest.serialization.Model): """Resource provider operation's display properties. :param publisher: Operation description. @@ -1157,7 +1440,16 @@ class ResourceProviderOperationDisplayProperties(Model): 'description': {'key': 'description', 'type': 'str'}, } - def __init__(self, *, publisher: str=None, provider: str=None, resource: str=None, operation: str=None, description: str=None, **kwargs) -> None: + def __init__( + self, + *, + publisher: Optional[str] = None, + provider: Optional[str] = None, + resource: Optional[str] = None, + operation: Optional[str] = None, + description: Optional[str] = None, + **kwargs + ): super(ResourceProviderOperationDisplayProperties, self).__init__(**kwargs) self.publisher = publisher self.provider = provider @@ -1166,7 +1458,7 @@ def __init__(self, *, publisher: str=None, provider: str=None, resource: str=Non self.description = description -class ResourcesMoveInfo(Model): +class ResourcesMoveInfo(msrest.serialization.Model): """Parameters of move resources. :param resources: The IDs of the resources. @@ -1180,13 +1472,19 @@ class ResourcesMoveInfo(Model): 'target_resource_group': {'key': 'targetResourceGroup', 'type': 'str'}, } - def __init__(self, *, resources=None, target_resource_group: str=None, **kwargs) -> None: + def __init__( + self, + *, + resources: Optional[List[str]] = None, + target_resource_group: Optional[str] = None, + **kwargs + ): super(ResourcesMoveInfo, self).__init__(**kwargs) self.resources = resources self.target_resource_group = target_resource_group -class Sku(Model): +class Sku(msrest.serialization.Model): """SKU for the resource. :param name: The SKU name. @@ -1212,7 +1510,17 @@ class Sku(Model): 'capacity': {'key': 'capacity', 'type': 'int'}, } - def __init__(self, *, name: str=None, tier: str=None, size: str=None, family: str=None, model: str=None, capacity: int=None, **kwargs) -> None: + def __init__( + self, + *, + name: Optional[str] = None, + tier: Optional[str] = None, + size: Optional[str] = None, + family: Optional[str] = None, + model: Optional[str] = None, + capacity: Optional[int] = None, + **kwargs + ): super(Sku, self).__init__(**kwargs) self.name = name self.tier = tier @@ -1222,10 +1530,10 @@ def __init__(self, *, name: str=None, tier: str=None, size: str=None, family: st self.capacity = capacity -class SubResource(Model): +class SubResource(msrest.serialization.Model): """SubResource. - :param id: Resource ID + :param id: Resource ID. :type id: str """ @@ -1233,12 +1541,17 @@ class SubResource(Model): 'id': {'key': 'id', 'type': 'str'}, } - def __init__(self, *, id: str=None, **kwargs) -> None: + def __init__( + self, + *, + id: Optional[str] = None, + **kwargs + ): super(SubResource, self).__init__(**kwargs) self.id = id -class TagCount(Model): +class TagCount(msrest.serialization.Model): """Tag count. :param type: Type of count. @@ -1252,29 +1565,32 @@ class TagCount(Model): 'value': {'key': 'value', 'type': 'int'}, } - def __init__(self, *, type: str=None, value: int=None, **kwargs) -> None: + def __init__( + self, + *, + type: Optional[str] = None, + value: Optional[int] = None, + **kwargs + ): super(TagCount, self).__init__(**kwargs) self.type = type self.value = value -class TagDetails(Model): +class TagDetails(msrest.serialization.Model): """Tag details. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :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 created and has no associated resources, the value - is 0. + :param 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] + :type values: list[~azure.mgmt.resource.resources.v2016_09_01.models.TagValue] """ _validation = { @@ -1288,7 +1604,14 @@ class TagDetails(Model): 'values': {'key': 'values', 'type': '[TagValue]'}, } - def __init__(self, *, tag_name: str=None, count=None, values=None, **kwargs) -> None: + def __init__( + self, + *, + tag_name: Optional[str] = None, + count: Optional["TagCount"] = None, + values: Optional[List["TagValue"]] = None, + **kwargs + ): super(TagDetails, self).__init__(**kwargs) self.id = None self.tag_name = tag_name @@ -1296,11 +1619,41 @@ def __init__(self, *, tag_name: str=None, count=None, values=None, **kwargs) -> self.values = values -class TagValue(Model): +class TagsListResult(msrest.serialization.Model): + """List of subscription tags. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[TagDetails]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["TagDetails"]] = None, + **kwargs + ): + super(TagsListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class TagValue(msrest.serialization.Model): """Tag information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The tag ID. :vartype id: str @@ -1320,14 +1673,20 @@ class TagValue(Model): 'count': {'key': 'count', 'type': 'TagCount'}, } - def __init__(self, *, tag_value: str=None, count=None, **kwargs) -> None: + def __init__( + self, + *, + tag_value: Optional[str] = None, + count: Optional["TagCount"] = None, + **kwargs + ): super(TagValue, self).__init__(**kwargs) self.id = None self.tag_value = tag_value self.count = count -class TargetResource(Model): +class TargetResource(msrest.serialization.Model): """Target resource. :param id: The ID of the resource. @@ -1344,16 +1703,22 @@ class TargetResource(Model): 'resource_type': {'key': 'resourceType', 'type': 'str'}, } - def __init__(self, *, id: str=None, resource_name: str=None, resource_type: str=None, **kwargs) -> None: + def __init__( + self, + *, + id: Optional[str] = None, + resource_name: Optional[str] = None, + resource_type: Optional[str] = None, + **kwargs + ): super(TargetResource, self).__init__(**kwargs) self.id = id self.resource_name = resource_name self.resource_type = resource_type -class TemplateHashResult(Model): - """Result of the request to calculate template hash. It contains a string of - minified template and its hash. +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 @@ -1366,21 +1731,26 @@ class TemplateHashResult(Model): 'template_hash': {'key': 'templateHash', 'type': 'str'}, } - def __init__(self, *, minified_template: str=None, template_hash: str=None, **kwargs) -> None: + def __init__( + self, + *, + minified_template: Optional[str] = None, + template_hash: Optional[str] = None, + **kwargs + ): super(TemplateHashResult, self).__init__(**kwargs) self.minified_template = minified_template self.template_hash = template_hash -class TemplateLink(Model): +class TemplateLink(msrest.serialization.Model): """Entity representing the reference to the template. 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. + :param content_version: If included, must match the ContentVersion in the template. :type content_version: str """ @@ -1393,7 +1763,13 @@ class TemplateLink(Model): 'content_version': {'key': 'contentVersion', 'type': 'str'}, } - def __init__(self, *, uri: str, content_version: str=None, **kwargs) -> None: + def __init__( + self, + *, + uri: str, + content_version: Optional[str] = None, + **kwargs + ): 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_09_01/models/_paged_models.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/models/_paged_models.py deleted file mode 100644 index d42ad6c10e64..000000000000 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/models/_paged_models.py +++ /dev/null @@ -1,92 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.paging import Paged - - -class DeploymentExtendedPaged(Paged): - """ - A paging container for iterating over a list of :class:`DeploymentExtended ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[DeploymentExtended]'} - } - - def __init__(self, *args, **kwargs): - - super(DeploymentExtendedPaged, self).__init__(*args, **kwargs) -class ProviderPaged(Paged): - """ - A paging container for iterating over a list of :class:`Provider ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[Provider]'} - } - - def __init__(self, *args, **kwargs): - - super(ProviderPaged, self).__init__(*args, **kwargs) -class GenericResourceExpandedPaged(Paged): - """ - A paging container for iterating over a list of :class:`GenericResourceExpanded ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[GenericResourceExpanded]'} - } - - def __init__(self, *args, **kwargs): - - super(GenericResourceExpandedPaged, self).__init__(*args, **kwargs) -class ResourceGroupPaged(Paged): - """ - A paging container for iterating over a list of :class:`ResourceGroup ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[ResourceGroup]'} - } - - def __init__(self, *args, **kwargs): - - super(ResourceGroupPaged, self).__init__(*args, **kwargs) -class TagDetailsPaged(Paged): - """ - A paging container for iterating over a list of :class:`TagDetails ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[TagDetails]'} - } - - def __init__(self, *args, **kwargs): - - super(TagDetailsPaged, self).__init__(*args, **kwargs) -class DeploymentOperationPaged(Paged): - """ - A paging container for iterating over a list of :class:`DeploymentOperation ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[DeploymentOperation]'} - } - - def __init__(self, *args, **kwargs): - - super(DeploymentOperationPaged, self).__init__(*args, **kwargs) 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 3b6a0e19d760..e51889be1e28 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 @@ -1,23 +1,20 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from enum import Enum - class DeploymentMode(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 + the resource group that are not included in the template are deleted. Be careful when using + Complete mode as you may unintentionally delete resources. + """ incremental = "Incremental" complete = "Complete" - - -class ResourceIdentityType(str, Enum): - - system_assigned = "SystemAssigned" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/operations/__init__.py index 0a2b1735bca3..a84dcb38191b 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/operations/__init__.py @@ -1,12 +1,9 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from ._deployments_operations import DeploymentsOperations @@ -14,7 +11,7 @@ from ._resource_groups_operations import ResourceGroupsOperations from ._resources_operations import ResourcesOperations from ._tags_operations import TagsOperations -from ._deployment_operations import DeploymentOperations +from ._deployment_operations_operations import DeploymentOperationsOperations __all__ = [ 'DeploymentsOperations', @@ -22,5 +19,5 @@ 'ResourceGroupsOperations', 'ResourcesOperations', 'TagsOperations', - 'DeploymentOperations', + 'DeploymentOperationsOperations', ] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/operations/_deployment_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/operations/_deployment_operations.py deleted file mode 100644 index 08a93eaa6545..000000000000 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/operations/_deployment_operations.py +++ /dev/null @@ -1,184 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError - -from .. import models - - -class DeploymentOperations(object): - """DeploymentOperations operations. - - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. - - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for this operation. Constant value: "2016-09-01". - """ - - models = models - - def __init__(self, client, config, serializer, deserializer): - - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self.api_version = "2016-09-01" - - self.config = config - - def get( - self, resource_group_name, deployment_name, operation_id, custom_headers=None, raw=False, **operation_config): - """Gets a deployments operation. - - :param resource_group_name: The name of the resource group. The name - is case insensitive. - :type resource_group_name: str - :param deployment_name: The name of the deployment. - :type deployment_name: str - :param operation_id: The ID of the operation to get. - :type operation_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentOperation or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentOperation - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` - """ - # Construct URL - url = self.get.metadata['url'] - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, 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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) - - if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentOperation', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}'} - - def list( - self, resource_group_name, deployment_name, top=None, custom_headers=None, raw=False, **operation_config): - """Gets all deployments operations for a deployment. - - :param resource_group_name: The name of the resource group. The name - is case insensitive. - :type resource_group_name: str - :param deployment_name: The name of the deployment with the operation - to get. - :type deployment_name: str - :param top: The number of results to return. - :type top: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of DeploymentOperation - :rtype: - ~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentOperationPaged[~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentOperation] - :raises: :class:`CloudError` - """ - def prepare_request(next_link=None): - if not next_link: - # Construct URL - url = self.list.metadata['url'] - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - else: - url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) - return request - - def internal_paging(next_link=None): - request = prepare_request(next_link) - - response = self._client.send(request, stream=False, **operation_config) - - if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response - - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.DeploymentOperationPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations'} 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 new file mode 100644 index 000000000000..8878689063d2 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/operations/_deployment_operations_operations.py @@ -0,0 +1,184 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class DeploymentOperationsOperations(object): + """DeploymentOperationsOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2016_09_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def get( + self, + resource_group_name, # type: str + deployment_name, # type: str + operation_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentOperation" + """Gets a deployments operation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param operation_id: The ID of the operation to get. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentOperation or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentOperation + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentOperation"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-09-01" + + # Construct URL + url = self.get.metadata['url'] # type: 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'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentOperation', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + def list( + self, + resource_group_name, # type: str + deployment_name, # type: str + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.DeploymentOperationsListResult"] + """Gets all deployments operations for a deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment with the operation to get. + :type deployment_name: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-09-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentOperationsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations'} # type: ignore 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 1d3ade815948..91727f987dc8 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 @@ -1,700 +1,685 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError -from msrest.polling import LROPoller, NoPolling -from msrestazure.polling.arm_polling import ARMPolling +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class DeploymentsOperations(object): """DeploymentsOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2016_09_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for this operation. Constant value: "2016-09-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2016-09-01" - - self.config = config - + self._config = config def _delete_initial( - self, resource_group_name, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-09-01" + # Construct URL - url = self.delete.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [202, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - - def delete( - self, resource_group_name, deployment_name, custom_headers=None, raw=False, polling=True, **operation_config): - """Deletes a deployment from the deployment history. - - A template deployment that is currently running cannot be deleted. - Deleting a template deployment removes the associated deployment - operations. Deleting a template deployment does not affect the state of - the resource group. This is an asynchronous operation that returns a - status of 202 until the template deployment is successfully deleted. - The Location response header contains the URI that is used to obtain - the status of the process. While the process is running, a call to the - URI in the Location header returns a status of 202. When the process - finishes, the URI in the Location header returns a status of 204 on - success. If the asynchronous request failed, the URI in the Location - header returns an error-level status code. - - :param resource_group_name: The name of the resource group with the - deployment to delete. The name is case insensitive. + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + def begin_delete( + self, + resource_group_name, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """A template deployment that is currently running cannot be deleted. Deleting a template deployment removes the associated deployment operations. Deleting a template deployment does not affect the state of the resource group. This is an asynchronous operation that returns a status of 202 until the template deployment is successfully deleted. The Location response header contains the URI that is used to obtain the status of the process. While the process is running, a call to the URI in the Location header returns a status of 202. When the process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. + + Deletes a deployment from the deployment history. + + :param resource_group_name: The name of the resource group with the deployment to delete. The + name is case insensitive. :type resource_group_name: str :param deployment_name: The name of the deployment to delete. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns None or - ClientRawResponse if raw==True - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._delete_initial( resource_group_name=resource_group_name, deployment_name=deployment_name, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore def check_existence( - self, resource_group_name, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Checks whether the deployment exists. - :param resource_group_name: The name of the resource group with the - deployment to check. The name is case insensitive. + :param resource_group_name: The name of the resource group with the deployment to check. The + name is case insensitive. :type resource_group_name: str :param deployment_name: The name of the deployment to check. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: bool or ClientRawResponse if raw=true - :rtype: bool or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-09-01" + # Construct URL - url = self.check_existence.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204, 404]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = (response.status_code == 204) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - return deserialized - check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + if cls: + return cls(pipeline_response, None, {}) + + 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, deployment_name, properties, custom_headers=None, raw=False, **operation_config): - parameters = models.Deployment(properties=properties) + self, + resource_group_name, # type: str + deployment_name, # type: str + properties, # type: "models.DeploymentProperties" + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentExtended" + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.Deployment(properties=properties) + api_version = "2016-09-01" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.create_or_update.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'Deployment') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 201]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', response) + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', response) + deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - - def create_or_update( - self, resource_group_name, deployment_name, properties, custom_headers=None, raw=False, polling=True, **operation_config): - """Deploys resources to a resource group. - - You can provide the template and parameters directly in the request or - link to JSON files. - - :param resource_group_name: The name of the resource group to deploy - the resources to. The name is case insensitive. The resource group - must already exist. + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + def begin_create_or_update( + self, + resource_group_name, # type: str + deployment_name, # type: str + properties, # type: "models.DeploymentProperties" + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """You can provide the template and parameters directly in the request or link to JSON files. + + Deploys resources to a resource group. + + :param resource_group_name: The name of the resource group to deploy the resources to. The name + is case insensitive. The resource group must already exist. :type resource_group_name: str :param deployment_name: The name of the deployment. :type deployment_name: str :param properties: The deployment properties. - :type properties: - ~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentProperties - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :type properties: ~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentProperties + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns DeploymentExtended or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentExtended] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentExtended]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 DeploymentExtended + :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] + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._create_or_update_initial( resource_group_name=resource_group_name, deployment_name=deployment_name, properties=properties, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - deserialized = self._deserialize('DeploymentExtended', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore def get( - self, resource_group_name, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentExtended" """Gets a deployment. - :param resource_group_name: The name of the resource group. The name - is case insensitive. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param deployment_name: The name of the deployment to get. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentExtended or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentExtended - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExtended or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentExtended + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-09-01" + # Construct URL - url = self.get.metadata['url'] + url = self.get.metadata['url'] # type: 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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', response) + deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore def cancel( - self, resource_group_name, deployment_name, custom_headers=None, raw=False, **operation_config): - """Cancels a currently running template deployment. + self, + resource_group_name, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """You can cancel a deployment only if the provisioningState is Accepted or Running. After the deployment is canceled, the provisioningState is set to Canceled. Canceling a template deployment stops the currently running template deployment and leaves the resource group partially deployed. - You can cancel a deployment only if the provisioningState is Accepted - or Running. After the deployment is canceled, the provisioningState is - set to Canceled. Canceling a template deployment stops the currently - running template deployment and leaves the resource group partially - deployed. + Cancels a currently running template deployment. - :param resource_group_name: The name of the resource group. The name - is case insensitive. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param deployment_name: The name of the deployment to cancel. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-09-01" + # Construct URL - url = self.cancel.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - cancel.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} + if cls: + return cls(pipeline_response, None, {}) - def validate( - self, resource_group_name, deployment_name, properties, custom_headers=None, raw=False, **operation_config): - """Validates whether the specified template is syntactically correct and - will be accepted by Azure Resource Manager.. + cancel.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore - :param resource_group_name: The name of the resource group the - template will be deployed to. The name is case insensitive. + def validate( + self, + resource_group_name, # type: str + deployment_name, # type: str + properties, # type: "models.DeploymentProperties" + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentValidateResult" + """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. :type resource_group_name: str :param deployment_name: The name of the deployment. :type deployment_name: str :param properties: The deployment properties. - :type properties: - ~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentProperties - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentValidateResult or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentValidateResult - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :type properties: ~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentProperties + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentValidateResult + :raises: ~azure.core.exceptions.HttpResponseError """ - parameters = models.Deployment(properties=properties) + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentValidateResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.Deployment(properties=properties) + api_version = "2016-09-01" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.validate.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'Deployment') # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 400]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', response) + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', response) + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - validate.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} + validate.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore def export_template( - self, resource_group_name, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentExportResult" """Exports the template used for specified deployment. - :param resource_group_name: The name of the resource group. The name - is case insensitive. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str - :param deployment_name: The name of the deployment from which to get - the template. + :param deployment_name: The name of the deployment from which to get the template. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentExportResult or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentExportResult - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentExportResult + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExportResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-09-01" + # Construct URL - url = self.export_template.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentExportResult', response) + deserialized = self._deserialize('DeploymentExportResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} + export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore def list( - self, resource_group_name, filter=None, top=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.DeploymentListResult"] """Get all the deployments for a resource group. - :param resource_group_name: The name of the resource group with the - deployments to get. The name is case insensitive. + :param resource_group_name: The name of the resource group with the deployments to get. The + name is case insensitive. :type resource_group_name: str - :param filter: The filter to apply on the operation. For example, you - can use $filter=provisioningState eq '{state}'. + :param filter: The filter to apply on the operation. For example, you can use + $filter=provisioningState eq '{state}'. :type filter: str - :param top: The number of results to get. If null is passed, returns - all deployments. + :param top: The number of results to get. If null is passed, returns all deployments. :type top: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of DeploymentExtended - :rtype: - ~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentExtendedPaged[~azure.mgmt.resource.resources.v2016_09_01.models.DeploymentExtended] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-09-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.DeploymentExtendedPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/'} # type: ignore def calculate_template_hash( - self, template, custom_headers=None, raw=False, **operation_config): + self, + template, # type: object + **kwargs # type: Any + ): + # type: (...) -> "models.TemplateHashResult" """Calculate the hash of the given template. :param template: The template provided to calculate hash. :type template: object - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: TemplateHashResult or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2016_09_01.models.TemplateHashResult - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateHashResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.TemplateHashResult + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TemplateHashResult"] + error_map = {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.calculate_template_hash.metadata['url'] + url = self.calculate_template_hash.metadata['url'] # type: ignore # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(template, 'object') # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('TemplateHashResult', response) + deserialized = self._deserialize('TemplateHashResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - calculate_template_hash.metadata = {'url': '/providers/Microsoft.Resources/calculateTemplateHash'} + 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 efda6c37d20e..b86e4f92041d 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 @@ -1,300 +1,287 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class ProvidersOperations(object): """ProvidersOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2016_09_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for this operation. Constant value: "2016-09-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2016-09-01" - - self.config = config + self._config = config def unregister( - self, resource_provider_namespace, custom_headers=None, raw=False, **operation_config): + self, + resource_provider_namespace, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.Provider" """Unregisters a subscription from a resource provider. - :param resource_provider_namespace: The namespace of the resource - provider to unregister. + :param resource_provider_namespace: The namespace of the resource provider to unregister. :type resource_provider_namespace: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: Provider or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.Provider or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Provider or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.Provider + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Provider"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-09-01" + # Construct URL - url = self.unregister.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('Provider', response) + deserialized = self._deserialize('Provider', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - unregister.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister'} + unregister.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister'} # type: ignore def register( - self, resource_provider_namespace, custom_headers=None, raw=False, **operation_config): + self, + resource_provider_namespace, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.Provider" """Registers a subscription with a resource provider. - :param resource_provider_namespace: The namespace of the resource - provider to register. + :param resource_provider_namespace: The namespace of the resource provider to register. :type resource_provider_namespace: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: Provider or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.Provider or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Provider or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.Provider + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Provider"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-09-01" + # Construct URL - url = self.register.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('Provider', response) + deserialized = self._deserialize('Provider', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - register.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register'} + register.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register'} # type: ignore def list( - self, top=None, expand=None, custom_headers=None, raw=False, **operation_config): + self, + top=None, # type: Optional[int] + expand=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.ProviderListResult"] """Gets all resource providers for a subscription. - :param top: The number of results to return. If null is passed returns - all deployments. + :param top: The number of results to return. If null is passed returns all deployments. :type top: int - :param expand: The properties to include in the results. For example, - use &$expand=metadata in the query string to retrieve resource - provider metadata. To include property aliases in response, use - $expand=resourceTypes/aliases. + :param expand: The properties to include in the results. For example, use &$expand=metadata in + the query string to retrieve resource provider metadata. To include property aliases in + response, use $expand=resourceTypes/aliases. :type expand: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of Provider - :rtype: - ~azure.mgmt.resource.resources.v2016_09_01.models.ProviderPaged[~azure.mgmt.resource.resources.v2016_09_01.models.Provider] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of ProviderListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-09-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['url'] + url = self.list.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_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 = {} + 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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('ProviderListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.ProviderPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers'} # type: ignore def get( - self, resource_provider_namespace, expand=None, custom_headers=None, raw=False, **operation_config): + self, + resource_provider_namespace, # type: str + expand=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.Provider" """Gets the specified resource provider. - :param resource_provider_namespace: The namespace of the resource - provider. + :param resource_provider_namespace: The namespace of the resource provider. :type resource_provider_namespace: str - :param expand: The $expand query parameter. For example, to include - property aliases in response, use $expand=resourceTypes/aliases. + :param expand: The $expand query parameter. For example, to include property aliases in + response, use $expand=resourceTypes/aliases. :type expand: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: Provider or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.Provider or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Provider or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.Provider + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Provider"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-09-01" + # Construct URL - url = self.get.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('Provider', response) + deserialized = self._deserialize('Provider', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}'} + 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 e512b91d0bd9..9db23ea3287e 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 @@ -1,612 +1,598 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError -from msrest.polling import LROPoller, NoPolling -from msrestazure.polling.arm_polling import ARMPolling +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, List, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class ResourceGroupsOperations(object): """ResourceGroupsOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2016_09_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for this operation. Constant value: "2016-09-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2016-09-01" - - self.config = config + self._config = config def list_resources( - self, resource_group_name, filter=None, expand=None, top=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + filter=None, # type: Optional[str] + expand=None, # type: Optional[str] + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.ResourceListResult"] """Get all the resources for a resource group. - :param resource_group_name: The resource group with the resources to - get. + :param resource_group_name: The resource group with the resources to get. :type resource_group_name: str :param filter: The filter to apply on the operation. :type filter: str - :param expand: Comma-separated list of additional properties to be - included in the response. Valid values include `createdTime`, - `changedTime` and `provisioningState`. For example, - `$expand=createdTime,changedTime`. + :param expand: Comma-separated list of additional properties to be included in the response. + Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, + ``$expand=createdTime,changedTime``. :type expand: str - :param top: The 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 - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of GenericResourceExpanded - :rtype: - ~azure.mgmt.resource.resources.v2016_09_01.models.GenericResourceExpandedPaged[~azure.mgmt.resource.resources.v2016_09_01.models.GenericResourceExpanded] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of ResourceListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-09-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_resources.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('ResourceListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.GenericResourceExpandedPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources'} + return ItemPaged( + get_next, extract_data + ) + list_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources'} # type: ignore def check_existence( - self, resource_group_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Checks whether a resource group exists. - :param resource_group_name: The name of the resource group to check. - The name is case insensitive. + :param resource_group_name: The name of the resource group to check. The name is case + insensitive. :type resource_group_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: bool or ClientRawResponse if raw=true - :rtype: bool or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-09-01" + # Construct URL - url = self.check_existence.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204, 404]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = (response.status_code == 204) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - return deserialized - check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore def create_or_update( - self, resource_group_name, parameters, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + parameters, # type: "models.ResourceGroup" + **kwargs # type: Any + ): + # type: (...) -> "models.ResourceGroup" """Creates a resource group. - :param resource_group_name: The name of the resource group to create - or update. + :param resource_group_name: The name of the resource group to create or update. :type resource_group_name: str - :param parameters: Parameters supplied to the create or update a - resource group. - :type parameters: - ~azure.mgmt.resource.resources.v2016_09_01.models.ResourceGroup - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: ResourceGroup or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2016_09_01.models.ResourceGroup or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :param parameters: Parameters supplied to the create or update a resource group. + :type parameters: ~azure.mgmt.resource.resources.v2016_09_01.models.ResourceGroup + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.ResourceGroup + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceGroup"] + error_map = {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.create_or_update.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'ResourceGroup') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 201]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ResourceGroup', response) + deserialized = self._deserialize('ResourceGroup', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('ResourceGroup', response) + deserialized = self._deserialize('ResourceGroup', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} - + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore def _delete_initial( - self, resource_group_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-09-01" + # Construct URL - url = self.delete.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 202]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + if cls: + return cls(pipeline_response, None, {}) - def delete( - self, resource_group_name, custom_headers=None, raw=False, polling=True, **operation_config): - """Deletes a resource group. + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore - When you delete a resource group, all of its resources are also - deleted. Deleting a resource group deletes all of its template - deployments and currently stored operations. + def begin_delete( + self, + resource_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """When you delete a resource group, all of its resources are also deleted. Deleting a resource group deletes all of its template deployments and currently stored operations. - :param resource_group_name: The name of the resource group to delete. - The name is case insensitive. + Deletes a resource group. + + :param resource_group_name: The name of the resource group to delete. The name is case + insensitive. :type resource_group_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns None or - ClientRawResponse if raw==True - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._delete_initial( resource_group_name=resource_group_name, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore def get( - self, resource_group_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.ResourceGroup" """Gets a resource group. - :param resource_group_name: The name of the resource group to get. The - name is case insensitive. + :param resource_group_name: The name of the resource group to get. The name is case + insensitive. :type resource_group_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: ResourceGroup or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2016_09_01.models.ResourceGroup or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.ResourceGroup + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceGroup"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-09-01" + # Construct URL - url = self.get.metadata['url'] + url = self.get.metadata['url'] # type: 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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('ResourceGroup', response) + deserialized = self._deserialize('ResourceGroup', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore def patch( - self, resource_group_name, parameters, custom_headers=None, raw=False, **operation_config): - """Updates a resource group. - - Resource groups can be updated through a simple PATCH operation to a - group address. The format of the request is the same as that for - creating a resource group. If a field is unspecified, the current value - is retained. - - :param resource_group_name: The name of the resource group to update. - The name is case insensitive. + self, + resource_group_name, # type: str + parameters, # type: "models.ResourceGroup" + **kwargs # type: Any + ): + # type: (...) -> "models.ResourceGroup" + """Resource groups can be updated through a simple PATCH operation to a group address. The format of the request is the same as that for creating a resource group. If a field is unspecified, the current value is retained. + + Updates a resource group. + + :param resource_group_name: The name of the resource group to update. The name is case + insensitive. :type resource_group_name: str :param parameters: Parameters supplied to update a resource group. - :type parameters: - ~azure.mgmt.resource.resources.v2016_09_01.models.ResourceGroup - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: ResourceGroup or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2016_09_01.models.ResourceGroup or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :type parameters: ~azure.mgmt.resource.resources.v2016_09_01.models.ResourceGroup + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.ResourceGroup + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceGroup"] + error_map = {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.patch.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'ResourceGroup') # Construct and send request - request = self._client.patch(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('ResourceGroup', response) + deserialized = self._deserialize('ResourceGroup', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - patch.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} + patch.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore def export_template( - self, resource_group_name, resources=None, options=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + resources=None, # type: Optional[List[str]] + options=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.ResourceGroupExportResult" """Captures the specified resource group as a template. - :param resource_group_name: The name of the resource group to export - as a template. + :param resource_group_name: The name of the resource group to export as a template. :type resource_group_name: str - :param resources: The IDs of the resources to filter the export by. To - export all resources, supply an array with single entry '*'. + :param 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', - 'SkipResourceNameParameterization', 'SkipAllParameterization' + :param options: The export template options. A CSV-formatted list containing zero or more of + the following: 'IncludeParameterDefaultValue', 'IncludeComments', + 'SkipResourceNameParameterization', 'SkipAllParameterization'. :type options: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: ResourceGroupExportResult or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2016_09_01.models.ResourceGroupExportResult - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroupExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.ResourceGroupExportResult + :raises: ~azure.core.exceptions.HttpResponseError """ - parameters = models.ExportTemplateRequest(resources=resources, options=options) + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceGroupExportResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.ExportTemplateRequest(resources=resources, options=options) + api_version = "2016-09-01" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.export_template.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'ExportTemplateRequest') # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('ResourceGroupExportResult', response) + deserialized = self._deserialize('ResourceGroupExportResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate'} + export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate'} # type: ignore def list( - self, filter=None, top=None, custom_headers=None, raw=False, **operation_config): + self, + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.ResourceGroupListResult"] """Gets all the resource groups for a subscription. :param filter: The filter to apply on the operation. :type filter: str - :param top: The number of results to return. If null is passed, - returns all resource groups. + :param top: The number of results to return. If null is passed, returns all resource groups. :type top: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of ResourceGroup - :rtype: - ~azure.mgmt.resource.resources.v2016_09_01.models.ResourceGroupPaged[~azure.mgmt.resource.resources.v2016_09_01.models.ResourceGroup] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-09-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['url'] + url = self.list.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_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 = {} + 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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('ResourceGroupListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.ResourceGroupPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups'} # type: ignore 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 ecdde9ebe7c6..cdd17ad0ab26 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 @@ -1,341 +1,366 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError -from msrest.polling import LROPoller, NoPolling -from msrestazure.polling.arm_polling import ARMPolling +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, List, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class ResourcesOperations(object): """ResourcesOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2016_09_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for this operation. Constant value: "2016-09-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2016-09-01" - - self.config = config - + self._config = config def _move_resources_initial( - self, source_resource_group_name, resources=None, target_resource_group=None, custom_headers=None, raw=False, **operation_config): - parameters = models.ResourcesMoveInfo(resources=resources, target_resource_group=target_resource_group) + self, + source_resource_group_name, # type: str + resources=None, # type: Optional[List[str]] + target_resource_group=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.ResourcesMoveInfo(resources=resources, target_resource_group=target_resource_group) + api_version = "2016-09-01" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.move_resources.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'ResourcesMoveInfo') + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [202, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - - def move_resources( - self, source_resource_group_name, resources=None, target_resource_group=None, custom_headers=None, raw=False, polling=True, **operation_config): - """Moves resources from one resource group to another resource group. - - The resources to move must be in the same source resource group. The - target resource group may be in a different subscription. When moving - resources, both the source group and the target group are locked for - the duration of the operation. Write and delete operations are blocked - on the groups until the move completes. . - - :param source_resource_group_name: The name of the resource group - containing the resources to move. + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore + + def begin_move_resources( + self, + source_resource_group_name, # type: str + resources=None, # type: Optional[List[str]] + target_resource_group=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """The resources to move must be in the same source resource group. The target resource group may be in a different subscription. When moving resources, both the source group and the target group are locked for the duration of the operation. Write and delete operations are blocked on the groups until the move completes. + + Moves resources from one resource group to another resource group. + + :param source_resource_group_name: The name of the resource group containing the resources to + move. :type source_resource_group_name: str :param resources: The IDs of the resources. :type resources: list[str] :param target_resource_group: The target resource group. :type target_resource_group: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns None or - ClientRawResponse if raw==True - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._move_resources_initial( source_resource_group_name=source_resource_group_name, resources=resources, target_resource_group=target_resource_group, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} + begin_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore def list( - self, filter=None, expand=None, top=None, custom_headers=None, raw=False, **operation_config): + self, + filter=None, # type: Optional[str] + expand=None, # type: Optional[str] + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.ResourceListResult"] """Get all the resources in a subscription. :param filter: The filter to apply on the operation. :type filter: str - :param expand: Comma-separated list of additional properties to be - included in the response. Valid values include `createdTime`, - `changedTime` and `provisioningState`. For example, - `$expand=createdTime,changedTime`. + :param expand: Comma-separated list of additional properties to be included in the response. + Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, + ``$expand=createdTime,changedTime``. :type expand: str - :param top: The number of results to return. If null is passed, - returns all resource groups. + :param top: The number of results to return. If null is passed, returns all resource groups. :type top: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of GenericResourceExpanded - :rtype: - ~azure.mgmt.resource.resources.v2016_09_01.models.GenericResourceExpandedPaged[~azure.mgmt.resource.resources.v2016_09_01.models.GenericResourceExpanded] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of ResourceListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-09-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['url'] + url = self.list.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_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 = {} + 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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('ResourceListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.GenericResourceExpandedPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resources'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resources'} # type: ignore def check_existence( - self, resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, api_version, custom_headers=None, raw=False, **operation_config): + self, + 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: (...) -> None """Checks whether a resource exists. - :param resource_group_name: The name of the resource group containing - the resource to check. The name is case insensitive. + :param resource_group_name: The name of the resource group containing the resource to check. + The name is case insensitive. :type resource_group_name: str - :param resource_provider_namespace: The resource provider of the - resource to check. + :param resource_provider_namespace: The resource provider of the resource to check. :type resource_provider_namespace: str :param parent_resource_path: The parent resource identity. :type parent_resource_path: str :param resource_type: The resource type. :type resource_type: str - :param resource_name: The name of the resource to check whether it - exists. + :param resource_name: The name of the resource to check whether it exists. :type resource_name: str - :param api_version: The API version to use for the operation. - :type api_version: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: bool or ClientRawResponse if raw=true - :rtype: bool or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-09-01" + # Construct URL - url = self.check_existence.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204, 404]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = (response.status_code == 204) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - return deserialized - check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + 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, resource_provider_namespace, parent_resource_path, resource_type, resource_name, api_version, custom_headers=None, raw=False, **operation_config): + self, + 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: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-09-01" + # Construct URL - url = self.delete.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - - def delete( - self, resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, api_version, custom_headers=None, raw=False, polling=True, **operation_config): + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + def begin_delete( + self, + 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: (...) -> LROPoller """Deletes a resource. - :param resource_group_name: The name of the resource group that - contains the resource to delete. The name is case insensitive. + :param resource_group_name: The name of the resource group that contains the resource to + delete. The name is case insensitive. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource - provider. + :param resource_provider_namespace: The namespace of the resource provider. :type resource_provider_namespace: str :param parent_resource_path: The parent resource identity. :type parent_resource_path: str @@ -343,109 +368,122 @@ def delete( :type resource_type: str :param resource_name: The name of the resource to delete. :type resource_name: str - :param api_version: The API version to use for the operation. - :type api_version: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns None or - ClientRawResponse if raw==True - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._delete_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, - api_version=api_version, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} - + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore def _create_or_update_initial( - self, resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, api_version, parameters, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + parameters, # type: "models.GenericResource" + **kwargs # type: Any + ): + # type: (...) -> "models.GenericResource" + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {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.create_or_update.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'GenericResource') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 201, 202]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('GenericResource', response) + deserialized = self._deserialize('GenericResource', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('GenericResource', response) + deserialized = self._deserialize('GenericResource', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - - def create_or_update( - self, resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, api_version, parameters, custom_headers=None, raw=False, polling=True, **operation_config): + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + def begin_create_or_update( + self, + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + parameters, # type: "models.GenericResource" + **kwargs # type: Any + ): + # type: (...) -> LROPoller """Creates a resource. - :param resource_group_name: The name of the resource group for the - resource. The name is case insensitive. + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource - provider. + :param resource_provider_namespace: The namespace of the resource provider. :type resource_provider_namespace: str :param parent_resource_path: The parent resource identity. :type parent_resource_path: str @@ -453,117 +491,125 @@ def create_or_update( :type resource_type: str :param resource_name: The name of the resource to create. :type resource_name: str - :param api_version: The API version to use for the operation. - :type api_version: str :param parameters: Parameters for creating or updating the resource. - :type parameters: - ~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :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 polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns GenericResource or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 GenericResource + :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] + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._create_or_update_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, - api_version=api_version, parameters=parameters, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - deserialized = self._deserialize('GenericResource', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('GenericResource', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} - + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore def _update_initial( - self, resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, api_version, parameters, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + parameters, # type: "models.GenericResource" + **kwargs # type: Any + ): + # type: (...) -> "models.GenericResource" + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {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.update.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'GenericResource') # Construct and send request - request = self._client.patch(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 202]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('GenericResource', response) + deserialized = self._deserialize('GenericResource', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - - def update( - self, resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, api_version, parameters, custom_headers=None, raw=False, polling=True, **operation_config): + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + def begin_update( + self, + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + parameters, # type: "models.GenericResource" + **kwargs # type: Any + ): + # type: (...) -> LROPoller """Updates a resource. - :param resource_group_name: The name of the resource group for the - resource. The name is case insensitive. + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource - provider. + :param resource_provider_namespace: The namespace of the resource provider. :type resource_provider_namespace: str :param parent_resource_path: The parent resource identity. :type parent_resource_path: str @@ -571,64 +617,63 @@ def update( :type resource_type: str :param resource_name: The name of the resource to update. :type resource_name: str - :param api_version: The API version to use for the operation. - :type api_version: str :param parameters: Parameters for updating the resource. - :type parameters: - ~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :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 polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns GenericResource or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 GenericResource + :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] + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._update_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, - api_version=api_version, parameters=parameters, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - deserialized = self._deserialize('GenericResource', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('GenericResource', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore def get( - self, resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, api_version, custom_headers=None, raw=False, **operation_config): + self, + 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: (...) -> "models.GenericResource" """Gets a resource. - :param resource_group_name: The name of the resource group containing - the resource to get. The name is case insensitive. + :param resource_group_name: The name of the resource group containing the resource to get. The + name is case insensitive. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource - provider. + :param resource_provider_namespace: The namespace of the resource provider. :type resource_provider_namespace: str :param parent_resource_path: The parent resource identity. :type parent_resource_path: str @@ -636,461 +681,443 @@ def get( :type resource_type: str :param resource_name: The name of the resource to get. :type resource_name: str - :param api_version: The API version to use for the operation. - :type api_version: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: GenericResource or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GenericResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-09-01" + # Construct URL - url = self.get.metadata['url'] + url = self.get.metadata['url'] # type: 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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('GenericResource', response) + deserialized = self._deserialize('GenericResource', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore def check_existence_by_id( - self, resource_id, api_version, custom_headers=None, raw=False, **operation_config): + self, + resource_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Checks by ID whether a resource exists. - :param resource_id: The fully qualified ID of the resource, including - the resource name and resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. :type resource_id: str - :param api_version: The API version to use for the operation. - :type api_version: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: bool or ClientRawResponse if raw=true - :rtype: bool or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-09-01" + # Construct URL - url = self.check_existence_by_id.metadata['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) + '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 = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204, 404]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = (response.status_code == 204) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - return deserialized - check_existence_by_id.metadata = {'url': '/{resourceId}'} + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + return 200 <= response.status_code <= 299 + check_existence_by_id.metadata = {'url': '/{resourceId}'} # type: ignore def _delete_by_id_initial( - self, resource_id, api_version, custom_headers=None, raw=False, **operation_config): + self, + resource_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-09-01" + # Construct URL - url = self.delete_by_id.metadata['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) + '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 = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + _delete_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore - def delete_by_id( - self, resource_id, api_version, custom_headers=None, raw=False, polling=True, **operation_config): + def begin_delete_by_id( + self, + resource_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> LROPoller """Deletes a resource by ID. - :param resource_id: The fully qualified ID of the resource, including - the resource name and resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. :type resource_id: str - :param api_version: The API version to use for the operation. - :type api_version: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns None or - ClientRawResponse if raw==True - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._delete_by_id_initial( resource_id=resource_id, - api_version=api_version, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - delete_by_id.metadata = {'url': '/{resourceId}'} - + begin_delete_by_id.metadata = {'url': '/{resourceId}'} # type: ignore def _create_or_update_by_id_initial( - self, resource_id, api_version, parameters, custom_headers=None, raw=False, **operation_config): + self, + resource_id, # type: str + parameters, # type: "models.GenericResource" + **kwargs # type: Any + ): + # type: (...) -> "models.GenericResource" + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {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.create_or_update_by_id.metadata['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) + '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 = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'GenericResource') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 201, 202]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('GenericResource', response) + deserialized = self._deserialize('GenericResource', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('GenericResource', response) + deserialized = self._deserialize('GenericResource', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - - def create_or_update_by_id( - self, resource_id, api_version, parameters, custom_headers=None, raw=False, polling=True, **operation_config): + _create_or_update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + def begin_create_or_update_by_id( + self, + resource_id, # type: str + parameters, # type: "models.GenericResource" + **kwargs # type: Any + ): + # type: (...) -> LROPoller """Create a resource by ID. - :param resource_id: The fully qualified ID of the resource, including - the resource name and resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. :type resource_id: str - :param api_version: The API version to use for the operation. - :type api_version: str :param parameters: Create or update resource parameters. - :type parameters: - ~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :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 polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns GenericResource or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 GenericResource + :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] + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._create_or_update_by_id_initial( resource_id=resource_id, - api_version=api_version, parameters=parameters, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - deserialized = self._deserialize('GenericResource', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('GenericResource', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - create_or_update_by_id.metadata = {'url': '/{resourceId}'} - + begin_create_or_update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore def _update_by_id_initial( - self, resource_id, api_version, parameters, custom_headers=None, raw=False, **operation_config): + self, + resource_id, # type: str + parameters, # type: "models.GenericResource" + **kwargs # type: Any + ): + # type: (...) -> "models.GenericResource" + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {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.update_by_id.metadata['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) + '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 = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'GenericResource') # Construct and send request - request = self._client.patch(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 202]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('GenericResource', response) + deserialized = self._deserialize('GenericResource', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - - def update_by_id( - self, resource_id, api_version, parameters, custom_headers=None, raw=False, polling=True, **operation_config): + _update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + def begin_update_by_id( + self, + resource_id, # type: str + parameters, # type: "models.GenericResource" + **kwargs # type: Any + ): + # type: (...) -> LROPoller """Updates a resource by ID. - :param resource_id: The fully qualified ID of the resource, including - the resource name and resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. :type resource_id: str - :param api_version: The API version to use for the operation. - :type api_version: str :param parameters: Update resource parameters. - :type parameters: - ~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :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 polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns GenericResource or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 GenericResource + :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] + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._update_by_id_initial( resource_id=resource_id, - api_version=api_version, parameters=parameters, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - deserialized = self._deserialize('GenericResource', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('GenericResource', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - update_by_id.metadata = {'url': '/{resourceId}'} + begin_update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore def get_by_id( - self, resource_id, api_version, custom_headers=None, raw=False, **operation_config): + self, + resource_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.GenericResource" """Gets a resource by ID. - :param resource_id: The fully qualified ID of the resource, including - the resource name and resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. :type resource_id: str - :param api_version: The API version to use for the operation. - :type api_version: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: GenericResource or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GenericResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.GenericResource + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-09-01" + # Construct URL - url = self.get_by_id.metadata['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) + '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 = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('GenericResource', response) + deserialized = self._deserialize('GenericResource', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/{resourceId}'} + 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 7f4a7c78a822..4d35d7397213 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 @@ -1,340 +1,336 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class TagsOperations(object): """TagsOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2016_09_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for this operation. Constant value: "2016-09-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2016-09-01" - - self.config = config + self._config = config def delete_value( - self, tag_name, tag_value, custom_headers=None, raw=False, **operation_config): + self, + tag_name, # type: str + tag_value, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Deletes a tag value. :param tag_name: The name of the tag. :type tag_name: str :param tag_value: The value of the tag to delete. :type tag_value: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-09-01" + # Construct URL - url = self.delete_value.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} + delete_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore def create_or_update_value( - self, tag_name, tag_value, custom_headers=None, raw=False, **operation_config): + self, + tag_name, # type: str + tag_value, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.TagValue" """Creates a tag value. The name of the tag must already exist. :param tag_name: The name of the tag. :type tag_name: str :param tag_value: The value of the tag to create. :type tag_value: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: TagValue or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.TagValue or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagValue or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.TagValue + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TagValue"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-09-01" + # Construct URL - url = self.create_or_update_value.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.put(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 201]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('TagValue', response) + deserialized = self._deserialize('TagValue', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('TagValue', response) + deserialized = self._deserialize('TagValue', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} + create_or_update_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore def create_or_update( - self, tag_name, custom_headers=None, raw=False, **operation_config): - """Creates a tag in the subscription. + self, + tag_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.TagDetails" + """The tag name can have a maximum of 512 characters and is case insensitive. Tag names created by Azure have prefixes of microsoft, azure, or windows. You cannot create tags with one of these prefixes. - The tag name can have a maximum of 512 characters and is case - insensitive. Tag names created by Azure have prefixes of microsoft, - azure, or windows. You cannot create tags with one of these prefixes. + Creates a tag in the subscription. :param tag_name: The name of the tag to create. :type tag_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: TagDetails or ClientRawResponse if raw=true + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagDetails or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2016_09_01.models.TagDetails - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TagDetails"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-09-01" + # Construct URL - url = self.create_or_update.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.put(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 201]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('TagDetails', response) + deserialized = self._deserialize('TagDetails', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('TagDetails', response) + deserialized = self._deserialize('TagDetails', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore def delete( - self, tag_name, custom_headers=None, raw=False, **operation_config): - """Deletes a tag from the subscription. + self, + tag_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """You must remove all values from a resource tag before you can delete it. - You must remove all values from a resource tag before you can delete - it. + Deletes a tag from the subscription. :param tag_name: The name of the tag. :type tag_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-09-01" + # Construct URL - url = self.delete.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} + delete.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore def list( - self, custom_headers=None, raw=False, **operation_config): - """Gets the names and values of all resource tags that are defined in a - subscription. - - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of TagDetails - :rtype: - ~azure.mgmt.resource.resources.v2016_09_01.models.TagDetailsPaged[~azure.mgmt.resource.resources.v2016_09_01.models.TagDetails] - :raises: :class:`CloudError` + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.TagsListResult"] + """Gets the names and values of all resource tags that are defined in a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of TagsListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-09-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['url'] + url = self.list.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('TagsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.TagDetailsPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/py.typed b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file 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 deleted file mode 100644 index e63d4addb017..000000000000 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2016_09_01/version.py +++ /dev/null @@ -1,13 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -VERSION = "2016-09-01" - 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 68bc897193ac..fde2ed4c3b83 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 @@ -1,19 +1,16 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._configuration import ResourceManagementClientConfiguration from ._resource_management_client import ResourceManagementClient -__all__ = ['ResourceManagementClient', 'ResourceManagementClientConfiguration'] - -from .version import VERSION - -__version__ = VERSION +__all__ = ['ResourceManagementClient'] +try: + from ._patch import patch_sdk + patch_sdk() +except ImportError: + pass 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 3b326f792363..8a9afefc5e98 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 @@ -1,48 +1,69 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrestazure import AzureConfiguration -from .version import VERSION +from typing import TYPE_CHECKING +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + + from azure.core.credentials import TokenCredential + +VERSION = "unknown" + +class ResourceManagementClientConfiguration(Configuration): + """Configuration for ResourceManagementClient. -class ResourceManagementClientConfiguration(AzureConfiguration): - """Configuration for ResourceManagementClient Note that all parameters used to create this instance are saved as instance attributes. - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` + :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 """ def __init__( - self, credentials, subscription_id, base_url=None): - - if credentials is None: - raise ValueError("Parameter 'credentials' must not be None.") + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + 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.") - if not base_url: - base_url = 'https://management.azure.com' + super(ResourceManagementClientConfiguration, self).__init__(**kwargs) - super(ResourceManagementClientConfiguration, self).__init__(base_url) - - # Starting Autorest.Python 4.0.64, make connection pool activated by default - self.keep_alive = True - - self.add_user_agent('azure-mgmt-resource/{}'.format(VERSION)) - self.add_user_agent('Azure-SDK-For-Python') - - self.credentials = credentials + self.credential = credential self.subscription_id = subscription_id + self.api_version = "2017-05-10" + self.credential_scopes = ['https://management.azure.com/.default'] + self.credential_scopes.extend(kwargs.pop('credential_scopes', [])) + kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + 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) 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 new file mode 100644 index 000000000000..4ef89ae0ea08 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/_metadata.json @@ -0,0 +1,58 @@ +{ + "chosen_version": "2017-05-10", + "total_api_version_list": ["2017-05-10"], + "client": { + "name": "ResourceManagementClient", + "filename": "_resource_management_client", + "description": "Provides operations for working with resources and resource groups." + }, + "global_parameters": { + "sync_method": { + "credential": { + "method_signature": "credential, # type: \"TokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials.TokenCredential", + "required": true + }, + "subscription_id": { + "method_signature": "subscription_id, # type: str", + "description": "The ID of the target subscription.", + "docstring_type": "str", + "required": true + } + }, + "async_method": { + "credential": { + "method_signature": "credential, # type: \"AsyncTokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + }, + "subscription_id": { + "method_signature": "subscription_id, # type: str", + "description": "The ID of the target subscription.", + "docstring_type": "str", + "required": true + } + }, + "constant": { + }, + "call": "credential, subscription_id" + }, + "config": { + "credential": true, + "credential_scopes": ["https://management.azure.com/.default"] + }, + "operation_groups": { + "deployments": "DeploymentsOperations", + "providers": "ProvidersOperations", + "resources": "ResourcesOperations", + "resource_groups": "ResourceGroupsOperations", + "tags": "TagsOperations", + "deployment_operations": "DeploymentOperationsOperations" + }, + "operation_mixins": { + }, + "sync_imports": "None", + "async_imports": "None" +} \ 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 2c2a19c959e6..bb034b992175 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 @@ -1,16 +1,19 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.service_client import SDKClient -from msrest import Serializer, Deserializer +from typing import TYPE_CHECKING + +from azure.mgmt.core import ARMPipelineClient +from msrest import Deserializer, Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional from ._configuration import ResourceManagementClientConfiguration from .operations import DeploymentsOperations @@ -18,57 +21,72 @@ from .operations import ResourcesOperations from .operations import ResourceGroupsOperations from .operations import TagsOperations -from .operations import DeploymentOperations +from .operations import DeploymentOperationsOperations from . import models -class ResourceManagementClient(SDKClient): +class ResourceManagementClient(object): """Provides operations for working with resources and resource groups. - :ivar config: Configuration for client. - :vartype config: ResourceManagementClientConfiguration - - :ivar deployments: Deployments operations + :ivar deployments: DeploymentsOperations operations :vartype deployments: azure.mgmt.resource.resources.v2017_05_10.operations.DeploymentsOperations - :ivar providers: Providers operations + :ivar providers: ProvidersOperations operations :vartype providers: azure.mgmt.resource.resources.v2017_05_10.operations.ProvidersOperations - :ivar resources: Resources operations + :ivar resources: ResourcesOperations operations :vartype resources: azure.mgmt.resource.resources.v2017_05_10.operations.ResourcesOperations - :ivar resource_groups: ResourceGroups operations + :ivar resource_groups: ResourceGroupsOperations operations :vartype resource_groups: azure.mgmt.resource.resources.v2017_05_10.operations.ResourceGroupsOperations - :ivar tags: Tags operations + :ivar tags: TagsOperations operations :vartype tags: azure.mgmt.resource.resources.v2017_05_10.operations.TagsOperations - :ivar deployment_operations: DeploymentOperations operations - :vartype deployment_operations: azure.mgmt.resource.resources.v2017_05_10.operations.DeploymentOperations - - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` + :ivar deployment_operations: DeploymentOperationsOperations operations + :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. """ def __init__( - self, credentials, subscription_id, base_url=None): - - self.config = ResourceManagementClientConfiguration(credentials, subscription_id, base_url) - super(ResourceManagementClient, self).__init__(self.config.credentials, self.config) + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = 'https://management.azure.com' + self._config = ResourceManagementClientConfiguration(credential, 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.api_version = '2017-05-10' self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self.deployments = DeploymentsOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.providers = ProvidersOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.resources = ResourcesOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.resource_groups = ResourceGroupsOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.tags = TagsOperations( - self._client, self.config, self._serialize, self._deserialize) - self.deployment_operations = DeploymentOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) + self.deployment_operations = DeploymentOperationsOperations( + self._client, self._config, self._serialize, self._deserialize) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> ResourceManagementClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) 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 new file mode 100644 index 000000000000..7f9b1bac71c5 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/__init__.py @@ -0,0 +1,10 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._resource_management_client_async import ResourceManagementClient +__all__ = ['ResourceManagementClient'] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/_configuration_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/_configuration_async.py new file mode 100644 index 000000000000..9ba123b85c97 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/_configuration_async.py @@ -0,0 +1,65 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + +VERSION = "unknown" + +class ResourceManagementClientConfiguration(Configuration): + """Configuration for ResourceManagementClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :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 + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + 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 + self.api_version = "2017-05-10" + self.credential_scopes = ['https://management.azure.com/.default'] + self.credential_scopes.extend(kwargs.pop('credential_scopes', [])) + kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs: Any + ) -> None: + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + 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) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/_resource_management_client_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/_resource_management_client_async.py new file mode 100644 index 000000000000..2421801d3176 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/_resource_management_client_async.py @@ -0,0 +1,84 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, Optional + +from azure.mgmt.core import AsyncARMPipelineClient +from msrest import Deserializer, Serializer + +from ._configuration_async import ResourceManagementClientConfiguration +from .operations_async import DeploymentsOperations +from .operations_async import ProvidersOperations +from .operations_async import ResourcesOperations +from .operations_async import ResourceGroupsOperations +from .operations_async import TagsOperations +from .operations_async import DeploymentOperationsOperations +from .. import models + + +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.aio.operations_async.DeploymentsOperations + :ivar providers: ProvidersOperations operations + :vartype providers: azure.mgmt.resource.resources.v2017_05_10.aio.operations_async.ProvidersOperations + :ivar resources: ResourcesOperations operations + :vartype resources: azure.mgmt.resource.resources.v2017_05_10.aio.operations_async.ResourcesOperations + :ivar resource_groups: ResourceGroupsOperations operations + :vartype resource_groups: azure.mgmt.resource.resources.v2017_05_10.aio.operations_async.ResourceGroupsOperations + :ivar tags: TagsOperations operations + :vartype tags: azure.mgmt.resource.resources.v2017_05_10.aio.operations_async.TagsOperations + :ivar deployment_operations: DeploymentOperationsOperations operations + :vartype deployment_operations: azure.mgmt.resource.resources.v2017_05_10.aio.operations_async.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. + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: Optional[str] = None, + **kwargs: 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) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + + self.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 close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "ResourceManagementClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/operations_async/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/operations_async/__init__.py new file mode 100644 index 000000000000..c5133656c811 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/operations_async/__init__.py @@ -0,0 +1,23 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._deployments_operations_async import DeploymentsOperations +from ._providers_operations_async import ProvidersOperations +from ._resources_operations_async import ResourcesOperations +from ._resource_groups_operations_async import ResourceGroupsOperations +from ._tags_operations_async import TagsOperations +from ._deployment_operations_operations_async import DeploymentOperationsOperations + +__all__ = [ + 'DeploymentsOperations', + 'ProvidersOperations', + 'ResourcesOperations', + 'ResourceGroupsOperations', + 'TagsOperations', + 'DeploymentOperationsOperations', +] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/operations_async/_deployment_operations_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/operations_async/_deployment_operations_operations_async.py new file mode 100644 index 000000000000..18f2c1be0286 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/operations_async/_deployment_operations_operations_async.py @@ -0,0 +1,178 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import 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 ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class DeploymentOperationsOperations: + """DeploymentOperationsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2017_05_10.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def get( + self, + resource_group_name: str, + deployment_name: str, + operation_id: str, + **kwargs + ) -> "models.DeploymentOperation": + """Gets a deployments operation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param operation_id: The ID of the operation to get. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentOperation or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentOperation + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentOperation"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-05-10" + + # Construct URL + url = self.get.metadata['url'] # type: 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentOperation', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + def list( + self, + resource_group_name: str, + deployment_name: str, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.DeploymentOperationsListResult"]: + """Gets all deployments operations for a deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment with the operation to get. + :type deployment_name: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-05-10" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentOperationsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/operations_async/_deployments_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/operations_async/_deployments_operations_async.py new file mode 100644 index 000000000000..8511bdfc9efb --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/operations_async/_deployments_operations_async.py @@ -0,0 +1,670 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.polling import AsyncNoPolling, AsyncPollingMethod, async_poller +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class DeploymentsOperations: + """DeploymentsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2017_05_10.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def _delete_initial( + self, + resource_group_name: str, + deployment_name: str, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def delete( + self, + resource_group_name: str, + deployment_name: str, + **kwargs + ) -> None: + """A template deployment that is currently running cannot be deleted. Deleting a template deployment removes the associated deployment operations. Deleting a template deployment does not affect the state of the resource group. This is an asynchronous operation that returns a status of 202 until the template deployment is successfully deleted. The Location response header contains the URI that is used to obtain the status of the process. While the process is running, a call to the URI in the Location header returns a status of 202. When the process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. + + Deletes a deployment from the deployment history. + + :param resource_group_name: The name of the resource group with the deployment to delete. The + name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment to delete. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def check_existence( + self, + resource_group_name: str, + deployment_name: str, + **kwargs + ) -> None: + """Checks whether the deployment exists. + + :param resource_group_name: The name of the resource group with the deployment to check. The + name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment to check. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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] + + # Construct and send request + 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 + + if response.status_code not in [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + 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, + deployment_name: str, + properties: "models.DeploymentProperties", + **kwargs + ) -> "models.DeploymentExtended": + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.Deployment(properties=properties) + api_version = "2017-05-10" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def create_or_update( + self, + resource_group_name: str, + deployment_name: str, + properties: "models.DeploymentProperties", + **kwargs + ) -> "models.DeploymentExtended": + """You can provide the template and parameters directly in the request or link to JSON files. + + Deploys resources to a resource group. + + :param resource_group_name: The name of the resource group to deploy the resources to. The name + is case insensitive. The resource group must already exist. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param properties: The deployment properties. + :type properties: ~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentProperties + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: DeploymentExtended + :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentExtended + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + properties=properties, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def get( + self, + resource_group_name: str, + deployment_name: str, + **kwargs + ) -> "models.DeploymentExtended": + """Gets a deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment to get. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExtended or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentExtended + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-05-10" + + # Construct URL + url = self.get.metadata['url'] # type: 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def cancel( + self, + resource_group_name: str, + deployment_name: str, + **kwargs + ) -> None: + """You can cancel a deployment only if the provisioningState is Accepted or Running. After the deployment is canceled, the provisioningState is set to Canceled. Canceling a template deployment stops the currently running template deployment and leaves the resource group partially deployed. + + Cancels a currently running template deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment to cancel. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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] + + # Construct and send request + 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 [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + cancel.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + + async def validate( + self, + resource_group_name: str, + deployment_name: str, + properties: "models.DeploymentProperties", + **kwargs + ) -> "models.DeploymentValidateResult": + """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param properties: The deployment properties. + :type properties: ~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentProperties + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentValidateResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentValidateResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.Deployment(properties=properties) + api_version = "2017-05-10" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 400]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + + if response.status_code == 400: + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + validate.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + async def export_template( + self, + resource_group_name: str, + deployment_name: str, + **kwargs + ) -> "models.DeploymentExportResult": + """Exports the template used for specified deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment from which to get the template. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentExportResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExportResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-05-10" + + # 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'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + def list_by_resource_group( + self, + resource_group_name: str, + filter: Optional[str] = None, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.DeploymentListResult"]: + """Get all the deployments for a resource group. + + :param resource_group_name: The name of the resource group with the deployments to get. The + name is case insensitive. + :type resource_group_name: str + :param filter: The filter to apply on the operation. For example, you can use + $filter=provisioningState eq '{state}'. + :type filter: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-05-10" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + 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 + + async def calculate_template_hash( + self, + template: object, + **kwargs + ) -> "models.TemplateHashResult": + """Calculate the hash of the given template. + + :param template: The template provided to calculate hash. + :type template: object + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateHashResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.TemplateHashResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TemplateHashResult"] + error_map = {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.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'] = 'application/json' + + # Construct and send request + 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) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('TemplateHashResult', pipeline_response) + + if cls: + 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_async/_providers_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/operations_async/_providers_operations_async.py new file mode 100644 index 000000000000..fcdb5cd896c3 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/operations_async/_providers_operations_async.py @@ -0,0 +1,279 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import 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 ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ProvidersOperations: + """ProvidersOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2017_05_10.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def unregister( + self, + resource_provider_namespace: str, + **kwargs + ) -> "models.Provider": + """Unregisters a subscription from a resource provider. + + :param resource_provider_namespace: The namespace of the resource provider to unregister. + :type resource_provider_namespace: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Provider or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.Provider + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Provider"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-05-10" + + # 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'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Provider', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + unregister.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister'} # type: ignore + + async def register( + self, + resource_provider_namespace: str, + **kwargs + ) -> "models.Provider": + """Registers a subscription with a resource provider. + + :param resource_provider_namespace: The namespace of the resource provider to register. + :type resource_provider_namespace: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Provider or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.Provider + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Provider"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-05-10" + + # 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'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Provider', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + register.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register'} # type: ignore + + def list( + self, + top: Optional[int] = None, + expand: Optional[str] = None, + **kwargs + ) -> AsyncIterable["models.ProviderListResult"]: + """Gets all resource providers for a subscription. + + :param top: The number of results to return. If null is passed returns all deployments. + :type top: int + :param expand: The properties to include in the results. For example, use &$expand=metadata in + the query string to retrieve resource provider metadata. To include property aliases in + response, use $expand=resourceTypes/aliases. + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of ProviderListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-05-10" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ProviderListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers'} # type: ignore + + async def get( + self, + resource_provider_namespace: str, + expand: Optional[str] = None, + **kwargs + ) -> "models.Provider": + """Gets the specified resource provider. + + :param resource_provider_namespace: The namespace of the resource provider. + :type resource_provider_namespace: str + :param expand: The $expand query parameter. For example, to include property aliases in + response, use $expand=resourceTypes/aliases. + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Provider or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.Provider + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Provider"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-05-10" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Provider', pipeline_response) + + if cls: + 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_async/_resource_groups_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/operations_async/_resource_groups_operations_async.py new file mode 100644 index 000000000000..f4b7a1a2f31d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/operations_async/_resource_groups_operations_async.py @@ -0,0 +1,501 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, List, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.polling import AsyncNoPolling, AsyncPollingMethod, async_poller +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ResourceGroupsOperations: + """ResourceGroupsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2017_05_10.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def check_existence( + self, + resource_group_name: str, + **kwargs + ) -> None: + """Checks whether a resource group exists. + + :param resource_group_name: The name of the resource group to check. 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: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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] + + # Construct and send request + 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 + + if response.status_code not in [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + async def create_or_update( + self, + resource_group_name: str, + parameters: "models.ResourceGroup", + **kwargs + ) -> "models.ResourceGroup": + """Creates or updates a resource group. + + :param resource_group_name: The name of the resource group to create or update. + :type resource_group_name: str + :param parameters: Parameters supplied to the create or update a resource group. + :type parameters: ~azure.mgmt.resource.resources.v2017_05_10.models.ResourceGroup + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.ResourceGroup + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceGroup"] + error_map = {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.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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ResourceGroup', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ResourceGroup', pipeline_response) + + if cls: + 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, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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] + + # Construct and send request + 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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + async def delete( + self, + resource_group_name: str, + **kwargs + ) -> None: + """When you delete a resource group, all of its resources are also deleted. Deleting a resource group deletes all of its template deployments and currently stored operations. + + Deletes a resource group. + + :param resource_group_name: The name of the resource group to delete. 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 + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + async def get( + self, + resource_group_name: str, + **kwargs + ) -> "models.ResourceGroup": + """Gets a resource group. + + :param resource_group_name: The name of the resource group to get. 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: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.ResourceGroup + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceGroup"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-05-10" + + # Construct URL + url = self.get.metadata['url'] # type: 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ResourceGroup', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + async def update( + self, + resource_group_name: str, + parameters: "models.ResourceGroupPatchable", + **kwargs + ) -> "models.ResourceGroup": + """Resource groups can be updated through a simple PATCH operation to a group address. The format of the request is the same as that for creating a resource group. If a field is unspecified, the current value is retained. + + Updates a resource group. + + :param resource_group_name: The name of the resource group to update. The name is case + insensitive. + :type resource_group_name: str + :param parameters: Parameters supplied to update a resource group. + :type parameters: ~azure.mgmt.resource.resources.v2017_05_10.models.ResourceGroupPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.ResourceGroup + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceGroup"] + error_map = {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.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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ResourceGroup', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + async def export_template( + self, + resource_group_name: str, + resources: Optional[List[str]] = None, + options: Optional[str] = None, + **kwargs + ) -> "models.ResourceGroupExportResult": + """Captures the specified resource group as a template. + + :param resource_group_name: The name of the resource group to export as a template. + :type resource_group_name: str + :param 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', + 'SkipResourceNameParameterization', 'SkipAllParameterization'. + :type options: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroupExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.ResourceGroupExportResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceGroupExportResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.ExportTemplateRequest(resources=resources, options=options) + api_version = "2017-05-10" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ResourceGroupExportResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate'} # type: ignore + + def list( + self, + filter: Optional[str] = None, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.ResourceGroupListResult"]: + """Gets all the resource groups for a subscription. + + :param filter: The filter to apply on the operation. + :type filter: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-05-10" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ResourceGroupListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/operations_async/_resources_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/operations_async/_resources_operations_async.py new file mode 100644 index 000000000000..ac7065a7fc56 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/operations_async/_resources_operations_async.py @@ -0,0 +1,1284 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, List, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.polling import AsyncNoPolling, AsyncPollingMethod, async_poller +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ResourcesOperations: + """ResourcesOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2017_05_10.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list_by_resource_group( + self, + resource_group_name: str, + filter: Optional[str] = None, + expand: Optional[str] = None, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.ResourceListResult"]: + """Get all the resources for a resource group. + + :param resource_group_name: The resource group with the resources to get. + :type resource_group_name: str + :param filter: The filter to apply on the operation. + :type filter: str + :param expand: Comma-separated list of additional properties to be included in the response. + Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, + ``$expand=createdTime,changedTime``. + :type expand: str + :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 ResourceListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-05-10" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ResourceListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources'} # type: ignore + + async def _move_resources_initial( + self, + source_resource_group_name: str, + resources: Optional[List[str]] = None, + target_resource_group: Optional[str] = None, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.ResourcesMoveInfo(resources=resources, target_resource_group=target_resource_group) + 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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + + # Construct and send request + 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 + + if response.status_code not in [202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore + + async def move_resources( + self, + source_resource_group_name: str, + resources: Optional[List[str]] = None, + target_resource_group: Optional[str] = None, + **kwargs + ) -> None: + """The resources to move must be in the same source resource group. The target resource group may be in a different subscription. When moving resources, both the source group and the target group are locked for the duration of the operation. Write and delete operations are blocked on the groups until the move completes. + + Moves resources from one resource group to another resource group. + + :param source_resource_group_name: The name of the resource group containing the resources to + move. + :type source_resource_group_name: str + :param resources: The IDs of the resources. + :type resources: list[str] + :param target_resource_group: The target resource group. + :type target_resource_group: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._move_resources_initial( + source_resource_group_name=source_resource_group_name, + resources=resources, + target_resource_group=target_resource_group, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore + + async def _validate_move_resources_initial( + self, + source_resource_group_name: str, + resources: Optional[List[str]] = None, + target_resource_group: Optional[str] = None, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.ResourcesMoveInfo(resources=resources, target_resource_group=target_resource_group) + 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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + + # Construct and send request + 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 + + if response.status_code not in [202, 204, 409]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _validate_move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} # type: ignore + + async def validate_move_resources( + self, + source_resource_group_name: str, + resources: Optional[List[str]] = None, + target_resource_group: Optional[str] = None, + **kwargs + ) -> None: + """This operation checks whether the specified resources can be moved to the target. The resources to move must be in the same source resource group. The target resource group may be in a different subscription. If validation succeeds, it returns HTTP response code 204 (no content). If validation fails, it returns HTTP response code 409 (Conflict) with an error message. Retrieve the URL in the Location header value to check the result of the long-running operation. + + Validates whether resources can be moved from one resource group to another resource group. + + :param source_resource_group_name: The name of the resource group containing the resources to + validate for move. + :type source_resource_group_name: str + :param resources: The IDs of the resources. + :type resources: list[str] + :param target_resource_group: The target resource group. + :type target_resource_group: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._validate_move_resources_initial( + source_resource_group_name=source_resource_group_name, + resources=resources, + target_resource_group=target_resource_group, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + validate_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} # type: ignore + + def list( + self, + filter: Optional[str] = None, + expand: Optional[str] = None, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.ResourceListResult"]: + """Get all the resources in a subscription. + + :param filter: The filter to apply on the operation. + :type filter: str + :param expand: Comma-separated list of additional properties to be included in the response. + Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, + ``$expand=createdTime,changedTime``. + :type expand: str + :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 ResourceListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-05-10" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ResourceListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resources'} # type: ignore + + async def check_existence( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + **kwargs + ) -> None: + """Checks whether a resource exists. + + :param resource_group_name: The name of the resource group containing the resource to check. + The name is case insensitive. + :type resource_group_name: str + :param resource_provider_namespace: The resource provider of the resource to check. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. + :type parent_resource_path: str + :param resource_type: The resource type. + :type resource_type: str + :param resource_name: The name of the resource to check whether it exists. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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\._\(\)]+$'), + 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), + 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_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] + + # Construct and send request + 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 + + if response.status_code not in [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + 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, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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\._\(\)]+$'), + 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), + 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + async def delete( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + **kwargs + ) -> None: + """Deletes a resource. + + :param resource_group_name: The name of the resource group that contains the resource to + delete. The name is case insensitive. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. + :type parent_resource_path: str + :param resource_type: The resource type. + :type resource_type: str + :param resource_name: The name of the resource to delete. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._delete_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, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + parameters: "models.GenericResource", + **kwargs + ) -> "models.GenericResource": + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {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._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'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 201, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('GenericResource', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + async def create_or_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + parameters: "models.GenericResource", + **kwargs + ) -> "models.GenericResource": + """Creates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to create. + :type resource_type: str + :param resource_name: The name of the resource to create. + :type resource_name: str + :param parameters: Parameters for creating or updating the resource. + :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 polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: GenericResource + :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._create_or_update_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, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + 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, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + parameters: "models.GenericResource", + **kwargs + ) -> "models.GenericResource": + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {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._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'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + async def update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + parameters: "models.GenericResource", + **kwargs + ) -> "models.GenericResource": + """Updates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to update. + :type resource_type: str + :param resource_name: The name of the resource to update. + :type resource_name: str + :param parameters: Parameters for updating the resource. + :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 polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: GenericResource + :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._update_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, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + async def get( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + **kwargs + ) -> "models.GenericResource": + """Gets a resource. + + :param resource_group_name: The name of the resource group containing the resource to get. The + name is case insensitive. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. + :type parent_resource_path: str + :param resource_type: The resource type of the resource. + :type resource_type: str + :param resource_name: The name of the resource to get. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GenericResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-05-10" + + # Construct URL + url = self.get.metadata['url'] # type: 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + async def check_existence_by_id( + self, + resource_id: str, + **kwargs + ) -> None: + """Checks by ID whether a resource exists. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + :type resource_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-05-10" + + # 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] + + # Construct and send request + 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 + + if response.status_code not in [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + 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, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-05-10" + + # 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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + async def delete_by_id( + self, + resource_id: str, + **kwargs + ) -> None: + """Deletes a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + :type resource_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._delete_by_id_initial( + resource_id=resource_id, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + delete_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + + async def _create_or_update_by_id_initial( + self, + resource_id: str, + parameters: "models.GenericResource", + **kwargs + ) -> "models.GenericResource": + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {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._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) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 201, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('GenericResource', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + async def create_or_update_by_id( + self, + resource_id: str, + parameters: "models.GenericResource", + **kwargs + ) -> "models.GenericResource": + """Create a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + :type resource_id: str + :param parameters: Create or update resource parameters. + :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 polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: GenericResource + :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._create_or_update_by_id_initial( + resource_id=resource_id, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + create_or_update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + + async def _update_by_id_initial( + self, + resource_id: str, + parameters: "models.GenericResource", + **kwargs + ) -> "models.GenericResource": + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {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._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) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + async def update_by_id( + self, + resource_id: str, + parameters: "models.GenericResource", + **kwargs + ) -> "models.GenericResource": + """Updates a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + :type resource_id: str + :param parameters: Update resource parameters. + :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 polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: GenericResource + :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._update_by_id_initial( + resource_id=resource_id, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + + async def get_by_id( + self, + resource_id: str, + **kwargs + ) -> "models.GenericResource": + """Gets a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + :type resource_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GenericResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-05-10" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + 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_async/_tags_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/operations_async/_tags_operations_async.py new file mode 100644 index 000000000000..09b409948914 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/aio/operations_async/_tags_operations_async.py @@ -0,0 +1,327 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import 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 ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class TagsOperations: + """TagsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2017_05_10.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def delete_value( + self, + tag_name: str, + tag_value: str, + **kwargs + ) -> None: + """Deletes a tag value. + + :param tag_name: The name of the tag. + :type tag_name: str + :param tag_value: The value of the tag to delete. + :type tag_value: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore + + async def create_or_update_value( + self, + tag_name: str, + tag_value: str, + **kwargs + ) -> "models.TagValue": + """Creates a tag value. The name of the tag must already exist. + + :param tag_name: The name of the tag. + :type tag_name: str + :param tag_value: The value of the tag to create. + :type tag_value: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagValue or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.TagValue + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TagValue"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-05-10" + + # 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'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('TagValue', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('TagValue', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore + + async def create_or_update( + self, + tag_name: str, + **kwargs + ) -> "models.TagDetails": + """The tag name can have a maximum of 512 characters and is case insensitive. Tag names created by Azure have prefixes of microsoft, azure, or windows. You cannot create tags with one of these prefixes. + + Creates a tag in the subscription. + + :param tag_name: The name of the tag to create. + :type tag_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagDetails or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.TagDetails + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TagDetails"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-05-10" + + # 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'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('TagDetails', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('TagDetails', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore + + async def delete( + self, + tag_name: str, + **kwargs + ) -> None: + """You must remove all values from a resource tag before you can delete it. + + Deletes a tag from the subscription. + + :param tag_name: The name of the tag. + :type tag_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore + + def list( + self, + **kwargs + ) -> AsyncIterable["models.TagsListResult"]: + """Gets the names and values of all resource tags that are defined in a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of TagsListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-05-10" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('TagsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/models/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/models/__init__.py index 6d69aa4efb8f..31a4ee8bd5ee 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/models/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/models/__init__.py @@ -1,12 +1,9 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- try: @@ -19,8 +16,10 @@ from ._models_py3 import DeploymentExportResult from ._models_py3 import DeploymentExtended from ._models_py3 import DeploymentExtendedFilter + from ._models_py3 import DeploymentListResult from ._models_py3 import DeploymentOperation from ._models_py3 import DeploymentOperationProperties + from ._models_py3 import DeploymentOperationsListResult from ._models_py3 import DeploymentProperties from ._models_py3 import DeploymentPropertiesExtended from ._models_py3 import DeploymentValidateResult @@ -35,13 +34,16 @@ from ._models_py3 import ParametersLink from ._models_py3 import Plan from ._models_py3 import Provider + from ._models_py3 import ProviderListResult from ._models_py3 import ProviderResourceType from ._models_py3 import Resource from ._models_py3 import ResourceGroup from ._models_py3 import ResourceGroupExportResult from ._models_py3 import ResourceGroupFilter + from ._models_py3 import ResourceGroupListResult from ._models_py3 import ResourceGroupPatchable from ._models_py3 import ResourceGroupProperties + from ._models_py3 import ResourceListResult from ._models_py3 import ResourceManagementErrorWithDetails from ._models_py3 import ResourceProviderOperationDisplayProperties from ._models_py3 import ResourcesMoveInfo @@ -50,62 +52,63 @@ from ._models_py3 import TagCount from ._models_py3 import TagDetails from ._models_py3 import TagValue + from ._models_py3 import TagsListResult from ._models_py3 import TargetResource from ._models_py3 import TemplateHashResult from ._models_py3 import TemplateLink except (SyntaxError, ImportError): - from ._models import AliasPathType - from ._models import AliasType - from ._models import BasicDependency - from ._models import DebugSetting - from ._models import Dependency - from ._models import Deployment - from ._models import DeploymentExportResult - from ._models import DeploymentExtended - from ._models import DeploymentExtendedFilter - from ._models import DeploymentOperation - from ._models import DeploymentOperationProperties - from ._models import DeploymentProperties - from ._models import DeploymentPropertiesExtended - from ._models import DeploymentValidateResult - from ._models import ErrorAdditionalInfo - from ._models import ErrorResponse - from ._models import ExportTemplateRequest - from ._models import GenericResource - from ._models import GenericResourceExpanded - from ._models import GenericResourceFilter - from ._models import HttpMessage - from ._models import Identity - from ._models import ParametersLink - from ._models import Plan - from ._models import Provider - from ._models import ProviderResourceType - from ._models import Resource - from ._models import ResourceGroup - from ._models import ResourceGroupExportResult - from ._models import ResourceGroupFilter - from ._models import ResourceGroupPatchable - from ._models import ResourceGroupProperties - from ._models import ResourceManagementErrorWithDetails - from ._models import ResourceProviderOperationDisplayProperties - from ._models import ResourcesMoveInfo - from ._models import Sku - from ._models import SubResource - from ._models import TagCount - from ._models import TagDetails - from ._models import TagValue - from ._models import TargetResource - from ._models import TemplateHashResult - from ._models import TemplateLink -from ._paged_models import DeploymentExtendedPaged -from ._paged_models import DeploymentOperationPaged -from ._paged_models import GenericResourceExpandedPaged -from ._paged_models import ProviderPaged -from ._paged_models import ResourceGroupPaged -from ._paged_models import TagDetailsPaged + from ._models import AliasPathType # type: ignore + from ._models import AliasType # type: ignore + from ._models import BasicDependency # type: ignore + from ._models import DebugSetting # type: ignore + from ._models import Dependency # type: ignore + from ._models import Deployment # type: ignore + from ._models import DeploymentExportResult # type: ignore + from ._models import DeploymentExtended # type: ignore + from ._models import DeploymentExtendedFilter # type: ignore + from ._models import DeploymentListResult # type: ignore + from ._models import DeploymentOperation # type: ignore + from ._models import DeploymentOperationProperties # type: ignore + from ._models import DeploymentOperationsListResult # type: ignore + from ._models import DeploymentProperties # type: ignore + from ._models import DeploymentPropertiesExtended # type: ignore + from ._models import DeploymentValidateResult # type: ignore + from ._models import ErrorAdditionalInfo # type: ignore + from ._models import ErrorResponse # type: ignore + from ._models import ExportTemplateRequest # type: ignore + from ._models import GenericResource # type: ignore + from ._models import GenericResourceExpanded # type: ignore + from ._models import GenericResourceFilter # type: ignore + from ._models import HttpMessage # type: ignore + from ._models import Identity # type: ignore + from ._models import ParametersLink # type: ignore + from ._models import Plan # type: ignore + from ._models import Provider # type: ignore + from ._models import ProviderListResult # type: ignore + from ._models import ProviderResourceType # type: ignore + from ._models import Resource # type: ignore + from ._models import ResourceGroup # type: ignore + from ._models import ResourceGroupExportResult # type: ignore + from ._models import ResourceGroupFilter # type: ignore + from ._models import ResourceGroupListResult # type: ignore + from ._models import ResourceGroupPatchable # type: ignore + from ._models import ResourceGroupProperties # type: ignore + from ._models import ResourceListResult # type: ignore + from ._models import ResourceManagementErrorWithDetails # type: ignore + from ._models import ResourceProviderOperationDisplayProperties # type: ignore + from ._models import ResourcesMoveInfo # type: ignore + from ._models import Sku # type: ignore + from ._models import SubResource # type: ignore + from ._models import TagCount # type: ignore + from ._models import TagDetails # type: ignore + from ._models import TagValue # type: ignore + from ._models import TagsListResult # type: ignore + from ._models import TargetResource # type: ignore + from ._models import TemplateHashResult # type: ignore + from ._models import TemplateLink # type: ignore + from ._resource_management_client_enums import ( DeploymentMode, - ResourceIdentityType, ) __all__ = [ @@ -118,8 +121,10 @@ 'DeploymentExportResult', 'DeploymentExtended', 'DeploymentExtendedFilter', + 'DeploymentListResult', 'DeploymentOperation', 'DeploymentOperationProperties', + 'DeploymentOperationsListResult', 'DeploymentProperties', 'DeploymentPropertiesExtended', 'DeploymentValidateResult', @@ -134,13 +139,16 @@ 'ParametersLink', 'Plan', 'Provider', + 'ProviderListResult', 'ProviderResourceType', 'Resource', 'ResourceGroup', 'ResourceGroupExportResult', 'ResourceGroupFilter', + 'ResourceGroupListResult', 'ResourceGroupPatchable', 'ResourceGroupProperties', + 'ResourceListResult', 'ResourceManagementErrorWithDetails', 'ResourceProviderOperationDisplayProperties', 'ResourcesMoveInfo', @@ -149,15 +157,9 @@ 'TagCount', 'TagDetails', 'TagValue', + 'TagsListResult', 'TargetResource', 'TemplateHashResult', 'TemplateLink', - 'DeploymentExtendedPaged', - 'ProviderPaged', - 'GenericResourceExpandedPaged', - 'ResourceGroupPaged', - 'TagDetailsPaged', - 'DeploymentOperationPaged', 'DeploymentMode', - 'ResourceIdentityType', ] 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 4ebdb811118d..6e2f34bc6ce9 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 @@ -1,20 +1,16 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.serialization import Model -from msrest.exceptions import HttpOperationError +import msrest.serialization -class AliasPathType(Model): - """The type of the paths for alias. . +class AliasPathType(msrest.serialization.Model): + """The type of the paths for alias. :param path: The path of an alias. :type path: str @@ -27,20 +23,22 @@ class AliasPathType(Model): 'api_versions': {'key': 'apiVersions', 'type': '[str]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(AliasPathType, self).__init__(**kwargs) self.path = kwargs.get('path', None) self.api_versions = kwargs.get('api_versions', None) -class AliasType(Model): - """The alias type. . +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] + :type paths: list[~azure.mgmt.resource.resources.v2017_05_10.models.AliasPathType] """ _attribute_map = { @@ -48,13 +46,16 @@ class AliasType(Model): 'paths': {'key': 'paths', 'type': '[AliasPathType]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(AliasType, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.paths = kwargs.get('paths', None) -class BasicDependency(Model): +class BasicDependency(msrest.serialization.Model): """Deployment dependency information. :param id: The ID of the dependency. @@ -71,52 +72,25 @@ class BasicDependency(Model): 'resource_name': {'key': 'resourceName', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(BasicDependency, self).__init__(**kwargs) self.id = kwargs.get('id', None) self.resource_type = kwargs.get('resource_type', None) self.resource_name = kwargs.get('resource_name', None) -class CloudError(Model): - """An error response for a resource management request. - - :param error: - :type error: - ~azure.mgmt.resource.resources.v2017_05_10.models.ErrorResponse - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorResponse'}, - } - - def __init__(self, **kwargs): - super(CloudError, self).__init__(**kwargs) - self.error = kwargs.get('error', None) - - -class CloudErrorException(HttpOperationError): - """Server responsed with exception of type: 'CloudError'. - - :param deserialize: A deserializer - :param response: Server response to be deserialized. - """ - - def __init__(self, deserialize, response, *args): - - super(CloudErrorException, self).__init__(deserialize, response, 'CloudError', *args) - - -class DebugSetting(Model): +class DebugSetting(msrest.serialization.Model): """DebugSetting. - :param 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. + :param 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 """ @@ -124,17 +98,19 @@ class DebugSetting(Model): 'detail_level': {'key': 'detailLevel', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DebugSetting, self).__init__(**kwargs) self.detail_level = kwargs.get('detail_level', None) -class Dependency(Model): +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] + :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. @@ -150,7 +126,10 @@ class Dependency(Model): 'resource_name': {'key': 'resourceName', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Dependency, self).__init__(**kwargs) self.depends_on = kwargs.get('depends_on', None) self.id = kwargs.get('id', None) @@ -158,14 +137,13 @@ def __init__(self, **kwargs): self.resource_name = kwargs.get('resource_name', None) -class Deployment(Model): +class Deployment(msrest.serialization.Model): """Deployment operation parameters. 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 + :type properties: ~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentProperties """ _validation = { @@ -176,13 +154,16 @@ class Deployment(Model): 'properties': {'key': 'properties', 'type': 'DeploymentProperties'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Deployment, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) + self.properties = kwargs['properties'] -class DeploymentExportResult(Model): - """The deployment export result. . +class DeploymentExportResult(msrest.serialization.Model): + """The deployment export result. :param template: The template content. :type template: object @@ -192,16 +173,18 @@ class DeploymentExportResult(Model): 'template': {'key': 'template', 'type': 'object'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentExportResult, self).__init__(**kwargs) self.template = kwargs.get('template', None) -class DeploymentExtended(Model): +class DeploymentExtended(msrest.serialization.Model): """Deployment information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. @@ -225,14 +208,17 @@ class DeploymentExtended(Model): 'properties': {'key': 'properties', 'type': 'DeploymentPropertiesExtended'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentExtended, self).__init__(**kwargs) self.id = None - self.name = kwargs.get('name', None) + self.name = kwargs['name'] self.properties = kwargs.get('properties', None) -class DeploymentExtendedFilter(Model): +class DeploymentExtendedFilter(msrest.serialization.Model): """Deployment filter. :param provisioning_state: The provisioning state. @@ -243,16 +229,47 @@ class DeploymentExtendedFilter(Model): 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentExtendedFilter, self).__init__(**kwargs) self.provisioning_state = kwargs.get('provisioning_state', None) -class DeploymentOperation(Model): +class DeploymentListResult(msrest.serialization.Model): + """List of deployments. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[DeploymentExtended]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(DeploymentListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = None + + +class DeploymentOperation(msrest.serialization.Model): """Deployment operation information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Full deployment operation ID. :vartype id: str @@ -274,23 +291,25 @@ class DeploymentOperation(Model): 'properties': {'key': 'properties', 'type': 'DeploymentOperationProperties'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentOperation, self).__init__(**kwargs) self.id = None self.operation_id = None self.properties = kwargs.get('properties', None) -class DeploymentOperationProperties(Model): +class DeploymentOperationProperties(msrest.serialization.Model): """Deployment operation properties. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar provisioning_state: The state of the provisioning. :vartype provisioning_state: str :ivar timestamp: The date and time of the operation. - :vartype timestamp: datetime + :vartype timestamp: ~datetime.datetime :ivar service_request_id: Deployment operation service request id. :vartype service_request_id: str :ivar status_code: Operation status code. @@ -298,14 +317,11 @@ class DeploymentOperationProperties(Model): :ivar status_message: Operation status message. :vartype status_message: object :ivar target_resource: The target resource. - :vartype target_resource: - ~azure.mgmt.resource.resources.v2017_05_10.models.TargetResource + :vartype target_resource: ~azure.mgmt.resource.resources.v2017_05_10.models.TargetResource :ivar request: The HTTP request message. - :vartype request: - ~azure.mgmt.resource.resources.v2017_05_10.models.HttpMessage + :vartype request: ~azure.mgmt.resource.resources.v2017_05_10.models.HttpMessage :ivar response: The HTTP response message. - :vartype response: - ~azure.mgmt.resource.resources.v2017_05_10.models.HttpMessage + :vartype response: ~azure.mgmt.resource.resources.v2017_05_10.models.HttpMessage """ _validation = { @@ -330,7 +346,10 @@ class DeploymentOperationProperties(Model): 'response': {'key': 'response', 'type': 'HttpMessage'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentOperationProperties, self).__init__(**kwargs) self.provisioning_state = None self.timestamp = None @@ -342,45 +361,66 @@ def __init__(self, **kwargs): self.response = None -class DeploymentProperties(Model): +class DeploymentOperationsListResult(msrest.serialization.Model): + """List of deployment operations. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[DeploymentOperation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(DeploymentOperationsListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = None + + +class DeploymentProperties(msrest.serialization.Model): """Deployment properties. 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 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. + :param 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: object - :param 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. 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. + :param 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. + 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: object - :param 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 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 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 + 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 + :type debug_setting: ~azure.mgmt.resource.resources.v2017_05_10.models.DebugSetting """ _validation = { @@ -392,62 +432,55 @@ class DeploymentProperties(Model): 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, 'parameters': {'key': 'parameters', 'type': 'object'}, 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, - 'mode': {'key': 'mode', 'type': 'DeploymentMode'}, + 'mode': {'key': 'mode', 'type': 'str'}, 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentProperties, self).__init__(**kwargs) self.template = kwargs.get('template', None) self.template_link = kwargs.get('template_link', None) self.parameters = kwargs.get('parameters', None) self.parameters_link = kwargs.get('parameters_link', None) - self.mode = kwargs.get('mode', None) + self.mode = kwargs['mode'] self.debug_setting = kwargs.get('debug_setting', None) -class DeploymentPropertiesExtended(Model): +class DeploymentPropertiesExtended(msrest.serialization.Model): """Deployment properties with additional details. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :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 + :vartype timestamp: ~datetime.datetime :param outputs: Key/value pairs that represent deployment output. :type outputs: object - :param providers: The list of resource providers needed for the - deployment. - :type providers: - list[~azure.mgmt.resource.resources.v2017_05_10.models.Provider] + :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 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: object - :param 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. + :param 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: object - :param 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 include: 'Incremental', 'Complete' - :type mode: str or - ~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentMode + :param 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 + 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 + :type debug_setting: ~azure.mgmt.resource.resources.v2017_05_10.models.DebugSetting """ _validation = { @@ -467,11 +500,14 @@ class DeploymentPropertiesExtended(Model): 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, 'parameters': {'key': 'parameters', 'type': 'object'}, 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, - 'mode': {'key': 'mode', 'type': 'DeploymentMode'}, + 'mode': {'key': 'mode', 'type': 'str'}, 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentPropertiesExtended, self).__init__(**kwargs) self.provisioning_state = None self.correlation_id = None @@ -487,7 +523,7 @@ def __init__(self, **kwargs): self.debug_setting = kwargs.get('debug_setting', None) -class DeploymentValidateResult(Model): +class DeploymentValidateResult(msrest.serialization.Model): """Information from validate template deployment response. :param error: Validation error. @@ -503,17 +539,19 @@ class DeploymentValidateResult(Model): 'properties': {'key': 'properties', 'type': 'DeploymentPropertiesExtended'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentValidateResult, self).__init__(**kwargs) self.error = kwargs.get('error', None) self.properties = kwargs.get('properties', None) -class ErrorAdditionalInfo(Model): +class ErrorAdditionalInfo(msrest.serialization.Model): """The resource management error additional info. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar type: The additional info type. :vartype type: str @@ -531,17 +569,19 @@ class ErrorAdditionalInfo(Model): 'info': {'key': 'info', 'type': 'object'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None -class ErrorResponse(Model): +class ErrorResponse(msrest.serialization.Model): """The resource management error response. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar code: The error code. :vartype code: str @@ -550,8 +590,7 @@ class ErrorResponse(Model): :ivar target: The error target. :vartype target: str :ivar details: The error details. - :vartype details: - list[~azure.mgmt.resource.resources.v2017_05_10.models.ErrorResponse] + :vartype details: list[~azure.mgmt.resource.resources.v2017_05_10.models.ErrorResponse] :ivar additional_info: The error additional info. :vartype additional_info: list[~azure.mgmt.resource.resources.v2017_05_10.models.ErrorAdditionalInfo] @@ -573,7 +612,10 @@ class ErrorResponse(Model): 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ErrorResponse, self).__init__(**kwargs) self.code = None self.message = None @@ -582,16 +624,15 @@ def __init__(self, **kwargs): self.additional_info = None -class ExportTemplateRequest(Model): +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, supply an array with single entry '*'. + :param 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', 'SkipResourceNameParameterization', - 'SkipAllParameterization' + :param options: The export template options. A CSV-formatted list containing zero or more of + the following: 'IncludeParameterDefaultValue', 'IncludeComments', + 'SkipResourceNameParameterization', 'SkipAllParameterization'. :type options: str """ @@ -600,27 +641,29 @@ class ExportTemplateRequest(Model): 'options': {'key': 'options', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ExportTemplateRequest, self).__init__(**kwargs) self.resources = kwargs.get('resources', None) self.options = kwargs.get('options', None) -class Resource(Model): +class Resource(msrest.serialization.Model): """Basic set of the resource properties. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID + :ivar id: Resource ID. :vartype id: str - :ivar name: Resource name + :ivar name: Resource name. :vartype name: str - :ivar type: Resource type + :ivar type: Resource type. :vartype type: str - :param location: Resource location + :param location: Resource location. :type location: str - :param tags: Resource tags + :param tags: A set of tags. Resource tags. :type tags: dict[str, str] """ @@ -638,7 +681,10 @@ class Resource(Model): 'tags': {'key': 'tags', 'type': '{str}'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -650,18 +696,17 @@ def __init__(self, **kwargs): class GenericResource(Resource): """Resource information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID + :ivar id: Resource ID. :vartype id: str - :ivar name: Resource name + :ivar name: Resource name. :vartype name: str - :ivar type: Resource type + :ivar type: Resource type. :vartype type: str - :param location: Resource location + :param location: Resource location. :type location: str - :param tags: Resource tags + :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 @@ -698,7 +743,10 @@ class GenericResource(Resource): 'identity': {'key': 'identity', 'type': 'Identity'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(GenericResource, self).__init__(**kwargs) self.plan = kwargs.get('plan', None) self.properties = kwargs.get('properties', None) @@ -711,18 +759,17 @@ def __init__(self, **kwargs): class GenericResourceExpanded(GenericResource): """Resource information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID + :ivar id: Resource ID. :vartype id: str - :ivar name: Resource name + :ivar name: Resource name. :vartype name: str - :ivar type: Resource type + :ivar type: Resource type. :vartype type: str - :param location: Resource location + :param location: Resource location. :type location: str - :param tags: Resource tags + :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 @@ -736,14 +783,14 @@ class GenericResourceExpanded(GenericResource): :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 created_time: The created time of the resource. This is only present - if requested via the $expand query parameter. - :vartype created_time: datetime - :ivar changed_time: The changed time of the resource. This is only present - if requested via the $expand query parameter. - :vartype changed_time: datetime - :ivar provisioning_state: The provisioning state of the resource. This is - only present if requested via the $expand query parameter. + :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 + :ivar changed_time: The changed time of the resource. This is only present if requested via the + $expand query parameter. + :vartype changed_time: ~datetime.datetime + :ivar provisioning_state: The provisioning state of the resource. This is only present if + requested via the $expand query parameter. :vartype provisioning_state: str """ @@ -774,14 +821,17 @@ class GenericResourceExpanded(GenericResource): 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(GenericResourceExpanded, self).__init__(**kwargs) self.created_time = None self.changed_time = None self.provisioning_state = None -class GenericResourceFilter(Model): +class GenericResourceFilter(msrest.serialization.Model): """Resource filter. :param resource_type: The resource type. @@ -798,14 +848,17 @@ class GenericResourceFilter(Model): 'tagvalue': {'key': 'tagvalue', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(GenericResourceFilter, self).__init__(**kwargs) self.resource_type = kwargs.get('resource_type', None) self.tagname = kwargs.get('tagname', None) self.tagvalue = kwargs.get('tagvalue', None) -class HttpMessage(Model): +class HttpMessage(msrest.serialization.Model): """HTTP message. :param content: HTTP message content. @@ -816,53 +869,58 @@ class HttpMessage(Model): 'content': {'key': 'content', 'type': 'object'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(HttpMessage, self).__init__(**kwargs) self.content = kwargs.get('content', None) -class Identity(Model): +class Identity(msrest.serialization.Model): """Identity for the resource. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar principal_id: The principal ID of resource identity. :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :param type: The identity type. Possible values include: 'SystemAssigned' - :type type: str or - ~azure.mgmt.resource.resources.v2017_05_10.models.ResourceIdentityType + :ivar type: The identity type. Default value: "SystemAssigned". + :vartype type: str """ _validation = { 'principal_id': {'readonly': True}, 'tenant_id': {'readonly': True}, + 'type': {'constant': True}, } _attribute_map = { 'principal_id': {'key': 'principalId', 'type': 'str'}, 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'ResourceIdentityType'}, + 'type': {'key': 'type', 'type': 'str'}, } - def __init__(self, **kwargs): + type = "SystemAssigned" + + def __init__( + self, + **kwargs + ): super(Identity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None - self.type = kwargs.get('type', None) -class ParametersLink(Model): +class ParametersLink(msrest.serialization.Model): """Entity representing the reference to the deployment parameters. 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. + :param content_version: If included, must match the ContentVersion in the template. :type content_version: str """ @@ -875,13 +933,16 @@ class ParametersLink(Model): 'content_version': {'key': 'contentVersion', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ParametersLink, self).__init__(**kwargs) - self.uri = kwargs.get('uri', None) + self.uri = kwargs['uri'] self.content_version = kwargs.get('content_version', None) -class Plan(Model): +class Plan(msrest.serialization.Model): """Plan for the resource. :param name: The plan ID. @@ -904,7 +965,10 @@ class Plan(Model): 'version': {'key': 'version', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Plan, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.publisher = kwargs.get('publisher', None) @@ -913,11 +977,10 @@ def __init__(self, **kwargs): self.version = kwargs.get('version', None) -class Provider(Model): +class Provider(msrest.serialization.Model): """Resource provider information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The provider ID. :vartype id: str @@ -943,7 +1006,10 @@ class Provider(Model): 'resource_types': {'key': 'resourceTypes', 'type': '[ProviderResourceType]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Provider, self).__init__(**kwargs) self.id = None self.namespace = kwargs.get('namespace', None) @@ -951,17 +1017,44 @@ def __init__(self, **kwargs): self.resource_types = None -class ProviderResourceType(Model): +class ProviderListResult(msrest.serialization.Model): + """List of resource providers. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Provider]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ProviderListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = None + + +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. + :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] + :type aliases: list[~azure.mgmt.resource.resources.v2017_05_10.models.AliasType] :param api_versions: The API version. :type api_versions: list[str] :param properties: The properties. @@ -976,7 +1069,10 @@ class ProviderResourceType(Model): 'properties': {'key': 'properties', 'type': '{str}'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ProviderResourceType, self).__init__(**kwargs) self.resource_type = kwargs.get('resource_type', None) self.locations = kwargs.get('locations', None) @@ -985,11 +1081,10 @@ def __init__(self, **kwargs): self.properties = kwargs.get('properties', None) -class ResourceGroup(Model): +class ResourceGroup(msrest.serialization.Model): """Resource group information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. @@ -997,17 +1092,14 @@ class ResourceGroup(Model): :vartype id: str :param name: The name of the resource group. :type name: str - :param 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 resource group has been created. It must be one of - the supported Azure locations. + :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 + 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. + :param managed_by: The ID of the resource that manages this resource group. :type managed_by: str - :param tags: The tags attached to the resource group. + :param tags: A set of tags. The tags attached to the resource group. :type tags: dict[str, str] """ @@ -1025,17 +1117,20 @@ class ResourceGroup(Model): 'tags': {'key': 'tags', 'type': '{str}'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ResourceGroup, self).__init__(**kwargs) self.id = None self.name = kwargs.get('name', None) self.properties = kwargs.get('properties', None) - self.location = kwargs.get('location', None) + self.location = kwargs['location'] self.managed_by = kwargs.get('managed_by', None) self.tags = kwargs.get('tags', None) -class ResourceGroupExportResult(Model): +class ResourceGroupExportResult(msrest.serialization.Model): """Resource group export result. :param template: The template content. @@ -1050,13 +1145,16 @@ class ResourceGroupExportResult(Model): 'error': {'key': 'error', 'type': 'ResourceManagementErrorWithDetails'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ResourceGroupExportResult, self).__init__(**kwargs) self.template = kwargs.get('template', None) self.error = kwargs.get('error', None) -class ResourceGroupFilter(Model): +class ResourceGroupFilter(msrest.serialization.Model): """Resource group filter. :param tag_name: The tag name. @@ -1070,24 +1168,54 @@ class ResourceGroupFilter(Model): 'tag_value': {'key': 'tagValue', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ResourceGroupFilter, self).__init__(**kwargs) self.tag_name = kwargs.get('tag_name', None) self.tag_value = kwargs.get('tag_value', None) -class ResourceGroupPatchable(Model): +class ResourceGroupListResult(msrest.serialization.Model): + """List of resource groups. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ResourceGroup]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ResourceGroupListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = None + + +class ResourceGroupPatchable(msrest.serialization.Model): """Resource group information. :param name: The name of the resource group. :type name: str - :param 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. + :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: The tags attached to the resource group. + :param tags: A set of tags. The tags attached to the resource group. :type tags: dict[str, str] """ @@ -1098,7 +1226,10 @@ class ResourceGroupPatchable(Model): 'tags': {'key': 'tags', 'type': '{str}'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ResourceGroupPatchable, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.properties = kwargs.get('properties', None) @@ -1106,11 +1237,10 @@ def __init__(self, **kwargs): self.tags = kwargs.get('tags', None) -class ResourceGroupProperties(Model): +class ResourceGroupProperties(msrest.serialization.Model): """The resource group properties. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar provisioning_state: The provisioning state. :vartype provisioning_state: str @@ -1124,16 +1254,47 @@ class ResourceGroupProperties(Model): 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ResourceGroupProperties, self).__init__(**kwargs) self.provisioning_state = None -class ResourceManagementErrorWithDetails(Model): +class ResourceListResult(msrest.serialization.Model): + """List of resource groups. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[GenericResourceExpanded]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ResourceListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = None + + +class ResourceManagementErrorWithDetails(msrest.serialization.Model): """The detailed error message of resource management. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar code: The error code returned when exporting the template. :vartype code: str @@ -1160,7 +1321,10 @@ class ResourceManagementErrorWithDetails(Model): 'details': {'key': 'details', 'type': '[ResourceManagementErrorWithDetails]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ResourceManagementErrorWithDetails, self).__init__(**kwargs) self.code = None self.message = None @@ -1168,7 +1332,7 @@ def __init__(self, **kwargs): self.details = None -class ResourceProviderOperationDisplayProperties(Model): +class ResourceProviderOperationDisplayProperties(msrest.serialization.Model): """Resource provider operation's display properties. :param publisher: Operation description. @@ -1191,7 +1355,10 @@ class ResourceProviderOperationDisplayProperties(Model): 'description': {'key': 'description', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ResourceProviderOperationDisplayProperties, self).__init__(**kwargs) self.publisher = kwargs.get('publisher', None) self.provider = kwargs.get('provider', None) @@ -1200,7 +1367,7 @@ def __init__(self, **kwargs): self.description = kwargs.get('description', None) -class ResourcesMoveInfo(Model): +class ResourcesMoveInfo(msrest.serialization.Model): """Parameters of move resources. :param resources: The IDs of the resources. @@ -1214,13 +1381,16 @@ class ResourcesMoveInfo(Model): 'target_resource_group': {'key': 'targetResourceGroup', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ResourcesMoveInfo, self).__init__(**kwargs) self.resources = kwargs.get('resources', None) self.target_resource_group = kwargs.get('target_resource_group', None) -class Sku(Model): +class Sku(msrest.serialization.Model): """SKU for the resource. :param name: The SKU name. @@ -1246,7 +1416,10 @@ class Sku(Model): 'capacity': {'key': 'capacity', 'type': 'int'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Sku, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.tier = kwargs.get('tier', None) @@ -1256,10 +1429,10 @@ def __init__(self, **kwargs): self.capacity = kwargs.get('capacity', None) -class SubResource(Model): +class SubResource(msrest.serialization.Model): """Sub-resource. - :param id: Resource ID + :param id: Resource ID. :type id: str """ @@ -1267,12 +1440,15 @@ class SubResource(Model): 'id': {'key': 'id', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(SubResource, self).__init__(**kwargs) self.id = kwargs.get('id', None) -class TagCount(Model): +class TagCount(msrest.serialization.Model): """Tag count. :param type: Type of count. @@ -1286,29 +1462,29 @@ class TagCount(Model): 'value': {'key': 'value', 'type': 'int'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(TagCount, self).__init__(**kwargs) self.type = kwargs.get('type', None) self.value = kwargs.get('value', None) -class TagDetails(Model): +class TagDetails(msrest.serialization.Model): """Tag details. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :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 created and has no associated resources, the value - is 0. + :param 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] + :type values: list[~azure.mgmt.resource.resources.v2017_05_10.models.TagValue] """ _validation = { @@ -1322,7 +1498,10 @@ class TagDetails(Model): 'values': {'key': 'values', 'type': '[TagValue]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(TagDetails, self).__init__(**kwargs) self.id = None self.tag_name = kwargs.get('tag_name', None) @@ -1330,11 +1509,39 @@ def __init__(self, **kwargs): self.values = kwargs.get('values', None) -class TagValue(Model): +class TagsListResult(msrest.serialization.Model): + """List of subscription tags. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[TagDetails]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(TagsListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = None + + +class TagValue(msrest.serialization.Model): """Tag information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The tag ID. :vartype id: str @@ -1354,14 +1561,17 @@ class TagValue(Model): 'count': {'key': 'count', 'type': 'TagCount'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(TagValue, self).__init__(**kwargs) self.id = None self.tag_value = kwargs.get('tag_value', None) self.count = kwargs.get('count', None) -class TargetResource(Model): +class TargetResource(msrest.serialization.Model): """Target resource. :param id: The ID of the resource. @@ -1378,16 +1588,18 @@ class TargetResource(Model): 'resource_type': {'key': 'resourceType', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(TargetResource, self).__init__(**kwargs) self.id = kwargs.get('id', None) self.resource_name = kwargs.get('resource_name', None) self.resource_type = kwargs.get('resource_type', None) -class TemplateHashResult(Model): - """Result of the request to calculate template hash. It contains a string of - minified template and its hash. +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 @@ -1400,21 +1612,23 @@ class TemplateHashResult(Model): 'template_hash': {'key': 'templateHash', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(TemplateHashResult, self).__init__(**kwargs) self.minified_template = kwargs.get('minified_template', None) self.template_hash = kwargs.get('template_hash', None) -class TemplateLink(Model): +class TemplateLink(msrest.serialization.Model): """Entity representing the reference to the template. 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. + :param content_version: If included, must match the ContentVersion in the template. :type content_version: str """ @@ -1427,7 +1641,10 @@ class TemplateLink(Model): 'content_version': {'key': 'contentVersion', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(TemplateLink, self).__init__(**kwargs) - self.uri = kwargs.get('uri', None) + self.uri = kwargs['uri'] self.content_version = kwargs.get('content_version', 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 e453236fb488..2358ee3e1221 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 @@ -1,20 +1,20 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.serialization import Model -from msrest.exceptions import HttpOperationError +from typing import Dict, List, Optional, Union +import msrest.serialization -class AliasPathType(Model): - """The type of the paths for alias. . +from ._resource_management_client_enums import * + + +class AliasPathType(msrest.serialization.Model): + """The type of the paths for alias. :param path: The path of an alias. :type path: str @@ -27,20 +27,25 @@ class AliasPathType(Model): 'api_versions': {'key': 'apiVersions', 'type': '[str]'}, } - def __init__(self, *, path: str=None, api_versions=None, **kwargs) -> None: + def __init__( + self, + *, + path: Optional[str] = None, + api_versions: Optional[List[str]] = None, + **kwargs + ): super(AliasPathType, self).__init__(**kwargs) self.path = path self.api_versions = api_versions -class AliasType(Model): - """The alias type. . +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] + :type paths: list[~azure.mgmt.resource.resources.v2017_05_10.models.AliasPathType] """ _attribute_map = { @@ -48,13 +53,19 @@ class AliasType(Model): 'paths': {'key': 'paths', 'type': '[AliasPathType]'}, } - def __init__(self, *, name: str=None, paths=None, **kwargs) -> None: + def __init__( + self, + *, + name: Optional[str] = None, + paths: Optional[List["AliasPathType"]] = None, + **kwargs + ): super(AliasType, self).__init__(**kwargs) self.name = name self.paths = paths -class BasicDependency(Model): +class BasicDependency(msrest.serialization.Model): """Deployment dependency information. :param id: The ID of the dependency. @@ -71,52 +82,29 @@ class BasicDependency(Model): 'resource_name': {'key': 'resourceName', 'type': 'str'}, } - def __init__(self, *, id: str=None, resource_type: str=None, resource_name: str=None, **kwargs) -> None: + def __init__( + self, + *, + id: Optional[str] = None, + resource_type: Optional[str] = None, + resource_name: Optional[str] = None, + **kwargs + ): super(BasicDependency, self).__init__(**kwargs) self.id = id self.resource_type = resource_type self.resource_name = resource_name -class CloudError(Model): - """An error response for a resource management request. - - :param error: - :type error: - ~azure.mgmt.resource.resources.v2017_05_10.models.ErrorResponse - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorResponse'}, - } - - def __init__(self, *, error=None, **kwargs) -> None: - super(CloudError, self).__init__(**kwargs) - self.error = error - - -class CloudErrorException(HttpOperationError): - """Server responsed with exception of type: 'CloudError'. - - :param deserialize: A deserializer - :param response: Server response to be deserialized. - """ - - def __init__(self, deserialize, response, *args): - - super(CloudErrorException, self).__init__(deserialize, response, 'CloudError', *args) - - -class DebugSetting(Model): +class DebugSetting(msrest.serialization.Model): """DebugSetting. - :param 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. + :param 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 """ @@ -124,17 +112,21 @@ class DebugSetting(Model): 'detail_level': {'key': 'detailLevel', 'type': 'str'}, } - def __init__(self, *, detail_level: str=None, **kwargs) -> None: + def __init__( + self, + *, + detail_level: Optional[str] = None, + **kwargs + ): super(DebugSetting, self).__init__(**kwargs) self.detail_level = detail_level -class Dependency(Model): +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] + :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. @@ -150,7 +142,15 @@ class Dependency(Model): 'resource_name': {'key': 'resourceName', 'type': 'str'}, } - def __init__(self, *, depends_on=None, id: str=None, resource_type: str=None, resource_name: str=None, **kwargs) -> None: + def __init__( + self, + *, + depends_on: Optional[List["BasicDependency"]] = None, + id: Optional[str] = None, + resource_type: Optional[str] = None, + resource_name: Optional[str] = None, + **kwargs + ): super(Dependency, self).__init__(**kwargs) self.depends_on = depends_on self.id = id @@ -158,14 +158,13 @@ def __init__(self, *, depends_on=None, id: str=None, resource_type: str=None, re self.resource_name = resource_name -class Deployment(Model): +class Deployment(msrest.serialization.Model): """Deployment operation parameters. 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 + :type properties: ~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentProperties """ _validation = { @@ -176,13 +175,18 @@ class Deployment(Model): 'properties': {'key': 'properties', 'type': 'DeploymentProperties'}, } - def __init__(self, *, properties, **kwargs) -> None: + def __init__( + self, + *, + properties: "DeploymentProperties", + **kwargs + ): super(Deployment, self).__init__(**kwargs) self.properties = properties -class DeploymentExportResult(Model): - """The deployment export result. . +class DeploymentExportResult(msrest.serialization.Model): + """The deployment export result. :param template: The template content. :type template: object @@ -192,16 +196,20 @@ class DeploymentExportResult(Model): 'template': {'key': 'template', 'type': 'object'}, } - def __init__(self, *, template=None, **kwargs) -> None: + def __init__( + self, + *, + template: Optional[object] = None, + **kwargs + ): super(DeploymentExportResult, self).__init__(**kwargs) self.template = template -class DeploymentExtended(Model): +class DeploymentExtended(msrest.serialization.Model): """Deployment information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. @@ -225,14 +233,20 @@ class DeploymentExtended(Model): 'properties': {'key': 'properties', 'type': 'DeploymentPropertiesExtended'}, } - def __init__(self, *, name: str, properties=None, **kwargs) -> None: + def __init__( + self, + *, + name: str, + properties: Optional["DeploymentPropertiesExtended"] = None, + **kwargs + ): super(DeploymentExtended, self).__init__(**kwargs) self.id = None self.name = name self.properties = properties -class DeploymentExtendedFilter(Model): +class DeploymentExtendedFilter(msrest.serialization.Model): """Deployment filter. :param provisioning_state: The provisioning state. @@ -243,16 +257,51 @@ class DeploymentExtendedFilter(Model): 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, } - def __init__(self, *, provisioning_state: str=None, **kwargs) -> None: + def __init__( + self, + *, + provisioning_state: Optional[str] = None, + **kwargs + ): super(DeploymentExtendedFilter, self).__init__(**kwargs) self.provisioning_state = provisioning_state -class DeploymentOperation(Model): +class DeploymentListResult(msrest.serialization.Model): + """List of deployments. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[DeploymentExtended]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["DeploymentExtended"]] = None, + **kwargs + ): + super(DeploymentListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class DeploymentOperation(msrest.serialization.Model): """Deployment operation information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Full deployment operation ID. :vartype id: str @@ -274,23 +323,27 @@ class DeploymentOperation(Model): 'properties': {'key': 'properties', 'type': 'DeploymentOperationProperties'}, } - def __init__(self, *, properties=None, **kwargs) -> None: + def __init__( + self, + *, + properties: Optional["DeploymentOperationProperties"] = None, + **kwargs + ): super(DeploymentOperation, self).__init__(**kwargs) self.id = None self.operation_id = None self.properties = properties -class DeploymentOperationProperties(Model): +class DeploymentOperationProperties(msrest.serialization.Model): """Deployment operation properties. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar provisioning_state: The state of the provisioning. :vartype provisioning_state: str :ivar timestamp: The date and time of the operation. - :vartype timestamp: datetime + :vartype timestamp: ~datetime.datetime :ivar service_request_id: Deployment operation service request id. :vartype service_request_id: str :ivar status_code: Operation status code. @@ -298,14 +351,11 @@ class DeploymentOperationProperties(Model): :ivar status_message: Operation status message. :vartype status_message: object :ivar target_resource: The target resource. - :vartype target_resource: - ~azure.mgmt.resource.resources.v2017_05_10.models.TargetResource + :vartype target_resource: ~azure.mgmt.resource.resources.v2017_05_10.models.TargetResource :ivar request: The HTTP request message. - :vartype request: - ~azure.mgmt.resource.resources.v2017_05_10.models.HttpMessage + :vartype request: ~azure.mgmt.resource.resources.v2017_05_10.models.HttpMessage :ivar response: The HTTP response message. - :vartype response: - ~azure.mgmt.resource.resources.v2017_05_10.models.HttpMessage + :vartype response: ~azure.mgmt.resource.resources.v2017_05_10.models.HttpMessage """ _validation = { @@ -330,7 +380,10 @@ class DeploymentOperationProperties(Model): 'response': {'key': 'response', 'type': 'HttpMessage'}, } - def __init__(self, **kwargs) -> None: + def __init__( + self, + **kwargs + ): super(DeploymentOperationProperties, self).__init__(**kwargs) self.provisioning_state = None self.timestamp = None @@ -342,45 +395,68 @@ def __init__(self, **kwargs) -> None: self.response = None -class DeploymentProperties(Model): +class DeploymentOperationsListResult(msrest.serialization.Model): + """List of deployment operations. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[DeploymentOperation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["DeploymentOperation"]] = None, + **kwargs + ): + super(DeploymentOperationsListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class DeploymentProperties(msrest.serialization.Model): """Deployment properties. 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 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. + :param 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: object - :param 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. 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. + :param 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. + 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: object - :param 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 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 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 + 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 + :type debug_setting: ~azure.mgmt.resource.resources.v2017_05_10.models.DebugSetting """ _validation = { @@ -392,11 +468,21 @@ class DeploymentProperties(Model): 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, 'parameters': {'key': 'parameters', 'type': 'object'}, 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, - 'mode': {'key': 'mode', 'type': 'DeploymentMode'}, + 'mode': {'key': 'mode', 'type': 'str'}, 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, } - def __init__(self, *, mode, template=None, template_link=None, parameters=None, parameters_link=None, debug_setting=None, **kwargs) -> None: + def __init__( + self, + *, + mode: Union[str, "DeploymentMode"], + template: Optional[object] = None, + template_link: Optional["TemplateLink"] = None, + parameters: Optional[object] = None, + parameters_link: Optional["ParametersLink"] = None, + debug_setting: Optional["DebugSetting"] = None, + **kwargs + ): super(DeploymentProperties, self).__init__(**kwargs) self.template = template self.template_link = template_link @@ -406,48 +492,38 @@ def __init__(self, *, mode, template=None, template_link=None, parameters=None, self.debug_setting = debug_setting -class DeploymentPropertiesExtended(Model): +class DeploymentPropertiesExtended(msrest.serialization.Model): """Deployment properties with additional details. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :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 + :vartype timestamp: ~datetime.datetime :param outputs: Key/value pairs that represent deployment output. :type outputs: object - :param providers: The list of resource providers needed for the - deployment. - :type providers: - list[~azure.mgmt.resource.resources.v2017_05_10.models.Provider] + :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 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: object - :param 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. + :param 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: object - :param 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 include: 'Incremental', 'Complete' - :type mode: str or - ~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentMode + :param 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 + 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 + :type debug_setting: ~azure.mgmt.resource.resources.v2017_05_10.models.DebugSetting """ _validation = { @@ -467,11 +543,24 @@ class DeploymentPropertiesExtended(Model): 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, 'parameters': {'key': 'parameters', 'type': 'object'}, 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, - 'mode': {'key': 'mode', 'type': 'DeploymentMode'}, + 'mode': {'key': 'mode', 'type': 'str'}, 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, } - def __init__(self, *, outputs=None, providers=None, dependencies=None, template=None, template_link=None, parameters=None, parameters_link=None, mode=None, debug_setting=None, **kwargs) -> None: + def __init__( + self, + *, + outputs: Optional[object] = None, + providers: Optional[List["Provider"]] = None, + dependencies: Optional[List["Dependency"]] = None, + template: Optional[object] = None, + template_link: Optional["TemplateLink"] = None, + parameters: Optional[object] = None, + parameters_link: Optional["ParametersLink"] = None, + mode: Optional[Union[str, "DeploymentMode"]] = None, + debug_setting: Optional["DebugSetting"] = None, + **kwargs + ): super(DeploymentPropertiesExtended, self).__init__(**kwargs) self.provisioning_state = None self.correlation_id = None @@ -487,7 +576,7 @@ def __init__(self, *, outputs=None, providers=None, dependencies=None, template= self.debug_setting = debug_setting -class DeploymentValidateResult(Model): +class DeploymentValidateResult(msrest.serialization.Model): """Information from validate template deployment response. :param error: Validation error. @@ -503,17 +592,22 @@ class DeploymentValidateResult(Model): 'properties': {'key': 'properties', 'type': 'DeploymentPropertiesExtended'}, } - def __init__(self, *, error=None, properties=None, **kwargs) -> None: + def __init__( + self, + *, + error: Optional["ResourceManagementErrorWithDetails"] = None, + properties: Optional["DeploymentPropertiesExtended"] = None, + **kwargs + ): super(DeploymentValidateResult, self).__init__(**kwargs) self.error = error self.properties = properties -class ErrorAdditionalInfo(Model): +class ErrorAdditionalInfo(msrest.serialization.Model): """The resource management error additional info. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar type: The additional info type. :vartype type: str @@ -531,17 +625,19 @@ class ErrorAdditionalInfo(Model): 'info': {'key': 'info', 'type': 'object'}, } - def __init__(self, **kwargs) -> None: + def __init__( + self, + **kwargs + ): super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None -class ErrorResponse(Model): +class ErrorResponse(msrest.serialization.Model): """The resource management error response. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar code: The error code. :vartype code: str @@ -550,8 +646,7 @@ class ErrorResponse(Model): :ivar target: The error target. :vartype target: str :ivar details: The error details. - :vartype details: - list[~azure.mgmt.resource.resources.v2017_05_10.models.ErrorResponse] + :vartype details: list[~azure.mgmt.resource.resources.v2017_05_10.models.ErrorResponse] :ivar additional_info: The error additional info. :vartype additional_info: list[~azure.mgmt.resource.resources.v2017_05_10.models.ErrorAdditionalInfo] @@ -573,7 +668,10 @@ class ErrorResponse(Model): 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, } - def __init__(self, **kwargs) -> None: + def __init__( + self, + **kwargs + ): super(ErrorResponse, self).__init__(**kwargs) self.code = None self.message = None @@ -582,16 +680,15 @@ def __init__(self, **kwargs) -> None: self.additional_info = None -class ExportTemplateRequest(Model): +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, supply an array with single entry '*'. + :param 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', 'SkipResourceNameParameterization', - 'SkipAllParameterization' + :param options: The export template options. A CSV-formatted list containing zero or more of + the following: 'IncludeParameterDefaultValue', 'IncludeComments', + 'SkipResourceNameParameterization', 'SkipAllParameterization'. :type options: str """ @@ -600,27 +697,32 @@ class ExportTemplateRequest(Model): 'options': {'key': 'options', 'type': 'str'}, } - def __init__(self, *, resources=None, options: str=None, **kwargs) -> None: + def __init__( + self, + *, + resources: Optional[List[str]] = None, + options: Optional[str] = None, + **kwargs + ): super(ExportTemplateRequest, self).__init__(**kwargs) self.resources = resources self.options = options -class Resource(Model): +class Resource(msrest.serialization.Model): """Basic set of the resource properties. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID + :ivar id: Resource ID. :vartype id: str - :ivar name: Resource name + :ivar name: Resource name. :vartype name: str - :ivar type: Resource type + :ivar type: Resource type. :vartype type: str - :param location: Resource location + :param location: Resource location. :type location: str - :param tags: Resource tags + :param tags: A set of tags. Resource tags. :type tags: dict[str, str] """ @@ -638,7 +740,13 @@ class Resource(Model): 'tags': {'key': 'tags', 'type': '{str}'}, } - def __init__(self, *, location: str=None, tags=None, **kwargs) -> None: + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -650,18 +758,17 @@ def __init__(self, *, location: str=None, tags=None, **kwargs) -> None: class GenericResource(Resource): """Resource information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID + :ivar id: Resource ID. :vartype id: str - :ivar name: Resource name + :ivar name: Resource name. :vartype name: str - :ivar type: Resource type + :ivar type: Resource type. :vartype type: str - :param location: Resource location + :param location: Resource location. :type location: str - :param tags: Resource tags + :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 @@ -698,7 +805,19 @@ class GenericResource(Resource): 'identity': {'key': 'identity', 'type': 'Identity'}, } - def __init__(self, *, location: str=None, tags=None, plan=None, properties=None, kind: str=None, managed_by: str=None, sku=None, identity=None, **kwargs) -> None: + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + plan: Optional["Plan"] = None, + properties: Optional[object] = None, + kind: Optional[str] = None, + managed_by: Optional[str] = None, + sku: Optional["Sku"] = None, + identity: Optional["Identity"] = None, + **kwargs + ): super(GenericResource, self).__init__(location=location, tags=tags, **kwargs) self.plan = plan self.properties = properties @@ -711,18 +830,17 @@ def __init__(self, *, location: str=None, tags=None, plan=None, properties=None, class GenericResourceExpanded(GenericResource): """Resource information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID + :ivar id: Resource ID. :vartype id: str - :ivar name: Resource name + :ivar name: Resource name. :vartype name: str - :ivar type: Resource type + :ivar type: Resource type. :vartype type: str - :param location: Resource location + :param location: Resource location. :type location: str - :param tags: Resource tags + :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 @@ -736,14 +854,14 @@ class GenericResourceExpanded(GenericResource): :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 created_time: The created time of the resource. This is only present - if requested via the $expand query parameter. - :vartype created_time: datetime - :ivar changed_time: The changed time of the resource. This is only present - if requested via the $expand query parameter. - :vartype changed_time: datetime - :ivar provisioning_state: The provisioning state of the resource. This is - only present if requested via the $expand query parameter. + :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 + :ivar changed_time: The changed time of the resource. This is only present if requested via the + $expand query parameter. + :vartype changed_time: ~datetime.datetime + :ivar provisioning_state: The provisioning state of the resource. This is only present if + requested via the $expand query parameter. :vartype provisioning_state: str """ @@ -774,14 +892,26 @@ class GenericResourceExpanded(GenericResource): 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, } - def __init__(self, *, location: str=None, tags=None, plan=None, properties=None, kind: str=None, managed_by: str=None, sku=None, identity=None, **kwargs) -> None: + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + plan: Optional["Plan"] = None, + properties: Optional[object] = None, + kind: Optional[str] = None, + managed_by: Optional[str] = None, + sku: Optional["Sku"] = None, + identity: Optional["Identity"] = None, + **kwargs + ): 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 self.provisioning_state = None -class GenericResourceFilter(Model): +class GenericResourceFilter(msrest.serialization.Model): """Resource filter. :param resource_type: The resource type. @@ -798,14 +928,21 @@ class GenericResourceFilter(Model): 'tagvalue': {'key': 'tagvalue', 'type': 'str'}, } - def __init__(self, *, resource_type: str=None, tagname: str=None, tagvalue: str=None, **kwargs) -> None: + def __init__( + self, + *, + resource_type: Optional[str] = None, + tagname: Optional[str] = None, + tagvalue: Optional[str] = None, + **kwargs + ): super(GenericResourceFilter, self).__init__(**kwargs) self.resource_type = resource_type self.tagname = tagname self.tagvalue = tagvalue -class HttpMessage(Model): +class HttpMessage(msrest.serialization.Model): """HTTP message. :param content: HTTP message content. @@ -816,53 +953,60 @@ class HttpMessage(Model): 'content': {'key': 'content', 'type': 'object'}, } - def __init__(self, *, content=None, **kwargs) -> None: + def __init__( + self, + *, + content: Optional[object] = None, + **kwargs + ): super(HttpMessage, self).__init__(**kwargs) self.content = content -class Identity(Model): +class Identity(msrest.serialization.Model): """Identity for the resource. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar principal_id: The principal ID of resource identity. :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :param type: The identity type. Possible values include: 'SystemAssigned' - :type type: str or - ~azure.mgmt.resource.resources.v2017_05_10.models.ResourceIdentityType + :ivar type: The identity type. Default value: "SystemAssigned". + :vartype type: str """ _validation = { 'principal_id': {'readonly': True}, 'tenant_id': {'readonly': True}, + 'type': {'constant': True}, } _attribute_map = { 'principal_id': {'key': 'principalId', 'type': 'str'}, 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'ResourceIdentityType'}, + 'type': {'key': 'type', 'type': 'str'}, } - def __init__(self, *, type=None, **kwargs) -> None: + type = "SystemAssigned" + + def __init__( + self, + **kwargs + ): super(Identity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None - self.type = type -class ParametersLink(Model): +class ParametersLink(msrest.serialization.Model): """Entity representing the reference to the deployment parameters. 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. + :param content_version: If included, must match the ContentVersion in the template. :type content_version: str """ @@ -875,13 +1019,19 @@ class ParametersLink(Model): 'content_version': {'key': 'contentVersion', 'type': 'str'}, } - def __init__(self, *, uri: str, content_version: str=None, **kwargs) -> None: + def __init__( + self, + *, + uri: str, + content_version: Optional[str] = None, + **kwargs + ): super(ParametersLink, self).__init__(**kwargs) self.uri = uri self.content_version = content_version -class Plan(Model): +class Plan(msrest.serialization.Model): """Plan for the resource. :param name: The plan ID. @@ -904,7 +1054,16 @@ class Plan(Model): 'version': {'key': 'version', 'type': 'str'}, } - def __init__(self, *, name: str=None, publisher: str=None, product: str=None, promotion_code: str=None, version: str=None, **kwargs) -> None: + def __init__( + self, + *, + name: Optional[str] = None, + publisher: Optional[str] = None, + product: Optional[str] = None, + promotion_code: Optional[str] = None, + version: Optional[str] = None, + **kwargs + ): super(Plan, self).__init__(**kwargs) self.name = name self.publisher = publisher @@ -913,11 +1072,10 @@ def __init__(self, *, name: str=None, publisher: str=None, product: str=None, pr self.version = version -class Provider(Model): +class Provider(msrest.serialization.Model): """Resource provider information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The provider ID. :vartype id: str @@ -943,7 +1101,12 @@ class Provider(Model): 'resource_types': {'key': 'resourceTypes', 'type': '[ProviderResourceType]'}, } - def __init__(self, *, namespace: str=None, **kwargs) -> None: + def __init__( + self, + *, + namespace: Optional[str] = None, + **kwargs + ): super(Provider, self).__init__(**kwargs) self.id = None self.namespace = namespace @@ -951,17 +1114,46 @@ def __init__(self, *, namespace: str=None, **kwargs) -> None: self.resource_types = None -class ProviderResourceType(Model): +class ProviderListResult(msrest.serialization.Model): + """List of resource providers. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Provider]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["Provider"]] = None, + **kwargs + ): + super(ProviderListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +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. + :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] + :type aliases: list[~azure.mgmt.resource.resources.v2017_05_10.models.AliasType] :param api_versions: The API version. :type api_versions: list[str] :param properties: The properties. @@ -976,7 +1168,16 @@ class ProviderResourceType(Model): 'properties': {'key': 'properties', 'type': '{str}'}, } - def __init__(self, *, resource_type: str=None, locations=None, aliases=None, api_versions=None, properties=None, **kwargs) -> None: + def __init__( + self, + *, + resource_type: Optional[str] = None, + locations: Optional[List[str]] = None, + aliases: Optional[List["AliasType"]] = None, + api_versions: Optional[List[str]] = None, + properties: Optional[Dict[str, str]] = None, + **kwargs + ): super(ProviderResourceType, self).__init__(**kwargs) self.resource_type = resource_type self.locations = locations @@ -985,11 +1186,10 @@ def __init__(self, *, resource_type: str=None, locations=None, aliases=None, api self.properties = properties -class ResourceGroup(Model): +class ResourceGroup(msrest.serialization.Model): """Resource group information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. @@ -997,17 +1197,14 @@ class ResourceGroup(Model): :vartype id: str :param name: The name of the resource group. :type name: str - :param 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 resource group has been created. It must be one of - the supported Azure locations. + :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 + 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. + :param managed_by: The ID of the resource that manages this resource group. :type managed_by: str - :param tags: The tags attached to the resource group. + :param tags: A set of tags. The tags attached to the resource group. :type tags: dict[str, str] """ @@ -1025,7 +1222,16 @@ class ResourceGroup(Model): 'tags': {'key': 'tags', 'type': '{str}'}, } - def __init__(self, *, location: str, name: str=None, properties=None, managed_by: str=None, tags=None, **kwargs) -> None: + def __init__( + self, + *, + location: str, + name: Optional[str] = None, + properties: Optional["ResourceGroupProperties"] = None, + managed_by: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): super(ResourceGroup, self).__init__(**kwargs) self.id = None self.name = name @@ -1035,7 +1241,7 @@ def __init__(self, *, location: str, name: str=None, properties=None, managed_by self.tags = tags -class ResourceGroupExportResult(Model): +class ResourceGroupExportResult(msrest.serialization.Model): """Resource group export result. :param template: The template content. @@ -1050,13 +1256,19 @@ class ResourceGroupExportResult(Model): 'error': {'key': 'error', 'type': 'ResourceManagementErrorWithDetails'}, } - def __init__(self, *, template=None, error=None, **kwargs) -> None: + def __init__( + self, + *, + template: Optional[object] = None, + error: Optional["ResourceManagementErrorWithDetails"] = None, + **kwargs + ): super(ResourceGroupExportResult, self).__init__(**kwargs) self.template = template self.error = error -class ResourceGroupFilter(Model): +class ResourceGroupFilter(msrest.serialization.Model): """Resource group filter. :param tag_name: The tag name. @@ -1070,24 +1282,59 @@ class ResourceGroupFilter(Model): 'tag_value': {'key': 'tagValue', 'type': 'str'}, } - def __init__(self, *, tag_name: str=None, tag_value: str=None, **kwargs) -> None: + def __init__( + self, + *, + tag_name: Optional[str] = None, + tag_value: Optional[str] = None, + **kwargs + ): super(ResourceGroupFilter, self).__init__(**kwargs) self.tag_name = tag_name self.tag_value = tag_value -class ResourceGroupPatchable(Model): +class ResourceGroupListResult(msrest.serialization.Model): + """List of resource groups. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ResourceGroup]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["ResourceGroup"]] = None, + **kwargs + ): + super(ResourceGroupListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class ResourceGroupPatchable(msrest.serialization.Model): """Resource group information. :param name: The name of the resource group. :type name: str - :param 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. + :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: The tags attached to the resource group. + :param tags: A set of tags. The tags attached to the resource group. :type tags: dict[str, str] """ @@ -1098,7 +1345,15 @@ class ResourceGroupPatchable(Model): 'tags': {'key': 'tags', 'type': '{str}'}, } - def __init__(self, *, name: str=None, properties=None, managed_by: str=None, tags=None, **kwargs) -> None: + def __init__( + self, + *, + name: Optional[str] = None, + properties: Optional["ResourceGroupProperties"] = None, + managed_by: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): super(ResourceGroupPatchable, self).__init__(**kwargs) self.name = name self.properties = properties @@ -1106,11 +1361,10 @@ def __init__(self, *, name: str=None, properties=None, managed_by: str=None, tag self.tags = tags -class ResourceGroupProperties(Model): +class ResourceGroupProperties(msrest.serialization.Model): """The resource group properties. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar provisioning_state: The provisioning state. :vartype provisioning_state: str @@ -1124,16 +1378,49 @@ class ResourceGroupProperties(Model): 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, } - def __init__(self, **kwargs) -> None: + def __init__( + self, + **kwargs + ): super(ResourceGroupProperties, self).__init__(**kwargs) self.provisioning_state = None -class ResourceManagementErrorWithDetails(Model): +class ResourceListResult(msrest.serialization.Model): + """List of resource groups. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[GenericResourceExpanded]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["GenericResourceExpanded"]] = None, + **kwargs + ): + super(ResourceListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class ResourceManagementErrorWithDetails(msrest.serialization.Model): """The detailed error message of resource management. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar code: The error code returned when exporting the template. :vartype code: str @@ -1160,7 +1447,10 @@ class ResourceManagementErrorWithDetails(Model): 'details': {'key': 'details', 'type': '[ResourceManagementErrorWithDetails]'}, } - def __init__(self, **kwargs) -> None: + def __init__( + self, + **kwargs + ): super(ResourceManagementErrorWithDetails, self).__init__(**kwargs) self.code = None self.message = None @@ -1168,7 +1458,7 @@ def __init__(self, **kwargs) -> None: self.details = None -class ResourceProviderOperationDisplayProperties(Model): +class ResourceProviderOperationDisplayProperties(msrest.serialization.Model): """Resource provider operation's display properties. :param publisher: Operation description. @@ -1191,7 +1481,16 @@ class ResourceProviderOperationDisplayProperties(Model): 'description': {'key': 'description', 'type': 'str'}, } - def __init__(self, *, publisher: str=None, provider: str=None, resource: str=None, operation: str=None, description: str=None, **kwargs) -> None: + def __init__( + self, + *, + publisher: Optional[str] = None, + provider: Optional[str] = None, + resource: Optional[str] = None, + operation: Optional[str] = None, + description: Optional[str] = None, + **kwargs + ): super(ResourceProviderOperationDisplayProperties, self).__init__(**kwargs) self.publisher = publisher self.provider = provider @@ -1200,7 +1499,7 @@ def __init__(self, *, publisher: str=None, provider: str=None, resource: str=Non self.description = description -class ResourcesMoveInfo(Model): +class ResourcesMoveInfo(msrest.serialization.Model): """Parameters of move resources. :param resources: The IDs of the resources. @@ -1214,13 +1513,19 @@ class ResourcesMoveInfo(Model): 'target_resource_group': {'key': 'targetResourceGroup', 'type': 'str'}, } - def __init__(self, *, resources=None, target_resource_group: str=None, **kwargs) -> None: + def __init__( + self, + *, + resources: Optional[List[str]] = None, + target_resource_group: Optional[str] = None, + **kwargs + ): super(ResourcesMoveInfo, self).__init__(**kwargs) self.resources = resources self.target_resource_group = target_resource_group -class Sku(Model): +class Sku(msrest.serialization.Model): """SKU for the resource. :param name: The SKU name. @@ -1246,7 +1551,17 @@ class Sku(Model): 'capacity': {'key': 'capacity', 'type': 'int'}, } - def __init__(self, *, name: str=None, tier: str=None, size: str=None, family: str=None, model: str=None, capacity: int=None, **kwargs) -> None: + def __init__( + self, + *, + name: Optional[str] = None, + tier: Optional[str] = None, + size: Optional[str] = None, + family: Optional[str] = None, + model: Optional[str] = None, + capacity: Optional[int] = None, + **kwargs + ): super(Sku, self).__init__(**kwargs) self.name = name self.tier = tier @@ -1256,10 +1571,10 @@ def __init__(self, *, name: str=None, tier: str=None, size: str=None, family: st self.capacity = capacity -class SubResource(Model): +class SubResource(msrest.serialization.Model): """Sub-resource. - :param id: Resource ID + :param id: Resource ID. :type id: str """ @@ -1267,12 +1582,17 @@ class SubResource(Model): 'id': {'key': 'id', 'type': 'str'}, } - def __init__(self, *, id: str=None, **kwargs) -> None: + def __init__( + self, + *, + id: Optional[str] = None, + **kwargs + ): super(SubResource, self).__init__(**kwargs) self.id = id -class TagCount(Model): +class TagCount(msrest.serialization.Model): """Tag count. :param type: Type of count. @@ -1286,29 +1606,32 @@ class TagCount(Model): 'value': {'key': 'value', 'type': 'int'}, } - def __init__(self, *, type: str=None, value: int=None, **kwargs) -> None: + def __init__( + self, + *, + type: Optional[str] = None, + value: Optional[int] = None, + **kwargs + ): super(TagCount, self).__init__(**kwargs) self.type = type self.value = value -class TagDetails(Model): +class TagDetails(msrest.serialization.Model): """Tag details. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :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 created and has no associated resources, the value - is 0. + :param 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] + :type values: list[~azure.mgmt.resource.resources.v2017_05_10.models.TagValue] """ _validation = { @@ -1322,7 +1645,14 @@ class TagDetails(Model): 'values': {'key': 'values', 'type': '[TagValue]'}, } - def __init__(self, *, tag_name: str=None, count=None, values=None, **kwargs) -> None: + def __init__( + self, + *, + tag_name: Optional[str] = None, + count: Optional["TagCount"] = None, + values: Optional[List["TagValue"]] = None, + **kwargs + ): super(TagDetails, self).__init__(**kwargs) self.id = None self.tag_name = tag_name @@ -1330,11 +1660,41 @@ def __init__(self, *, tag_name: str=None, count=None, values=None, **kwargs) -> self.values = values -class TagValue(Model): +class TagsListResult(msrest.serialization.Model): + """List of subscription tags. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[TagDetails]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["TagDetails"]] = None, + **kwargs + ): + super(TagsListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class TagValue(msrest.serialization.Model): """Tag information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The tag ID. :vartype id: str @@ -1354,14 +1714,20 @@ class TagValue(Model): 'count': {'key': 'count', 'type': 'TagCount'}, } - def __init__(self, *, tag_value: str=None, count=None, **kwargs) -> None: + def __init__( + self, + *, + tag_value: Optional[str] = None, + count: Optional["TagCount"] = None, + **kwargs + ): super(TagValue, self).__init__(**kwargs) self.id = None self.tag_value = tag_value self.count = count -class TargetResource(Model): +class TargetResource(msrest.serialization.Model): """Target resource. :param id: The ID of the resource. @@ -1378,16 +1744,22 @@ class TargetResource(Model): 'resource_type': {'key': 'resourceType', 'type': 'str'}, } - def __init__(self, *, id: str=None, resource_name: str=None, resource_type: str=None, **kwargs) -> None: + def __init__( + self, + *, + id: Optional[str] = None, + resource_name: Optional[str] = None, + resource_type: Optional[str] = None, + **kwargs + ): super(TargetResource, self).__init__(**kwargs) self.id = id self.resource_name = resource_name self.resource_type = resource_type -class TemplateHashResult(Model): - """Result of the request to calculate template hash. It contains a string of - minified template and its hash. +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 @@ -1400,21 +1772,26 @@ class TemplateHashResult(Model): 'template_hash': {'key': 'templateHash', 'type': 'str'}, } - def __init__(self, *, minified_template: str=None, template_hash: str=None, **kwargs) -> None: + def __init__( + self, + *, + minified_template: Optional[str] = None, + template_hash: Optional[str] = None, + **kwargs + ): super(TemplateHashResult, self).__init__(**kwargs) self.minified_template = minified_template self.template_hash = template_hash -class TemplateLink(Model): +class TemplateLink(msrest.serialization.Model): """Entity representing the reference to the template. 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. + :param content_version: If included, must match the ContentVersion in the template. :type content_version: str """ @@ -1427,7 +1804,13 @@ class TemplateLink(Model): 'content_version': {'key': 'contentVersion', 'type': 'str'}, } - def __init__(self, *, uri: str, content_version: str=None, **kwargs) -> None: + def __init__( + self, + *, + uri: str, + content_version: Optional[str] = None, + **kwargs + ): 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/v2017_05_10/models/_paged_models.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/models/_paged_models.py deleted file mode 100644 index 8380256e9902..000000000000 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/models/_paged_models.py +++ /dev/null @@ -1,92 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.paging import Paged - - -class DeploymentExtendedPaged(Paged): - """ - A paging container for iterating over a list of :class:`DeploymentExtended ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[DeploymentExtended]'} - } - - def __init__(self, *args, **kwargs): - - super(DeploymentExtendedPaged, self).__init__(*args, **kwargs) -class ProviderPaged(Paged): - """ - A paging container for iterating over a list of :class:`Provider ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[Provider]'} - } - - def __init__(self, *args, **kwargs): - - super(ProviderPaged, self).__init__(*args, **kwargs) -class GenericResourceExpandedPaged(Paged): - """ - A paging container for iterating over a list of :class:`GenericResourceExpanded ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[GenericResourceExpanded]'} - } - - def __init__(self, *args, **kwargs): - - super(GenericResourceExpandedPaged, self).__init__(*args, **kwargs) -class ResourceGroupPaged(Paged): - """ - A paging container for iterating over a list of :class:`ResourceGroup ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[ResourceGroup]'} - } - - def __init__(self, *args, **kwargs): - - super(ResourceGroupPaged, self).__init__(*args, **kwargs) -class TagDetailsPaged(Paged): - """ - A paging container for iterating over a list of :class:`TagDetails ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[TagDetails]'} - } - - def __init__(self, *args, **kwargs): - - super(TagDetailsPaged, self).__init__(*args, **kwargs) -class DeploymentOperationPaged(Paged): - """ - A paging container for iterating over a list of :class:`DeploymentOperation ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[DeploymentOperation]'} - } - - def __init__(self, *args, **kwargs): - - super(DeploymentOperationPaged, self).__init__(*args, **kwargs) 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 3b6a0e19d760..e51889be1e28 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 @@ -1,23 +1,20 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from enum import Enum - class DeploymentMode(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 + the resource group that are not included in the template are deleted. Be careful when using + Complete mode as you may unintentionally delete resources. + """ incremental = "Incremental" complete = "Complete" - - -class ResourceIdentityType(str, Enum): - - system_assigned = "SystemAssigned" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/operations/__init__.py index 7ec2787ace60..75e22640321c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/operations/__init__.py @@ -1,12 +1,9 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from ._deployments_operations import DeploymentsOperations @@ -14,7 +11,7 @@ from ._resources_operations import ResourcesOperations from ._resource_groups_operations import ResourceGroupsOperations from ._tags_operations import TagsOperations -from ._deployment_operations import DeploymentOperations +from ._deployment_operations_operations import DeploymentOperationsOperations __all__ = [ 'DeploymentsOperations', @@ -22,5 +19,5 @@ 'ResourcesOperations', 'ResourceGroupsOperations', 'TagsOperations', - 'DeploymentOperations', + 'DeploymentOperationsOperations', ] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/operations/_deployment_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/operations/_deployment_operations.py deleted file mode 100644 index 1dfa6e6cfbb9..000000000000 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/operations/_deployment_operations.py +++ /dev/null @@ -1,184 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError - -from .. import models - - -class DeploymentOperations(object): - """DeploymentOperations operations. - - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. - - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for this operation. Constant value: "2017-05-10". - """ - - models = models - - def __init__(self, client, config, serializer, deserializer): - - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self.api_version = "2017-05-10" - - self.config = config - - def get( - self, resource_group_name, deployment_name, operation_id, custom_headers=None, raw=False, **operation_config): - """Gets a deployments operation. - - :param resource_group_name: The name of the resource group. The name - is case insensitive. - :type resource_group_name: str - :param deployment_name: The name of the deployment. - :type deployment_name: str - :param operation_id: The ID of the operation to get. - :type operation_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentOperation or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentOperation - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` - """ - # Construct URL - url = self.get.metadata['url'] - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, 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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) - - if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentOperation', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}'} - - def list( - self, resource_group_name, deployment_name, top=None, custom_headers=None, raw=False, **operation_config): - """Gets all deployments operations for a deployment. - - :param resource_group_name: The name of the resource group. The name - is case insensitive. - :type resource_group_name: str - :param deployment_name: The name of the deployment with the operation - to get. - :type deployment_name: str - :param top: The number of results to return. - :type top: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of DeploymentOperation - :rtype: - ~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentOperationPaged[~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentOperation] - :raises: :class:`CloudError` - """ - def prepare_request(next_link=None): - if not next_link: - # Construct URL - url = self.list.metadata['url'] - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - else: - url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) - return request - - def internal_paging(next_link=None): - request = prepare_request(next_link) - - response = self._client.send(request, stream=False, **operation_config) - - if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response - - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.DeploymentOperationPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations'} 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 new file mode 100644 index 000000000000..1942381625a8 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/operations/_deployment_operations_operations.py @@ -0,0 +1,184 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class DeploymentOperationsOperations(object): + """DeploymentOperationsOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2017_05_10.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def get( + self, + resource_group_name, # type: str + deployment_name, # type: str + operation_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentOperation" + """Gets a deployments operation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param operation_id: The ID of the operation to get. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentOperation or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentOperation + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentOperation"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-05-10" + + # Construct URL + url = self.get.metadata['url'] # type: 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'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentOperation', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + def list( + self, + resource_group_name, # type: str + deployment_name, # type: str + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.DeploymentOperationsListResult"] + """Gets all deployments operations for a deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment with the operation to get. + :type deployment_name: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-05-10" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentOperationsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations'} # type: ignore 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 1ffb3391cd7d..52cd207eeedb 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 @@ -1,700 +1,685 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError -from msrest.polling import LROPoller, NoPolling -from msrestazure.polling.arm_polling import ARMPolling +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class DeploymentsOperations(object): """DeploymentsOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2017_05_10.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for this operation. Constant value: "2017-05-10". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2017-05-10" - - self.config = config - + self._config = config def _delete_initial( - self, resource_group_name, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-05-10" + # Construct URL - url = self.delete.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [202, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - - def delete( - self, resource_group_name, deployment_name, custom_headers=None, raw=False, polling=True, **operation_config): - """Deletes a deployment from the deployment history. - - A template deployment that is currently running cannot be deleted. - Deleting a template deployment removes the associated deployment - operations. Deleting a template deployment does not affect the state of - the resource group. This is an asynchronous operation that returns a - status of 202 until the template deployment is successfully deleted. - The Location response header contains the URI that is used to obtain - the status of the process. While the process is running, a call to the - URI in the Location header returns a status of 202. When the process - finishes, the URI in the Location header returns a status of 204 on - success. If the asynchronous request failed, the URI in the Location - header returns an error-level status code. - - :param resource_group_name: The name of the resource group with the - deployment to delete. The name is case insensitive. + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + def begin_delete( + self, + resource_group_name, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """A template deployment that is currently running cannot be deleted. Deleting a template deployment removes the associated deployment operations. Deleting a template deployment does not affect the state of the resource group. This is an asynchronous operation that returns a status of 202 until the template deployment is successfully deleted. The Location response header contains the URI that is used to obtain the status of the process. While the process is running, a call to the URI in the Location header returns a status of 202. When the process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. + + Deletes a deployment from the deployment history. + + :param resource_group_name: The name of the resource group with the deployment to delete. The + name is case insensitive. :type resource_group_name: str :param deployment_name: The name of the deployment to delete. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns None or - ClientRawResponse if raw==True - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._delete_initial( resource_group_name=resource_group_name, deployment_name=deployment_name, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore def check_existence( - self, resource_group_name, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Checks whether the deployment exists. - :param resource_group_name: The name of the resource group with the - deployment to check. The name is case insensitive. + :param resource_group_name: The name of the resource group with the deployment to check. The + name is case insensitive. :type resource_group_name: str :param deployment_name: The name of the deployment to check. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: bool or ClientRawResponse if raw=true - :rtype: bool or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-05-10" + # Construct URL - url = self.check_existence.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204, 404]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = (response.status_code == 204) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - return deserialized - check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + if cls: + return cls(pipeline_response, None, {}) + + 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, deployment_name, properties, custom_headers=None, raw=False, **operation_config): - parameters = models.Deployment(properties=properties) + self, + resource_group_name, # type: str + deployment_name, # type: str + properties, # type: "models.DeploymentProperties" + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentExtended" + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.Deployment(properties=properties) + api_version = "2017-05-10" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.create_or_update.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'Deployment') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 201]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', response) + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', response) + deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - - def create_or_update( - self, resource_group_name, deployment_name, properties, custom_headers=None, raw=False, polling=True, **operation_config): - """Deploys resources to a resource group. - - You can provide the template and parameters directly in the request or - link to JSON files. - - :param resource_group_name: The name of the resource group to deploy - the resources to. The name is case insensitive. The resource group - must already exist. + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + def begin_create_or_update( + self, + resource_group_name, # type: str + deployment_name, # type: str + properties, # type: "models.DeploymentProperties" + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """You can provide the template and parameters directly in the request or link to JSON files. + + Deploys resources to a resource group. + + :param resource_group_name: The name of the resource group to deploy the resources to. The name + is case insensitive. The resource group must already exist. :type resource_group_name: str :param deployment_name: The name of the deployment. :type deployment_name: str :param properties: The deployment properties. - :type properties: - ~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentProperties - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :type properties: ~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentProperties + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns DeploymentExtended or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentExtended] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentExtended]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 DeploymentExtended + :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] + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._create_or_update_initial( resource_group_name=resource_group_name, deployment_name=deployment_name, properties=properties, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - deserialized = self._deserialize('DeploymentExtended', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore def get( - self, resource_group_name, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentExtended" """Gets a deployment. - :param resource_group_name: The name of the resource group. The name - is case insensitive. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param deployment_name: The name of the deployment to get. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentExtended or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentExtended - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExtended or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentExtended + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-05-10" + # Construct URL - url = self.get.metadata['url'] + url = self.get.metadata['url'] # type: 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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', response) + deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore def cancel( - self, resource_group_name, deployment_name, custom_headers=None, raw=False, **operation_config): - """Cancels a currently running template deployment. + self, + resource_group_name, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """You can cancel a deployment only if the provisioningState is Accepted or Running. After the deployment is canceled, the provisioningState is set to Canceled. Canceling a template deployment stops the currently running template deployment and leaves the resource group partially deployed. - You can cancel a deployment only if the provisioningState is Accepted - or Running. After the deployment is canceled, the provisioningState is - set to Canceled. Canceling a template deployment stops the currently - running template deployment and leaves the resource group partially - deployed. + Cancels a currently running template deployment. - :param resource_group_name: The name of the resource group. The name - is case insensitive. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param deployment_name: The name of the deployment to cancel. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-05-10" + # Construct URL - url = self.cancel.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - cancel.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} + if cls: + return cls(pipeline_response, None, {}) - def validate( - self, resource_group_name, deployment_name, properties, custom_headers=None, raw=False, **operation_config): - """Validates whether the specified template is syntactically correct and - will be accepted by Azure Resource Manager.. + cancel.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore - :param resource_group_name: The name of the resource group the - template will be deployed to. The name is case insensitive. + def validate( + self, + resource_group_name, # type: str + deployment_name, # type: str + properties, # type: "models.DeploymentProperties" + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentValidateResult" + """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. :type resource_group_name: str :param deployment_name: The name of the deployment. :type deployment_name: str :param properties: The deployment properties. - :type properties: - ~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentProperties - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentValidateResult or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentValidateResult - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :type properties: ~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentProperties + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentValidateResult + :raises: ~azure.core.exceptions.HttpResponseError """ - parameters = models.Deployment(properties=properties) + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentValidateResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.Deployment(properties=properties) + api_version = "2017-05-10" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.validate.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'Deployment') # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 400]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', response) + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', response) + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - validate.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} + validate.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore def export_template( - self, resource_group_name, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentExportResult" """Exports the template used for specified deployment. - :param resource_group_name: The name of the resource group. The name - is case insensitive. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str - :param deployment_name: The name of the deployment from which to get - the template. + :param deployment_name: The name of the deployment from which to get the template. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentExportResult or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentExportResult - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentExportResult + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExportResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-05-10" + # Construct URL - url = self.export_template.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentExportResult', response) + deserialized = self._deserialize('DeploymentExportResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} + export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore def list_by_resource_group( - self, resource_group_name, filter=None, top=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.DeploymentListResult"] """Get all the deployments for a resource group. - :param resource_group_name: The name of the resource group with the - deployments to get. The name is case insensitive. + :param resource_group_name: The name of the resource group with the deployments to get. The + name is case insensitive. :type resource_group_name: str - :param filter: The filter to apply on the operation. For example, you - can use $filter=provisioningState eq '{state}'. + :param filter: The filter to apply on the operation. For example, you can use + $filter=provisioningState eq '{state}'. :type filter: str - :param top: The number of results to get. If null is passed, returns - all deployments. + :param top: The number of results to get. If null is passed, returns all deployments. :type top: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of DeploymentExtended - :rtype: - ~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentExtendedPaged[~azure.mgmt.resource.resources.v2017_05_10.models.DeploymentExtended] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-05-10" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_by_resource_group.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.DeploymentExtendedPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/'} + return ItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/'} # type: ignore def calculate_template_hash( - self, template, custom_headers=None, raw=False, **operation_config): + self, + template, # type: object + **kwargs # type: Any + ): + # type: (...) -> "models.TemplateHashResult" """Calculate the hash of the given template. :param template: The template provided to calculate hash. :type template: object - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: TemplateHashResult or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2017_05_10.models.TemplateHashResult - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateHashResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.TemplateHashResult + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TemplateHashResult"] + error_map = {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.calculate_template_hash.metadata['url'] + url = self.calculate_template_hash.metadata['url'] # type: ignore # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(template, 'object') # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('TemplateHashResult', response) + deserialized = self._deserialize('TemplateHashResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - calculate_template_hash.metadata = {'url': '/providers/Microsoft.Resources/calculateTemplateHash'} + 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 58d615769a42..8d4bde5f2014 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 @@ -1,300 +1,287 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class ProvidersOperations(object): """ProvidersOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2017_05_10.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for this operation. Constant value: "2017-05-10". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2017-05-10" - - self.config = config + self._config = config def unregister( - self, resource_provider_namespace, custom_headers=None, raw=False, **operation_config): + self, + resource_provider_namespace, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.Provider" """Unregisters a subscription from a resource provider. - :param resource_provider_namespace: The namespace of the resource - provider to unregister. + :param resource_provider_namespace: The namespace of the resource provider to unregister. :type resource_provider_namespace: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: Provider or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.Provider or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Provider or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.Provider + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Provider"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-05-10" + # Construct URL - url = self.unregister.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('Provider', response) + deserialized = self._deserialize('Provider', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - unregister.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister'} + unregister.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister'} # type: ignore def register( - self, resource_provider_namespace, custom_headers=None, raw=False, **operation_config): + self, + resource_provider_namespace, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.Provider" """Registers a subscription with a resource provider. - :param resource_provider_namespace: The namespace of the resource - provider to register. + :param resource_provider_namespace: The namespace of the resource provider to register. :type resource_provider_namespace: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: Provider or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.Provider or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Provider or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.Provider + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Provider"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-05-10" + # Construct URL - url = self.register.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('Provider', response) + deserialized = self._deserialize('Provider', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - register.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register'} + register.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register'} # type: ignore def list( - self, top=None, expand=None, custom_headers=None, raw=False, **operation_config): + self, + top=None, # type: Optional[int] + expand=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.ProviderListResult"] """Gets all resource providers for a subscription. - :param top: The number of results to return. If null is passed returns - all deployments. + :param top: The number of results to return. If null is passed returns all deployments. :type top: int - :param expand: The properties to include in the results. For example, - use &$expand=metadata in the query string to retrieve resource - provider metadata. To include property aliases in response, use - $expand=resourceTypes/aliases. + :param expand: The properties to include in the results. For example, use &$expand=metadata in + the query string to retrieve resource provider metadata. To include property aliases in + response, use $expand=resourceTypes/aliases. :type expand: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of Provider - :rtype: - ~azure.mgmt.resource.resources.v2017_05_10.models.ProviderPaged[~azure.mgmt.resource.resources.v2017_05_10.models.Provider] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of ProviderListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-05-10" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['url'] + url = self.list.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_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 = {} + 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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('ProviderListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.ProviderPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers'} # type: ignore def get( - self, resource_provider_namespace, expand=None, custom_headers=None, raw=False, **operation_config): + self, + resource_provider_namespace, # type: str + expand=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.Provider" """Gets the specified resource provider. - :param resource_provider_namespace: The namespace of the resource - provider. + :param resource_provider_namespace: The namespace of the resource provider. :type resource_provider_namespace: str - :param expand: The $expand query parameter. For example, to include - property aliases in response, use $expand=resourceTypes/aliases. + :param expand: The $expand query parameter. For example, to include property aliases in + response, use $expand=resourceTypes/aliases. :type expand: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: Provider or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.Provider or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Provider or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.Provider + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Provider"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-05-10" + # Construct URL - url = self.get.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('Provider', response) + deserialized = self._deserialize('Provider', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}'} + 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 e806259e832f..e7725b7c3b38 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 @@ -1,526 +1,513 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError -from msrest.polling import LROPoller, NoPolling -from msrestazure.polling.arm_polling import ARMPolling +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, List, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class ResourceGroupsOperations(object): """ResourceGroupsOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2017_05_10.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for this operation. Constant value: "2017-05-10". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2017-05-10" - - self.config = config + self._config = config def check_existence( - self, resource_group_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Checks whether a resource group exists. - :param resource_group_name: The name of the resource group to check. - The name is case insensitive. + :param resource_group_name: The name of the resource group to check. The name is case + insensitive. :type resource_group_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: bool or ClientRawResponse if raw=true - :rtype: bool or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-05-10" + # Construct URL - url = self.check_existence.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204, 404]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = (response.status_code == 204) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - return deserialized - check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore def create_or_update( - self, resource_group_name, parameters, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + parameters, # type: "models.ResourceGroup" + **kwargs # type: Any + ): + # type: (...) -> "models.ResourceGroup" """Creates or updates a resource group. - :param resource_group_name: The name of the resource group to create - or update. + :param resource_group_name: The name of the resource group to create or update. :type resource_group_name: str - :param parameters: Parameters supplied to the create or update a - resource group. - :type parameters: - ~azure.mgmt.resource.resources.v2017_05_10.models.ResourceGroup - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: ResourceGroup or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2017_05_10.models.ResourceGroup or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :param parameters: Parameters supplied to the create or update a resource group. + :type parameters: ~azure.mgmt.resource.resources.v2017_05_10.models.ResourceGroup + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.ResourceGroup + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceGroup"] + error_map = {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.create_or_update.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'ResourceGroup') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 201]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ResourceGroup', response) + deserialized = self._deserialize('ResourceGroup', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('ResourceGroup', response) + deserialized = self._deserialize('ResourceGroup', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} - + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore def _delete_initial( - self, resource_group_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-05-10" + # Construct URL - url = self.delete.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 202]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore - def delete( - self, resource_group_name, custom_headers=None, raw=False, polling=True, **operation_config): - """Deletes a resource group. + def begin_delete( + self, + resource_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """When you delete a resource group, all of its resources are also deleted. Deleting a resource group deletes all of its template deployments and currently stored operations. - When you delete a resource group, all of its resources are also - deleted. Deleting a resource group deletes all of its template - deployments and currently stored operations. + Deletes a resource group. - :param resource_group_name: The name of the resource group to delete. - The name is case insensitive. + :param resource_group_name: The name of the resource group to delete. The name is case + insensitive. :type resource_group_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns None or - ClientRawResponse if raw==True - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._delete_initial( resource_group_name=resource_group_name, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore def get( - self, resource_group_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.ResourceGroup" """Gets a resource group. - :param resource_group_name: The name of the resource group to get. The - name is case insensitive. + :param resource_group_name: The name of the resource group to get. The name is case + insensitive. :type resource_group_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: ResourceGroup or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2017_05_10.models.ResourceGroup or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.ResourceGroup + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceGroup"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-05-10" + # Construct URL - url = self.get.metadata['url'] + url = self.get.metadata['url'] # type: 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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('ResourceGroup', response) + deserialized = self._deserialize('ResourceGroup', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore def update( - self, resource_group_name, parameters, custom_headers=None, raw=False, **operation_config): - """Updates a resource group. - - Resource groups can be updated through a simple PATCH operation to a - group address. The format of the request is the same as that for - creating a resource group. If a field is unspecified, the current value - is retained. - - :param resource_group_name: The name of the resource group to update. - The name is case insensitive. + self, + resource_group_name, # type: str + parameters, # type: "models.ResourceGroupPatchable" + **kwargs # type: Any + ): + # type: (...) -> "models.ResourceGroup" + """Resource groups can be updated through a simple PATCH operation to a group address. The format of the request is the same as that for creating a resource group. If a field is unspecified, the current value is retained. + + Updates a resource group. + + :param resource_group_name: The name of the resource group to update. The name is case + insensitive. :type resource_group_name: str :param parameters: Parameters supplied to update a resource group. - :type parameters: - ~azure.mgmt.resource.resources.v2017_05_10.models.ResourceGroupPatchable - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: ResourceGroup or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2017_05_10.models.ResourceGroup or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :type parameters: ~azure.mgmt.resource.resources.v2017_05_10.models.ResourceGroupPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.ResourceGroup + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceGroup"] + error_map = {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.update.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'ResourceGroupPatchable') # Construct and send request - request = self._client.patch(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('ResourceGroup', response) + deserialized = self._deserialize('ResourceGroup', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore def export_template( - self, resource_group_name, resources=None, options=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + resources=None, # type: Optional[List[str]] + options=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.ResourceGroupExportResult" """Captures the specified resource group as a template. - :param resource_group_name: The name of the resource group to export - as a template. + :param resource_group_name: The name of the resource group to export as a template. :type resource_group_name: str - :param resources: The IDs of the resources to filter the export by. To - export all resources, supply an array with single entry '*'. + :param 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', - 'SkipResourceNameParameterization', 'SkipAllParameterization' + :param options: The export template options. A CSV-formatted list containing zero or more of + the following: 'IncludeParameterDefaultValue', 'IncludeComments', + 'SkipResourceNameParameterization', 'SkipAllParameterization'. :type options: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: ResourceGroupExportResult or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2017_05_10.models.ResourceGroupExportResult - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroupExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.ResourceGroupExportResult + :raises: ~azure.core.exceptions.HttpResponseError """ - parameters = models.ExportTemplateRequest(resources=resources, options=options) + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceGroupExportResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.ExportTemplateRequest(resources=resources, options=options) + api_version = "2017-05-10" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.export_template.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'ExportTemplateRequest') # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('ResourceGroupExportResult', response) + deserialized = self._deserialize('ResourceGroupExportResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate'} + export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate'} # type: ignore def list( - self, filter=None, top=None, custom_headers=None, raw=False, **operation_config): + self, + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.ResourceGroupListResult"] """Gets all the resource groups for a subscription. :param filter: The filter to apply on the operation. :type filter: str - :param top: The number of results to return. If null is passed, - returns all resource groups. + :param top: The number of results to return. If null is passed, returns all resource groups. :type top: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of ResourceGroup - :rtype: - ~azure.mgmt.resource.resources.v2017_05_10.models.ResourceGroupPaged[~azure.mgmt.resource.resources.v2017_05_10.models.ResourceGroup] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-05-10" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['url'] + url = self.list.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_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 = {} + 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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('ResourceGroupListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.ResourceGroupPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups'} # type: ignore 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 eb5c31791467..cd1fe2948be2 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 @@ -1,524 +1,553 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError -from msrest.polling import LROPoller, NoPolling -from msrestazure.polling.arm_polling import ARMPolling +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, List, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class ResourcesOperations(object): """ResourcesOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2017_05_10.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for this operation. Constant value: "2017-05-10". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2017-05-10" - - self.config = config + self._config = config def list_by_resource_group( - self, resource_group_name, filter=None, expand=None, top=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + filter=None, # type: Optional[str] + expand=None, # type: Optional[str] + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.ResourceListResult"] """Get all the resources for a resource group. - :param resource_group_name: The resource group with the resources to - get. + :param resource_group_name: The resource group with the resources to get. :type resource_group_name: str :param filter: The filter to apply on the operation. :type filter: str - :param expand: Comma-separated list of additional properties to be - included in the response. Valid values include `createdTime`, - `changedTime` and `provisioningState`. For example, - `$expand=createdTime,changedTime`. + :param expand: Comma-separated list of additional properties to be included in the response. + Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, + ``$expand=createdTime,changedTime``. :type expand: str - :param top: The 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 - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of GenericResourceExpanded - :rtype: - ~azure.mgmt.resource.resources.v2017_05_10.models.GenericResourceExpandedPaged[~azure.mgmt.resource.resources.v2017_05_10.models.GenericResourceExpanded] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of ResourceListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-05-10" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_by_resource_group.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('ResourceListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response - - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.GenericResourceExpandedPaged(internal_paging, self._deserialize.dependencies, header_dict) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return deserialized - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources'} + return pipeline_response + return ItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources'} # type: ignore def _move_resources_initial( - self, source_resource_group_name, resources=None, target_resource_group=None, custom_headers=None, raw=False, **operation_config): - parameters = models.ResourcesMoveInfo(resources=resources, target_resource_group=target_resource_group) + self, + source_resource_group_name, # type: str + resources=None, # type: Optional[List[str]] + target_resource_group=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.ResourcesMoveInfo(resources=resources, target_resource_group=target_resource_group) + api_version = "2017-05-10" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.move_resources.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'ResourcesMoveInfo') + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [202, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - - def move_resources( - self, source_resource_group_name, resources=None, target_resource_group=None, custom_headers=None, raw=False, polling=True, **operation_config): - """Moves resources from one resource group to another resource group. - - The resources to move must be in the same source resource group. The - target resource group may be in a different subscription. When moving - resources, both the source group and the target group are locked for - the duration of the operation. Write and delete operations are blocked - on the groups until the move completes. . - - :param source_resource_group_name: The name of the resource group - containing the resources to move. + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore + + def begin_move_resources( + self, + source_resource_group_name, # type: str + resources=None, # type: Optional[List[str]] + target_resource_group=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """The resources to move must be in the same source resource group. The target resource group may be in a different subscription. When moving resources, both the source group and the target group are locked for the duration of the operation. Write and delete operations are blocked on the groups until the move completes. + + Moves resources from one resource group to another resource group. + + :param source_resource_group_name: The name of the resource group containing the resources to + move. :type source_resource_group_name: str :param resources: The IDs of the resources. :type resources: list[str] :param target_resource_group: The target resource group. :type target_resource_group: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns None or - ClientRawResponse if raw==True - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._move_resources_initial( source_resource_group_name=source_resource_group_name, resources=resources, target_resource_group=target_resource_group, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} - + begin_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore def _validate_move_resources_initial( - self, source_resource_group_name, resources=None, target_resource_group=None, custom_headers=None, raw=False, **operation_config): - parameters = models.ResourcesMoveInfo(resources=resources, target_resource_group=target_resource_group) + self, + source_resource_group_name, # type: str + resources=None, # type: Optional[List[str]] + target_resource_group=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.ResourcesMoveInfo(resources=resources, target_resource_group=target_resource_group) + api_version = "2017-05-10" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.validate_move_resources.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'ResourcesMoveInfo') + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [202, 204, 409]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - - def validate_move_resources( - self, source_resource_group_name, resources=None, target_resource_group=None, custom_headers=None, raw=False, polling=True, **operation_config): - """Validates whether resources can be moved from one resource group to - another resource group. - - This operation checks whether the specified resources can be moved to - the target. The resources to move must be in the same source resource - group. The target resource group may be in a different subscription. If - validation succeeds, it returns HTTP response code 204 (no content). If - validation fails, it returns HTTP response code 409 (Conflict) with an - error message. Retrieve the URL in the Location header value to check - the result of the long-running operation. - - :param source_resource_group_name: The name of the resource group - containing the resources to validate for move. + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _validate_move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} # type: ignore + + def begin_validate_move_resources( + self, + source_resource_group_name, # type: str + resources=None, # type: Optional[List[str]] + target_resource_group=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """This operation checks whether the specified resources can be moved to the target. The resources to move must be in the same source resource group. The target resource group may be in a different subscription. If validation succeeds, it returns HTTP response code 204 (no content). If validation fails, it returns HTTP response code 409 (Conflict) with an error message. Retrieve the URL in the Location header value to check the result of the long-running operation. + + Validates whether resources can be moved from one resource group to another resource group. + + :param source_resource_group_name: The name of the resource group containing the resources to + validate for move. :type source_resource_group_name: str :param resources: The IDs of the resources. :type resources: list[str] :param target_resource_group: The target resource group. :type target_resource_group: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns None or - ClientRawResponse if raw==True - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._validate_move_resources_initial( source_resource_group_name=source_resource_group_name, resources=resources, target_resource_group=target_resource_group, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - validate_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} + begin_validate_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} # type: ignore def list( - self, filter=None, expand=None, top=None, custom_headers=None, raw=False, **operation_config): + self, + filter=None, # type: Optional[str] + expand=None, # type: Optional[str] + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.ResourceListResult"] """Get all the resources in a subscription. :param filter: The filter to apply on the operation. :type filter: str - :param expand: Comma-separated list of additional properties to be - included in the response. Valid values include `createdTime`, - `changedTime` and `provisioningState`. For example, - `$expand=createdTime,changedTime`. + :param expand: Comma-separated list of additional properties to be included in the response. + Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, + ``$expand=createdTime,changedTime``. :type expand: str - :param top: The number of results to return. If null is passed, - returns all resource groups. + :param top: The number of results to return. If null is passed, returns all resource groups. :type top: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of GenericResourceExpanded - :rtype: - ~azure.mgmt.resource.resources.v2017_05_10.models.GenericResourceExpandedPaged[~azure.mgmt.resource.resources.v2017_05_10.models.GenericResourceExpanded] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of ResourceListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-05-10" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['url'] + url = self.list.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_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 = {} + 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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('ResourceListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.GenericResourceExpandedPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resources'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resources'} # type: ignore def check_existence( - self, resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, api_version, custom_headers=None, raw=False, **operation_config): + self, + 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: (...) -> None """Checks whether a resource exists. - :param resource_group_name: The name of the resource group containing - the resource to check. The name is case insensitive. + :param resource_group_name: The name of the resource group containing the resource to check. + The name is case insensitive. :type resource_group_name: str - :param resource_provider_namespace: The resource provider of the - resource to check. + :param resource_provider_namespace: The resource provider of the resource to check. :type resource_provider_namespace: str :param parent_resource_path: The parent resource identity. :type parent_resource_path: str :param resource_type: The resource type. :type resource_type: str - :param resource_name: The name of the resource to check whether it - exists. + :param resource_name: The name of the resource to check whether it exists. :type resource_name: str - :param api_version: The API version to use for the operation. - :type api_version: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: bool or ClientRawResponse if raw=true - :rtype: bool or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-05-10" + # Construct URL - url = self.check_existence.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204, 404]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = (response.status_code == 204) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - return deserialized - check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + 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, resource_provider_namespace, parent_resource_path, resource_type, resource_name, api_version, custom_headers=None, raw=False, **operation_config): + self, + 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: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-05-10" + # Construct URL - url = self.delete.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - - def delete( - self, resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, api_version, custom_headers=None, raw=False, polling=True, **operation_config): + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + def begin_delete( + self, + 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: (...) -> LROPoller """Deletes a resource. - :param resource_group_name: The name of the resource group that - contains the resource to delete. The name is case insensitive. + :param resource_group_name: The name of the resource group that contains the resource to + delete. The name is case insensitive. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource - provider. + :param resource_provider_namespace: The namespace of the resource provider. :type resource_provider_namespace: str :param parent_resource_path: The parent resource identity. :type parent_resource_path: str @@ -526,109 +555,122 @@ def delete( :type resource_type: str :param resource_name: The name of the resource to delete. :type resource_name: str - :param api_version: The API version to use for the operation. - :type api_version: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns None or - ClientRawResponse if raw==True - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._delete_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, - api_version=api_version, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} - + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore def _create_or_update_initial( - self, resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, api_version, parameters, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + parameters, # type: "models.GenericResource" + **kwargs # type: Any + ): + # type: (...) -> "models.GenericResource" + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {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.create_or_update.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'GenericResource') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 201, 202]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('GenericResource', response) + deserialized = self._deserialize('GenericResource', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('GenericResource', response) + deserialized = self._deserialize('GenericResource', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - - def create_or_update( - self, resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, api_version, parameters, custom_headers=None, raw=False, polling=True, **operation_config): + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + def begin_create_or_update( + self, + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + parameters, # type: "models.GenericResource" + **kwargs # type: Any + ): + # type: (...) -> LROPoller """Creates a resource. - :param resource_group_name: The name of the resource group for the - resource. The name is case insensitive. + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource - provider. + :param resource_provider_namespace: The namespace of the resource provider. :type resource_provider_namespace: str :param parent_resource_path: The parent resource identity. :type parent_resource_path: str @@ -636,117 +678,125 @@ def create_or_update( :type resource_type: str :param resource_name: The name of the resource to create. :type resource_name: str - :param api_version: The API version to use for the operation. - :type api_version: str :param parameters: Parameters for creating or updating the resource. - :type parameters: - ~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :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 polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns GenericResource or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 GenericResource + :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] + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._create_or_update_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, - api_version=api_version, parameters=parameters, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - deserialized = self._deserialize('GenericResource', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('GenericResource', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} - + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore def _update_initial( - self, resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, api_version, parameters, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + parameters, # type: "models.GenericResource" + **kwargs # type: Any + ): + # type: (...) -> "models.GenericResource" + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {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.update.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'GenericResource') # Construct and send request - request = self._client.patch(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 202]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('GenericResource', response) + deserialized = self._deserialize('GenericResource', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - - def update( - self, resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, api_version, parameters, custom_headers=None, raw=False, polling=True, **operation_config): + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + def begin_update( + self, + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + parameters, # type: "models.GenericResource" + **kwargs # type: Any + ): + # type: (...) -> LROPoller """Updates a resource. - :param resource_group_name: The name of the resource group for the - resource. The name is case insensitive. + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource - provider. + :param resource_provider_namespace: The namespace of the resource provider. :type resource_provider_namespace: str :param parent_resource_path: The parent resource identity. :type parent_resource_path: str @@ -754,64 +804,63 @@ def update( :type resource_type: str :param resource_name: The name of the resource to update. :type resource_name: str - :param api_version: The API version to use for the operation. - :type api_version: str :param parameters: Parameters for updating the resource. - :type parameters: - ~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :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 polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns GenericResource or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 GenericResource + :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] + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._update_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, - api_version=api_version, parameters=parameters, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - deserialized = self._deserialize('GenericResource', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('GenericResource', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore def get( - self, resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, api_version, custom_headers=None, raw=False, **operation_config): + self, + 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: (...) -> "models.GenericResource" """Gets a resource. - :param resource_group_name: The name of the resource group containing - the resource to get. The name is case insensitive. + :param resource_group_name: The name of the resource group containing the resource to get. The + name is case insensitive. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource - provider. + :param resource_provider_namespace: The namespace of the resource provider. :type resource_provider_namespace: str :param parent_resource_path: The parent resource identity. :type parent_resource_path: str @@ -819,461 +868,443 @@ def get( :type resource_type: str :param resource_name: The name of the resource to get. :type resource_name: str - :param api_version: The API version to use for the operation. - :type api_version: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: GenericResource or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GenericResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-05-10" + # Construct URL - url = self.get.metadata['url'] + url = self.get.metadata['url'] # type: 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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('GenericResource', response) + deserialized = self._deserialize('GenericResource', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore def check_existence_by_id( - self, resource_id, api_version, custom_headers=None, raw=False, **operation_config): + self, + resource_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Checks by ID whether a resource exists. - :param resource_id: The fully qualified ID of the resource, including - the resource name and resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. :type resource_id: str - :param api_version: The API version to use for the operation. - :type api_version: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: bool or ClientRawResponse if raw=true - :rtype: bool or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-05-10" + # Construct URL - url = self.check_existence_by_id.metadata['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) + '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 = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204, 404]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = (response.status_code == 204) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - return deserialized - check_existence_by_id.metadata = {'url': '/{resourceId}'} + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + return 200 <= response.status_code <= 299 + check_existence_by_id.metadata = {'url': '/{resourceId}'} # type: ignore def _delete_by_id_initial( - self, resource_id, api_version, custom_headers=None, raw=False, **operation_config): + self, + resource_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-05-10" + # Construct URL - url = self.delete_by_id.metadata['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) + '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 = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + _delete_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore - def delete_by_id( - self, resource_id, api_version, custom_headers=None, raw=False, polling=True, **operation_config): + def begin_delete_by_id( + self, + resource_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> LROPoller """Deletes a resource by ID. - :param resource_id: The fully qualified ID of the resource, including - the resource name and resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. :type resource_id: str - :param api_version: The API version to use for the operation. - :type api_version: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns None or - ClientRawResponse if raw==True - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._delete_by_id_initial( resource_id=resource_id, - api_version=api_version, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - delete_by_id.metadata = {'url': '/{resourceId}'} - + begin_delete_by_id.metadata = {'url': '/{resourceId}'} # type: ignore def _create_or_update_by_id_initial( - self, resource_id, api_version, parameters, custom_headers=None, raw=False, **operation_config): + self, + resource_id, # type: str + parameters, # type: "models.GenericResource" + **kwargs # type: Any + ): + # type: (...) -> "models.GenericResource" + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {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.create_or_update_by_id.metadata['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) + '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 = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'GenericResource') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 201, 202]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('GenericResource', response) + deserialized = self._deserialize('GenericResource', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('GenericResource', response) + deserialized = self._deserialize('GenericResource', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - - def create_or_update_by_id( - self, resource_id, api_version, parameters, custom_headers=None, raw=False, polling=True, **operation_config): + _create_or_update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + def begin_create_or_update_by_id( + self, + resource_id, # type: str + parameters, # type: "models.GenericResource" + **kwargs # type: Any + ): + # type: (...) -> LROPoller """Create a resource by ID. - :param resource_id: The fully qualified ID of the resource, including - the resource name and resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. :type resource_id: str - :param api_version: The API version to use for the operation. - :type api_version: str :param parameters: Create or update resource parameters. - :type parameters: - ~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :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 polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns GenericResource or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 GenericResource + :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] + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._create_or_update_by_id_initial( resource_id=resource_id, - api_version=api_version, parameters=parameters, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - deserialized = self._deserialize('GenericResource', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('GenericResource', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - create_or_update_by_id.metadata = {'url': '/{resourceId}'} - + begin_create_or_update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore def _update_by_id_initial( - self, resource_id, api_version, parameters, custom_headers=None, raw=False, **operation_config): + self, + resource_id, # type: str + parameters, # type: "models.GenericResource" + **kwargs # type: Any + ): + # type: (...) -> "models.GenericResource" + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {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.update_by_id.metadata['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) + '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 = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'GenericResource') # Construct and send request - request = self._client.patch(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 202]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('GenericResource', response) + deserialized = self._deserialize('GenericResource', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - - def update_by_id( - self, resource_id, api_version, parameters, custom_headers=None, raw=False, polling=True, **operation_config): + _update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + def begin_update_by_id( + self, + resource_id, # type: str + parameters, # type: "models.GenericResource" + **kwargs # type: Any + ): + # type: (...) -> LROPoller """Updates a resource by ID. - :param resource_id: The fully qualified ID of the resource, including - the resource name and resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. :type resource_id: str - :param api_version: The API version to use for the operation. - :type api_version: str :param parameters: Update resource parameters. - :type parameters: - ~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :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 polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns GenericResource or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 GenericResource + :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] + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._update_by_id_initial( resource_id=resource_id, - api_version=api_version, parameters=parameters, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - deserialized = self._deserialize('GenericResource', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('GenericResource', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - update_by_id.metadata = {'url': '/{resourceId}'} + begin_update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore def get_by_id( - self, resource_id, api_version, custom_headers=None, raw=False, **operation_config): + self, + resource_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.GenericResource" """Gets a resource by ID. - :param resource_id: The fully qualified ID of the resource, including - the resource name and resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. :type resource_id: str - :param api_version: The API version to use for the operation. - :type api_version: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: GenericResource or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GenericResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.GenericResource + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-05-10" + # Construct URL - url = self.get_by_id.metadata['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) + '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 = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('GenericResource', response) + deserialized = self._deserialize('GenericResource', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/{resourceId}'} + 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 8475bfee73d0..cadf51ae5a23 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 @@ -1,340 +1,336 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class TagsOperations(object): """TagsOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2017_05_10.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for this operation. Constant value: "2017-05-10". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2017-05-10" - - self.config = config + self._config = config def delete_value( - self, tag_name, tag_value, custom_headers=None, raw=False, **operation_config): + self, + tag_name, # type: str + tag_value, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Deletes a tag value. :param tag_name: The name of the tag. :type tag_name: str :param tag_value: The value of the tag to delete. :type tag_value: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-05-10" + # Construct URL - url = self.delete_value.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} + delete_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore def create_or_update_value( - self, tag_name, tag_value, custom_headers=None, raw=False, **operation_config): + self, + tag_name, # type: str + tag_value, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.TagValue" """Creates a tag value. The name of the tag must already exist. :param tag_name: The name of the tag. :type tag_name: str :param tag_value: The value of the tag to create. :type tag_value: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: TagValue or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.TagValue or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagValue or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.TagValue + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TagValue"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-05-10" + # Construct URL - url = self.create_or_update_value.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.put(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 201]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('TagValue', response) + deserialized = self._deserialize('TagValue', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('TagValue', response) + deserialized = self._deserialize('TagValue', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} + create_or_update_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore def create_or_update( - self, tag_name, custom_headers=None, raw=False, **operation_config): - """Creates a tag in the subscription. + self, + tag_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.TagDetails" + """The tag name can have a maximum of 512 characters and is case insensitive. Tag names created by Azure have prefixes of microsoft, azure, or windows. You cannot create tags with one of these prefixes. - The tag name can have a maximum of 512 characters and is case - insensitive. Tag names created by Azure have prefixes of microsoft, - azure, or windows. You cannot create tags with one of these prefixes. + Creates a tag in the subscription. :param tag_name: The name of the tag to create. :type tag_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: TagDetails or ClientRawResponse if raw=true + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagDetails or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2017_05_10.models.TagDetails - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TagDetails"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-05-10" + # Construct URL - url = self.create_or_update.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.put(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 201]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('TagDetails', response) + deserialized = self._deserialize('TagDetails', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('TagDetails', response) + deserialized = self._deserialize('TagDetails', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore def delete( - self, tag_name, custom_headers=None, raw=False, **operation_config): - """Deletes a tag from the subscription. + self, + tag_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """You must remove all values from a resource tag before you can delete it. - You must remove all values from a resource tag before you can delete - it. + Deletes a tag from the subscription. :param tag_name: The name of the tag. :type tag_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-05-10" + # Construct URL - url = self.delete.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} + delete.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore def list( - self, custom_headers=None, raw=False, **operation_config): - """Gets the names and values of all resource tags that are defined in a - subscription. - - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of TagDetails - :rtype: - ~azure.mgmt.resource.resources.v2017_05_10.models.TagDetailsPaged[~azure.mgmt.resource.resources.v2017_05_10.models.TagDetails] - :raises: :class:`CloudError` + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.TagsListResult"] + """Gets the names and values of all resource tags that are defined in a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of TagsListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2017-05-10" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['url'] + url = self.list.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('TagsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.TagDetailsPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/py.typed b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file 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 deleted file mode 100644 index e6d73d4a6828..000000000000 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2017_05_10/version.py +++ /dev/null @@ -1,13 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -VERSION = "2017-05-10" - 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 68bc897193ac..fde2ed4c3b83 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 @@ -1,19 +1,16 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._configuration import ResourceManagementClientConfiguration from ._resource_management_client import ResourceManagementClient -__all__ = ['ResourceManagementClient', 'ResourceManagementClientConfiguration'] - -from .version import VERSION - -__version__ = VERSION +__all__ = ['ResourceManagementClient'] +try: + from ._patch import patch_sdk + patch_sdk() +except ImportError: + pass 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 3b326f792363..9306f5b7af1f 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 @@ -1,48 +1,69 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrestazure import AzureConfiguration -from .version import VERSION +from typing import TYPE_CHECKING +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + + from azure.core.credentials import TokenCredential + +VERSION = "unknown" + +class ResourceManagementClientConfiguration(Configuration): + """Configuration for ResourceManagementClient. -class ResourceManagementClientConfiguration(AzureConfiguration): - """Configuration for ResourceManagementClient Note that all parameters used to create this instance are saved as instance attributes. - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` + :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 """ def __init__( - self, credentials, subscription_id, base_url=None): - - if credentials is None: - raise ValueError("Parameter 'credentials' must not be None.") + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + 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.") - if not base_url: - base_url = 'https://management.azure.com' + super(ResourceManagementClientConfiguration, self).__init__(**kwargs) - super(ResourceManagementClientConfiguration, self).__init__(base_url) - - # Starting Autorest.Python 4.0.64, make connection pool activated by default - self.keep_alive = True - - self.add_user_agent('azure-mgmt-resource/{}'.format(VERSION)) - self.add_user_agent('Azure-SDK-For-Python') - - self.credentials = credentials + self.credential = credential self.subscription_id = subscription_id + self.api_version = "2018-02-01" + self.credential_scopes = ['https://management.azure.com/.default'] + self.credential_scopes.extend(kwargs.pop('credential_scopes', [])) + kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + 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) 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 new file mode 100644 index 000000000000..b55b0e51944d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/_metadata.json @@ -0,0 +1,58 @@ +{ + "chosen_version": "2018-02-01", + "total_api_version_list": ["2018-02-01"], + "client": { + "name": "ResourceManagementClient", + "filename": "_resource_management_client", + "description": "Provides operations for working with resources and resource groups." + }, + "global_parameters": { + "sync_method": { + "credential": { + "method_signature": "credential, # type: \"TokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials.TokenCredential", + "required": true + }, + "subscription_id": { + "method_signature": "subscription_id, # type: str", + "description": "The ID of the target subscription.", + "docstring_type": "str", + "required": true + } + }, + "async_method": { + "credential": { + "method_signature": "credential, # type: \"AsyncTokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + }, + "subscription_id": { + "method_signature": "subscription_id, # type: str", + "description": "The ID of the target subscription.", + "docstring_type": "str", + "required": true + } + }, + "constant": { + }, + "call": "credential, subscription_id" + }, + "config": { + "credential": true, + "credential_scopes": ["https://management.azure.com/.default"] + }, + "operation_groups": { + "deployments": "DeploymentsOperations", + "providers": "ProvidersOperations", + "resources": "ResourcesOperations", + "resource_groups": "ResourceGroupsOperations", + "tags": "TagsOperations", + "deployment_operations": "DeploymentOperationsOperations" + }, + "operation_mixins": { + }, + "sync_imports": "None", + "async_imports": "None" +} \ 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 bcad877fc9c3..3548af5945c2 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 @@ -1,16 +1,19 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.service_client import SDKClient -from msrest import Serializer, Deserializer +from typing import TYPE_CHECKING + +from azure.mgmt.core import ARMPipelineClient +from msrest import Deserializer, Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional from ._configuration import ResourceManagementClientConfiguration from .operations import DeploymentsOperations @@ -18,57 +21,72 @@ from .operations import ResourcesOperations from .operations import ResourceGroupsOperations from .operations import TagsOperations -from .operations import DeploymentOperations +from .operations import DeploymentOperationsOperations from . import models -class ResourceManagementClient(SDKClient): +class ResourceManagementClient(object): """Provides operations for working with resources and resource groups. - :ivar config: Configuration for client. - :vartype config: ResourceManagementClientConfiguration - - :ivar deployments: Deployments operations + :ivar deployments: DeploymentsOperations operations :vartype deployments: azure.mgmt.resource.resources.v2018_02_01.operations.DeploymentsOperations - :ivar providers: Providers operations + :ivar providers: ProvidersOperations operations :vartype providers: azure.mgmt.resource.resources.v2018_02_01.operations.ProvidersOperations - :ivar resources: Resources operations + :ivar resources: ResourcesOperations operations :vartype resources: azure.mgmt.resource.resources.v2018_02_01.operations.ResourcesOperations - :ivar resource_groups: ResourceGroups operations + :ivar resource_groups: ResourceGroupsOperations operations :vartype resource_groups: azure.mgmt.resource.resources.v2018_02_01.operations.ResourceGroupsOperations - :ivar tags: Tags operations + :ivar tags: TagsOperations operations :vartype tags: azure.mgmt.resource.resources.v2018_02_01.operations.TagsOperations - :ivar deployment_operations: DeploymentOperations operations - :vartype deployment_operations: azure.mgmt.resource.resources.v2018_02_01.operations.DeploymentOperations - - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` + :ivar deployment_operations: DeploymentOperationsOperations operations + :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. """ def __init__( - self, credentials, subscription_id, base_url=None): - - self.config = ResourceManagementClientConfiguration(credentials, subscription_id, base_url) - super(ResourceManagementClient, self).__init__(self.config.credentials, self.config) + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = 'https://management.azure.com' + self._config = ResourceManagementClientConfiguration(credential, 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.api_version = '2018-02-01' self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self.deployments = DeploymentsOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.providers = ProvidersOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.resources = ResourcesOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.resource_groups = ResourceGroupsOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.tags = TagsOperations( - self._client, self.config, self._serialize, self._deserialize) - self.deployment_operations = DeploymentOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) + self.deployment_operations = DeploymentOperationsOperations( + self._client, self._config, self._serialize, self._deserialize) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> ResourceManagementClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) 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 new file mode 100644 index 000000000000..7f9b1bac71c5 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/__init__.py @@ -0,0 +1,10 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._resource_management_client_async import ResourceManagementClient +__all__ = ['ResourceManagementClient'] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/_configuration_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/_configuration_async.py new file mode 100644 index 000000000000..747bf5d68663 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/_configuration_async.py @@ -0,0 +1,65 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + +VERSION = "unknown" + +class ResourceManagementClientConfiguration(Configuration): + """Configuration for ResourceManagementClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :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 + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + 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 + self.api_version = "2018-02-01" + self.credential_scopes = ['https://management.azure.com/.default'] + self.credential_scopes.extend(kwargs.pop('credential_scopes', [])) + kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs: Any + ) -> None: + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + 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) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/_resource_management_client_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/_resource_management_client_async.py new file mode 100644 index 000000000000..1d2877bb2aec --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/_resource_management_client_async.py @@ -0,0 +1,84 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, Optional + +from azure.mgmt.core import AsyncARMPipelineClient +from msrest import Deserializer, Serializer + +from ._configuration_async import ResourceManagementClientConfiguration +from .operations_async import DeploymentsOperations +from .operations_async import ProvidersOperations +from .operations_async import ResourcesOperations +from .operations_async import ResourceGroupsOperations +from .operations_async import TagsOperations +from .operations_async import DeploymentOperationsOperations +from .. import models + + +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.aio.operations_async.DeploymentsOperations + :ivar providers: ProvidersOperations operations + :vartype providers: azure.mgmt.resource.resources.v2018_02_01.aio.operations_async.ProvidersOperations + :ivar resources: ResourcesOperations operations + :vartype resources: azure.mgmt.resource.resources.v2018_02_01.aio.operations_async.ResourcesOperations + :ivar resource_groups: ResourceGroupsOperations operations + :vartype resource_groups: azure.mgmt.resource.resources.v2018_02_01.aio.operations_async.ResourceGroupsOperations + :ivar tags: TagsOperations operations + :vartype tags: azure.mgmt.resource.resources.v2018_02_01.aio.operations_async.TagsOperations + :ivar deployment_operations: DeploymentOperationsOperations operations + :vartype deployment_operations: azure.mgmt.resource.resources.v2018_02_01.aio.operations_async.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. + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: Optional[str] = None, + **kwargs: 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) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + + self.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 close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "ResourceManagementClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/operations_async/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/operations_async/__init__.py new file mode 100644 index 000000000000..c5133656c811 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/operations_async/__init__.py @@ -0,0 +1,23 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._deployments_operations_async import DeploymentsOperations +from ._providers_operations_async import ProvidersOperations +from ._resources_operations_async import ResourcesOperations +from ._resource_groups_operations_async import ResourceGroupsOperations +from ._tags_operations_async import TagsOperations +from ._deployment_operations_operations_async import DeploymentOperationsOperations + +__all__ = [ + 'DeploymentsOperations', + 'ProvidersOperations', + 'ResourcesOperations', + 'ResourceGroupsOperations', + 'TagsOperations', + 'DeploymentOperationsOperations', +] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/operations_async/_deployment_operations_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/operations_async/_deployment_operations_operations_async.py new file mode 100644 index 000000000000..fb734a04775c --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/operations_async/_deployment_operations_operations_async.py @@ -0,0 +1,178 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import 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 ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class DeploymentOperationsOperations: + """DeploymentOperationsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2018_02_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def get( + self, + resource_group_name: str, + deployment_name: str, + operation_id: str, + **kwargs + ) -> "models.DeploymentOperation": + """Gets a deployments operation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param operation_id: The ID of the operation to get. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentOperation or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentOperation + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentOperation"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-02-01" + + # Construct URL + url = self.get.metadata['url'] # type: 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentOperation', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + def list( + self, + resource_group_name: str, + deployment_name: str, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.DeploymentOperationsListResult"]: + """Gets all deployments operations for a deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment with the operation to get. + :type deployment_name: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-02-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentOperationsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/operations_async/_deployments_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/operations_async/_deployments_operations_async.py new file mode 100644 index 000000000000..912eacd73545 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/operations_async/_deployments_operations_async.py @@ -0,0 +1,670 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.polling import AsyncNoPolling, AsyncPollingMethod, async_poller +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class DeploymentsOperations: + """DeploymentsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2018_02_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def _delete_initial( + self, + resource_group_name: str, + deployment_name: str, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def delete( + self, + resource_group_name: str, + deployment_name: str, + **kwargs + ) -> None: + """A template deployment that is currently running cannot be deleted. Deleting a template deployment removes the associated deployment operations. Deleting a template deployment does not affect the state of the resource group. This is an asynchronous operation that returns a status of 202 until the template deployment is successfully deleted. The Location response header contains the URI that is used to obtain the status of the process. While the process is running, a call to the URI in the Location header returns a status of 202. When the process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. + + Deletes a deployment from the deployment history. + + :param resource_group_name: The name of the resource group with the deployment to delete. The + name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment to delete. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def check_existence( + self, + resource_group_name: str, + deployment_name: str, + **kwargs + ) -> None: + """Checks whether the deployment exists. + + :param resource_group_name: The name of the resource group with the deployment to check. The + name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment to check. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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] + + # Construct and send request + 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 + + if response.status_code not in [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + 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, + deployment_name: str, + properties: "models.DeploymentProperties", + **kwargs + ) -> "models.DeploymentExtended": + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.Deployment(properties=properties) + api_version = "2018-02-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def create_or_update( + self, + resource_group_name: str, + deployment_name: str, + properties: "models.DeploymentProperties", + **kwargs + ) -> "models.DeploymentExtended": + """You can provide the template and parameters directly in the request or link to JSON files. + + Deploys resources to a resource group. + + :param resource_group_name: The name of the resource group to deploy the resources to. The name + is case insensitive. The resource group must already exist. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param properties: The deployment properties. + :type properties: ~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentProperties + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: DeploymentExtended + :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentExtended + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + properties=properties, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def get( + self, + resource_group_name: str, + deployment_name: str, + **kwargs + ) -> "models.DeploymentExtended": + """Gets a deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment to get. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExtended or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentExtended + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-02-01" + + # Construct URL + url = self.get.metadata['url'] # type: 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def cancel( + self, + resource_group_name: str, + deployment_name: str, + **kwargs + ) -> None: + """You can cancel a deployment only if the provisioningState is Accepted or Running. After the deployment is canceled, the provisioningState is set to Canceled. Canceling a template deployment stops the currently running template deployment and leaves the resource group partially deployed. + + Cancels a currently running template deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment to cancel. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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] + + # Construct and send request + 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 [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + cancel.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + + async def validate( + self, + resource_group_name: str, + deployment_name: str, + properties: "models.DeploymentProperties", + **kwargs + ) -> "models.DeploymentValidateResult": + """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param properties: The deployment properties. + :type properties: ~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentProperties + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentValidateResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentValidateResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.Deployment(properties=properties) + api_version = "2018-02-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 400]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + + if response.status_code == 400: + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + validate.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + async def export_template( + self, + resource_group_name: str, + deployment_name: str, + **kwargs + ) -> "models.DeploymentExportResult": + """Exports the template used for specified deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment from which to get the template. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentExportResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExportResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-02-01" + + # 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'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + def list_by_resource_group( + self, + resource_group_name: str, + filter: Optional[str] = None, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.DeploymentListResult"]: + """Get all the deployments for a resource group. + + :param resource_group_name: The name of the resource group with the deployments to get. The + name is case insensitive. + :type resource_group_name: str + :param filter: The filter to apply on the operation. For example, you can use + $filter=provisioningState eq '{state}'. + :type filter: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-02-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + 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 + + async def calculate_template_hash( + self, + template: object, + **kwargs + ) -> "models.TemplateHashResult": + """Calculate the hash of the given template. + + :param template: The template provided to calculate hash. + :type template: object + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateHashResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.TemplateHashResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TemplateHashResult"] + error_map = {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.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'] = 'application/json' + + # Construct and send request + 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) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('TemplateHashResult', pipeline_response) + + if cls: + 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_async/_providers_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/operations_async/_providers_operations_async.py new file mode 100644 index 000000000000..707c9c0c3a71 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/operations_async/_providers_operations_async.py @@ -0,0 +1,279 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import 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 ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ProvidersOperations: + """ProvidersOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2018_02_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def unregister( + self, + resource_provider_namespace: str, + **kwargs + ) -> "models.Provider": + """Unregisters a subscription from a resource provider. + + :param resource_provider_namespace: The namespace of the resource provider to unregister. + :type resource_provider_namespace: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Provider or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.Provider + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Provider"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-02-01" + + # 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'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Provider', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + unregister.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister'} # type: ignore + + async def register( + self, + resource_provider_namespace: str, + **kwargs + ) -> "models.Provider": + """Registers a subscription with a resource provider. + + :param resource_provider_namespace: The namespace of the resource provider to register. + :type resource_provider_namespace: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Provider or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.Provider + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Provider"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-02-01" + + # 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'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Provider', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + register.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register'} # type: ignore + + def list( + self, + top: Optional[int] = None, + expand: Optional[str] = None, + **kwargs + ) -> AsyncIterable["models.ProviderListResult"]: + """Gets all resource providers for a subscription. + + :param top: The number of results to return. If null is passed returns all deployments. + :type top: int + :param expand: The properties to include in the results. For example, use &$expand=metadata in + the query string to retrieve resource provider metadata. To include property aliases in + response, use $expand=resourceTypes/aliases. + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of ProviderListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-02-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ProviderListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers'} # type: ignore + + async def get( + self, + resource_provider_namespace: str, + expand: Optional[str] = None, + **kwargs + ) -> "models.Provider": + """Gets the specified resource provider. + + :param resource_provider_namespace: The namespace of the resource provider. + :type resource_provider_namespace: str + :param expand: The $expand query parameter. For example, to include property aliases in + response, use $expand=resourceTypes/aliases. + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Provider or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.Provider + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Provider"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-02-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Provider', pipeline_response) + + if cls: + 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_async/_resource_groups_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/operations_async/_resource_groups_operations_async.py new file mode 100644 index 000000000000..d759c7656579 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/operations_async/_resource_groups_operations_async.py @@ -0,0 +1,501 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, List, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.polling import AsyncNoPolling, AsyncPollingMethod, async_poller +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ResourceGroupsOperations: + """ResourceGroupsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2018_02_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def check_existence( + self, + resource_group_name: str, + **kwargs + ) -> None: + """Checks whether a resource group exists. + + :param resource_group_name: The name of the resource group to check. 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: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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] + + # Construct and send request + 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 + + if response.status_code not in [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + async def create_or_update( + self, + resource_group_name: str, + parameters: "models.ResourceGroup", + **kwargs + ) -> "models.ResourceGroup": + """Creates or updates a resource group. + + :param resource_group_name: The name of the resource group to create or update. + :type resource_group_name: str + :param parameters: Parameters supplied to the create or update a resource group. + :type parameters: ~azure.mgmt.resource.resources.v2018_02_01.models.ResourceGroup + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.ResourceGroup + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceGroup"] + error_map = {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.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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ResourceGroup', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ResourceGroup', pipeline_response) + + if cls: + 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, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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] + + # Construct and send request + 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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + async def delete( + self, + resource_group_name: str, + **kwargs + ) -> None: + """When you delete a resource group, all of its resources are also deleted. Deleting a resource group deletes all of its template deployments and currently stored operations. + + Deletes a resource group. + + :param resource_group_name: The name of the resource group to delete. 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 + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + async def get( + self, + resource_group_name: str, + **kwargs + ) -> "models.ResourceGroup": + """Gets a resource group. + + :param resource_group_name: The name of the resource group to get. 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: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.ResourceGroup + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceGroup"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-02-01" + + # Construct URL + url = self.get.metadata['url'] # type: 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ResourceGroup', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + async def update( + self, + resource_group_name: str, + parameters: "models.ResourceGroupPatchable", + **kwargs + ) -> "models.ResourceGroup": + """Resource groups can be updated through a simple PATCH operation to a group address. The format of the request is the same as that for creating a resource group. If a field is unspecified, the current value is retained. + + Updates a resource group. + + :param resource_group_name: The name of the resource group to update. The name is case + insensitive. + :type resource_group_name: str + :param parameters: Parameters supplied to update a resource group. + :type parameters: ~azure.mgmt.resource.resources.v2018_02_01.models.ResourceGroupPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.ResourceGroup + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceGroup"] + error_map = {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.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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ResourceGroup', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + async def export_template( + self, + resource_group_name: str, + resources: Optional[List[str]] = None, + options: Optional[str] = None, + **kwargs + ) -> "models.ResourceGroupExportResult": + """Captures the specified resource group as a template. + + :param resource_group_name: The name of the resource group to export as a template. + :type resource_group_name: str + :param 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', + 'SkipResourceNameParameterization', 'SkipAllParameterization'. + :type options: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroupExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.ResourceGroupExportResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceGroupExportResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.ExportTemplateRequest(resources=resources, options=options) + api_version = "2018-02-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ResourceGroupExportResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate'} # type: ignore + + def list( + self, + filter: Optional[str] = None, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.ResourceGroupListResult"]: + """Gets all the resource groups for a subscription. + + :param filter: The filter to apply on the operation. + :type filter: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-02-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ResourceGroupListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/operations_async/_resources_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/operations_async/_resources_operations_async.py new file mode 100644 index 000000000000..e43cb66da250 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/operations_async/_resources_operations_async.py @@ -0,0 +1,1282 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, List, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.polling import AsyncNoPolling, AsyncPollingMethod, async_poller +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ResourcesOperations: + """ResourcesOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2018_02_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list_by_resource_group( + self, + resource_group_name: str, + filter: Optional[str] = None, + expand: Optional[str] = None, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.ResourceListResult"]: + """Get all the resources for a resource group. + + :param resource_group_name: The resource group with the resources to get. + :type resource_group_name: str + :param filter: The filter to apply on the operation. + :type filter: str + :param expand: Comma-separated list of additional properties to be included in the response. + Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, + ``$expand=createdTime,changedTime``. + :type expand: str + :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 ResourceListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-02-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ResourceListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources'} # type: ignore + + async def _move_resources_initial( + self, + source_resource_group_name: str, + resources: Optional[List[str]] = None, + target_resource_group: Optional[str] = None, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.ResourcesMoveInfo(resources=resources, target_resource_group=target_resource_group) + 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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + + # Construct and send request + 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 + + if response.status_code not in [202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore + + async def move_resources( + self, + source_resource_group_name: str, + resources: Optional[List[str]] = None, + target_resource_group: Optional[str] = None, + **kwargs + ) -> None: + """The resources to move must be in the same source resource group. The target resource group may be in a different subscription. When moving resources, both the source group and the target group are locked for the duration of the operation. Write and delete operations are blocked on the groups until the move completes. + + Moves resources from one resource group to another resource group. + + :param source_resource_group_name: The name of the resource group containing the resources to + move. + :type source_resource_group_name: str + :param resources: The IDs of the resources. + :type resources: list[str] + :param target_resource_group: The target resource group. + :type target_resource_group: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._move_resources_initial( + source_resource_group_name=source_resource_group_name, + resources=resources, + target_resource_group=target_resource_group, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore + + async def _validate_move_resources_initial( + self, + source_resource_group_name: str, + resources: Optional[List[str]] = None, + target_resource_group: Optional[str] = None, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.ResourcesMoveInfo(resources=resources, target_resource_group=target_resource_group) + 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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + + # Construct and send request + 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 + + if response.status_code not in [202, 204, 409]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _validate_move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} # type: ignore + + async def validate_move_resources( + self, + source_resource_group_name: str, + resources: Optional[List[str]] = None, + target_resource_group: Optional[str] = None, + **kwargs + ) -> None: + """This operation checks whether the specified resources can be moved to the target. The resources to move must be in the same source resource group. The target resource group may be in a different subscription. If validation succeeds, it returns HTTP response code 204 (no content). If validation fails, it returns HTTP response code 409 (Conflict) with an error message. Retrieve the URL in the Location header value to check the result of the long-running operation. + + Validates whether resources can be moved from one resource group to another resource group. + + :param source_resource_group_name: The name of the resource group containing the resources to + validate for move. + :type source_resource_group_name: str + :param resources: The IDs of the resources. + :type resources: list[str] + :param target_resource_group: The target resource group. + :type target_resource_group: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._validate_move_resources_initial( + source_resource_group_name=source_resource_group_name, + resources=resources, + target_resource_group=target_resource_group, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + validate_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} # type: ignore + + def list( + self, + filter: Optional[str] = None, + expand: Optional[str] = None, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.ResourceListResult"]: + """Get all the resources in a subscription. + + :param filter: The filter to apply on the operation. + :type filter: str + :param expand: The $expand query parameter. + :type expand: str + :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 ResourceListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-02-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ResourceListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resources'} # type: ignore + + async def check_existence( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + **kwargs + ) -> None: + """Checks whether a resource exists. + + :param resource_group_name: The name of the resource group containing the resource to check. + The name is case insensitive. + :type resource_group_name: str + :param resource_provider_namespace: The resource provider of the resource to check. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. + :type parent_resource_path: str + :param resource_type: The resource type. + :type resource_type: str + :param resource_name: The name of the resource to check whether it exists. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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\._\(\)]+$'), + 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), + 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_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] + + # Construct and send request + 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 + + if response.status_code not in [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + 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, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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\._\(\)]+$'), + 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), + 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + async def delete( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + **kwargs + ) -> None: + """Deletes a resource. + + :param resource_group_name: The name of the resource group that contains the resource to + delete. The name is case insensitive. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. + :type parent_resource_path: str + :param resource_type: The resource type. + :type resource_type: str + :param resource_name: The name of the resource to delete. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._delete_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, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + parameters: "models.GenericResource", + **kwargs + ) -> "models.GenericResource": + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {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._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'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 201, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('GenericResource', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + async def create_or_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + parameters: "models.GenericResource", + **kwargs + ) -> "models.GenericResource": + """Creates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to create. + :type resource_type: str + :param resource_name: The name of the resource to create. + :type resource_name: str + :param parameters: Parameters for creating or updating the resource. + :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 polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: GenericResource + :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._create_or_update_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, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + 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, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + parameters: "models.GenericResource", + **kwargs + ) -> "models.GenericResource": + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {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._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'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + async def update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + parameters: "models.GenericResource", + **kwargs + ) -> "models.GenericResource": + """Updates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to update. + :type resource_type: str + :param resource_name: The name of the resource to update. + :type resource_name: str + :param parameters: Parameters for updating the resource. + :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 polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: GenericResource + :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._update_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, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + async def get( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + **kwargs + ) -> "models.GenericResource": + """Gets a resource. + + :param resource_group_name: The name of the resource group containing the resource to get. The + name is case insensitive. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. + :type parent_resource_path: str + :param resource_type: The resource type of the resource. + :type resource_type: str + :param resource_name: The name of the resource to get. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GenericResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-02-01" + + # Construct URL + url = self.get.metadata['url'] # type: 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + async def check_existence_by_id( + self, + resource_id: str, + **kwargs + ) -> None: + """Checks by ID whether a resource exists. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + :type resource_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-02-01" + + # 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] + + # Construct and send request + 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 + + if response.status_code not in [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + 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, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-02-01" + + # 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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + async def delete_by_id( + self, + resource_id: str, + **kwargs + ) -> None: + """Deletes a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + :type resource_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._delete_by_id_initial( + resource_id=resource_id, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + delete_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + + async def _create_or_update_by_id_initial( + self, + resource_id: str, + parameters: "models.GenericResource", + **kwargs + ) -> "models.GenericResource": + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {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._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) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 201, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('GenericResource', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + async def create_or_update_by_id( + self, + resource_id: str, + parameters: "models.GenericResource", + **kwargs + ) -> "models.GenericResource": + """Create a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + :type resource_id: str + :param parameters: Create or update resource parameters. + :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 polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: GenericResource + :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._create_or_update_by_id_initial( + resource_id=resource_id, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + create_or_update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + + async def _update_by_id_initial( + self, + resource_id: str, + parameters: "models.GenericResource", + **kwargs + ) -> "models.GenericResource": + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {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._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) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + async def update_by_id( + self, + resource_id: str, + parameters: "models.GenericResource", + **kwargs + ) -> "models.GenericResource": + """Updates a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + :type resource_id: str + :param parameters: Update resource parameters. + :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 polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: GenericResource + :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._update_by_id_initial( + resource_id=resource_id, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + + async def get_by_id( + self, + resource_id: str, + **kwargs + ) -> "models.GenericResource": + """Gets a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + :type resource_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GenericResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-02-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + 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_async/_tags_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/operations_async/_tags_operations_async.py new file mode 100644 index 000000000000..8f768135dd07 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/aio/operations_async/_tags_operations_async.py @@ -0,0 +1,327 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import 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 ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class TagsOperations: + """TagsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2018_02_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def delete_value( + self, + tag_name: str, + tag_value: str, + **kwargs + ) -> None: + """Deletes a tag value. + + :param tag_name: The name of the tag. + :type tag_name: str + :param tag_value: The value of the tag to delete. + :type tag_value: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore + + async def create_or_update_value( + self, + tag_name: str, + tag_value: str, + **kwargs + ) -> "models.TagValue": + """Creates a tag value. The name of the tag must already exist. + + :param tag_name: The name of the tag. + :type tag_name: str + :param tag_value: The value of the tag to create. + :type tag_value: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagValue or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.TagValue + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TagValue"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-02-01" + + # 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'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('TagValue', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('TagValue', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore + + async def create_or_update( + self, + tag_name: str, + **kwargs + ) -> "models.TagDetails": + """The tag name can have a maximum of 512 characters and is case insensitive. Tag names created by Azure have prefixes of microsoft, azure, or windows. You cannot create tags with one of these prefixes. + + Creates a tag in the subscription. + + :param tag_name: The name of the tag to create. + :type tag_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagDetails or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.TagDetails + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TagDetails"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-02-01" + + # 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'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('TagDetails', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('TagDetails', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore + + async def delete( + self, + tag_name: str, + **kwargs + ) -> None: + """You must remove all values from a resource tag before you can delete it. + + Deletes a tag from the subscription. + + :param tag_name: The name of the tag. + :type tag_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore + + def list( + self, + **kwargs + ) -> AsyncIterable["models.TagsListResult"]: + """Gets the names and values of all resource tags that are defined in a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of TagsListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-02-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('TagsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/models/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/models/__init__.py index ab9bcea6f39e..359df8169265 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/models/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/models/__init__.py @@ -1,12 +1,9 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- try: @@ -19,8 +16,10 @@ from ._models_py3 import DeploymentExportResult from ._models_py3 import DeploymentExtended from ._models_py3 import DeploymentExtendedFilter + from ._models_py3 import DeploymentListResult from ._models_py3 import DeploymentOperation from ._models_py3 import DeploymentOperationProperties + from ._models_py3 import DeploymentOperationsListResult from ._models_py3 import DeploymentProperties from ._models_py3 import DeploymentPropertiesExtended from ._models_py3 import DeploymentValidateResult @@ -37,13 +36,16 @@ from ._models_py3 import ParametersLink from ._models_py3 import Plan from ._models_py3 import Provider + from ._models_py3 import ProviderListResult from ._models_py3 import ProviderResourceType from ._models_py3 import Resource from ._models_py3 import ResourceGroup from ._models_py3 import ResourceGroupExportResult from ._models_py3 import ResourceGroupFilter + from ._models_py3 import ResourceGroupListResult from ._models_py3 import ResourceGroupPatchable from ._models_py3 import ResourceGroupProperties + from ._models_py3 import ResourceListResult from ._models_py3 import ResourceManagementErrorWithDetails from ._models_py3 import ResourceProviderOperationDisplayProperties from ._models_py3 import ResourcesMoveInfo @@ -52,61 +54,63 @@ from ._models_py3 import TagCount from ._models_py3 import TagDetails from ._models_py3 import TagValue + from ._models_py3 import TagsListResult from ._models_py3 import TargetResource from ._models_py3 import TemplateHashResult from ._models_py3 import TemplateLink except (SyntaxError, ImportError): - from ._models import AliasPathType - from ._models import AliasType - from ._models import BasicDependency - from ._models import DebugSetting - from ._models import Dependency - from ._models import Deployment - from ._models import DeploymentExportResult - from ._models import DeploymentExtended - from ._models import DeploymentExtendedFilter - from ._models import DeploymentOperation - from ._models import DeploymentOperationProperties - from ._models import DeploymentProperties - from ._models import DeploymentPropertiesExtended - from ._models import DeploymentValidateResult - from ._models import ErrorAdditionalInfo - from ._models import ErrorResponse - from ._models import ExportTemplateRequest - from ._models import GenericResource - from ._models import GenericResourceExpanded - from ._models import GenericResourceFilter - from ._models import HttpMessage - from ._models import Identity - from ._models import OnErrorDeployment - from ._models import OnErrorDeploymentExtended - from ._models import ParametersLink - from ._models import Plan - from ._models import Provider - from ._models import ProviderResourceType - from ._models import Resource - from ._models import ResourceGroup - from ._models import ResourceGroupExportResult - from ._models import ResourceGroupFilter - from ._models import ResourceGroupPatchable - from ._models import ResourceGroupProperties - from ._models import ResourceManagementErrorWithDetails - from ._models import ResourceProviderOperationDisplayProperties - from ._models import ResourcesMoveInfo - from ._models import Sku - from ._models import SubResource - from ._models import TagCount - from ._models import TagDetails - from ._models import TagValue - from ._models import TargetResource - from ._models import TemplateHashResult - from ._models import TemplateLink -from ._paged_models import DeploymentExtendedPaged -from ._paged_models import DeploymentOperationPaged -from ._paged_models import GenericResourceExpandedPaged -from ._paged_models import ProviderPaged -from ._paged_models import ResourceGroupPaged -from ._paged_models import TagDetailsPaged + from ._models import AliasPathType # type: ignore + from ._models import AliasType # type: ignore + from ._models import BasicDependency # type: ignore + from ._models import DebugSetting # type: ignore + from ._models import Dependency # type: ignore + from ._models import Deployment # type: ignore + from ._models import DeploymentExportResult # type: ignore + from ._models import DeploymentExtended # type: ignore + from ._models import DeploymentExtendedFilter # type: ignore + from ._models import DeploymentListResult # type: ignore + from ._models import DeploymentOperation # type: ignore + from ._models import DeploymentOperationProperties # type: ignore + from ._models import DeploymentOperationsListResult # type: ignore + from ._models import DeploymentProperties # type: ignore + from ._models import DeploymentPropertiesExtended # type: ignore + from ._models import DeploymentValidateResult # type: ignore + from ._models import ErrorAdditionalInfo # type: ignore + from ._models import ErrorResponse # type: ignore + from ._models import ExportTemplateRequest # type: ignore + from ._models import GenericResource # type: ignore + from ._models import GenericResourceExpanded # type: ignore + from ._models import GenericResourceFilter # type: ignore + from ._models import HttpMessage # type: ignore + from ._models import Identity # type: ignore + from ._models import OnErrorDeployment # type: ignore + from ._models import OnErrorDeploymentExtended # type: ignore + from ._models import ParametersLink # type: ignore + from ._models import Plan # type: ignore + from ._models import Provider # type: ignore + from ._models import ProviderListResult # type: ignore + from ._models import ProviderResourceType # type: ignore + from ._models import Resource # type: ignore + from ._models import ResourceGroup # type: ignore + from ._models import ResourceGroupExportResult # type: ignore + from ._models import ResourceGroupFilter # type: ignore + from ._models import ResourceGroupListResult # type: ignore + from ._models import ResourceGroupPatchable # type: ignore + from ._models import ResourceGroupProperties # type: ignore + from ._models import ResourceListResult # type: ignore + from ._models import ResourceManagementErrorWithDetails # type: ignore + from ._models import ResourceProviderOperationDisplayProperties # type: ignore + from ._models import ResourcesMoveInfo # type: ignore + from ._models import Sku # type: ignore + from ._models import SubResource # type: ignore + from ._models import TagCount # type: ignore + from ._models import TagDetails # type: ignore + from ._models import TagValue # type: ignore + from ._models import TagsListResult # type: ignore + from ._models import TargetResource # type: ignore + from ._models import TemplateHashResult # type: ignore + from ._models import TemplateLink # type: ignore + from ._resource_management_client_enums import ( DeploymentMode, OnErrorDeploymentType, @@ -123,8 +127,10 @@ 'DeploymentExportResult', 'DeploymentExtended', 'DeploymentExtendedFilter', + 'DeploymentListResult', 'DeploymentOperation', 'DeploymentOperationProperties', + 'DeploymentOperationsListResult', 'DeploymentProperties', 'DeploymentPropertiesExtended', 'DeploymentValidateResult', @@ -141,13 +147,16 @@ 'ParametersLink', 'Plan', 'Provider', + 'ProviderListResult', 'ProviderResourceType', 'Resource', 'ResourceGroup', 'ResourceGroupExportResult', 'ResourceGroupFilter', + 'ResourceGroupListResult', 'ResourceGroupPatchable', 'ResourceGroupProperties', + 'ResourceListResult', 'ResourceManagementErrorWithDetails', 'ResourceProviderOperationDisplayProperties', 'ResourcesMoveInfo', @@ -156,15 +165,10 @@ 'TagCount', 'TagDetails', 'TagValue', + 'TagsListResult', 'TargetResource', 'TemplateHashResult', 'TemplateLink', - 'DeploymentExtendedPaged', - 'ProviderPaged', - 'GenericResourceExpandedPaged', - 'ResourceGroupPaged', - 'TagDetailsPaged', - 'DeploymentOperationPaged', 'DeploymentMode', 'OnErrorDeploymentType', 'ResourceIdentityType', 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 21cbfd150f2c..3b62d2d1828f 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 @@ -1,20 +1,16 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.serialization import Model -from msrest.exceptions import HttpOperationError +import msrest.serialization -class AliasPathType(Model): - """The type of the paths for alias. . +class AliasPathType(msrest.serialization.Model): + """The type of the paths for alias. :param path: The path of an alias. :type path: str @@ -27,20 +23,22 @@ class AliasPathType(Model): 'api_versions': {'key': 'apiVersions', 'type': '[str]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(AliasPathType, self).__init__(**kwargs) self.path = kwargs.get('path', None) self.api_versions = kwargs.get('api_versions', None) -class AliasType(Model): - """The alias type. . +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] + :type paths: list[~azure.mgmt.resource.resources.v2018_02_01.models.AliasPathType] """ _attribute_map = { @@ -48,13 +46,16 @@ class AliasType(Model): 'paths': {'key': 'paths', 'type': '[AliasPathType]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(AliasType, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.paths = kwargs.get('paths', None) -class BasicDependency(Model): +class BasicDependency(msrest.serialization.Model): """Deployment dependency information. :param id: The ID of the dependency. @@ -71,52 +72,25 @@ class BasicDependency(Model): 'resource_name': {'key': 'resourceName', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(BasicDependency, self).__init__(**kwargs) self.id = kwargs.get('id', None) self.resource_type = kwargs.get('resource_type', None) self.resource_name = kwargs.get('resource_name', None) -class CloudError(Model): - """An error response for a resource management request. - - :param error: - :type error: - ~azure.mgmt.resource.resources.v2018_02_01.models.ErrorResponse - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorResponse'}, - } - - def __init__(self, **kwargs): - super(CloudError, self).__init__(**kwargs) - self.error = kwargs.get('error', None) - - -class CloudErrorException(HttpOperationError): - """Server responsed with exception of type: 'CloudError'. - - :param deserialize: A deserializer - :param response: Server response to be deserialized. - """ - - def __init__(self, deserialize, response, *args): - - super(CloudErrorException, self).__init__(deserialize, response, 'CloudError', *args) - - -class DebugSetting(Model): +class DebugSetting(msrest.serialization.Model): """DebugSetting. - :param 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. + :param 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 """ @@ -124,17 +98,19 @@ class DebugSetting(Model): 'detail_level': {'key': 'detailLevel', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DebugSetting, self).__init__(**kwargs) self.detail_level = kwargs.get('detail_level', None) -class Dependency(Model): +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] + :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. @@ -150,7 +126,10 @@ class Dependency(Model): 'resource_name': {'key': 'resourceName', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Dependency, self).__init__(**kwargs) self.depends_on = kwargs.get('depends_on', None) self.id = kwargs.get('id', None) @@ -158,14 +137,13 @@ def __init__(self, **kwargs): self.resource_name = kwargs.get('resource_name', None) -class Deployment(Model): +class Deployment(msrest.serialization.Model): """Deployment operation parameters. 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 + :type properties: ~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentProperties """ _validation = { @@ -176,13 +154,16 @@ class Deployment(Model): 'properties': {'key': 'properties', 'type': 'DeploymentProperties'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Deployment, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) + self.properties = kwargs['properties'] -class DeploymentExportResult(Model): - """The deployment export result. . +class DeploymentExportResult(msrest.serialization.Model): + """The deployment export result. :param template: The template content. :type template: object @@ -192,16 +173,18 @@ class DeploymentExportResult(Model): 'template': {'key': 'template', 'type': 'object'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentExportResult, self).__init__(**kwargs) self.template = kwargs.get('template', None) -class DeploymentExtended(Model): +class DeploymentExtended(msrest.serialization.Model): """Deployment information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. @@ -225,14 +208,17 @@ class DeploymentExtended(Model): 'properties': {'key': 'properties', 'type': 'DeploymentPropertiesExtended'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentExtended, self).__init__(**kwargs) self.id = None - self.name = kwargs.get('name', None) + self.name = kwargs['name'] self.properties = kwargs.get('properties', None) -class DeploymentExtendedFilter(Model): +class DeploymentExtendedFilter(msrest.serialization.Model): """Deployment filter. :param provisioning_state: The provisioning state. @@ -243,16 +229,47 @@ class DeploymentExtendedFilter(Model): 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentExtendedFilter, self).__init__(**kwargs) self.provisioning_state = kwargs.get('provisioning_state', None) -class DeploymentOperation(Model): +class DeploymentListResult(msrest.serialization.Model): + """List of deployments. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[DeploymentExtended]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(DeploymentListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = None + + +class DeploymentOperation(msrest.serialization.Model): """Deployment operation information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Full deployment operation ID. :vartype id: str @@ -274,23 +291,25 @@ class DeploymentOperation(Model): 'properties': {'key': 'properties', 'type': 'DeploymentOperationProperties'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentOperation, self).__init__(**kwargs) self.id = None self.operation_id = None self.properties = kwargs.get('properties', None) -class DeploymentOperationProperties(Model): +class DeploymentOperationProperties(msrest.serialization.Model): """Deployment operation properties. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar provisioning_state: The state of the provisioning. :vartype provisioning_state: str :ivar timestamp: The date and time of the operation. - :vartype timestamp: datetime + :vartype timestamp: ~datetime.datetime :ivar service_request_id: Deployment operation service request id. :vartype service_request_id: str :ivar status_code: Operation status code. @@ -298,14 +317,11 @@ class DeploymentOperationProperties(Model): :ivar status_message: Operation status message. :vartype status_message: object :ivar target_resource: The target resource. - :vartype target_resource: - ~azure.mgmt.resource.resources.v2018_02_01.models.TargetResource + :vartype target_resource: ~azure.mgmt.resource.resources.v2018_02_01.models.TargetResource :ivar request: The HTTP request message. - :vartype request: - ~azure.mgmt.resource.resources.v2018_02_01.models.HttpMessage + :vartype request: ~azure.mgmt.resource.resources.v2018_02_01.models.HttpMessage :ivar response: The HTTP response message. - :vartype response: - ~azure.mgmt.resource.resources.v2018_02_01.models.HttpMessage + :vartype response: ~azure.mgmt.resource.resources.v2018_02_01.models.HttpMessage """ _validation = { @@ -330,7 +346,10 @@ class DeploymentOperationProperties(Model): 'response': {'key': 'response', 'type': 'HttpMessage'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentOperationProperties, self).__init__(**kwargs) self.provisioning_state = None self.timestamp = None @@ -342,48 +361,68 @@ def __init__(self, **kwargs): self.response = None -class DeploymentProperties(Model): +class DeploymentOperationsListResult(msrest.serialization.Model): + """List of deployment operations. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[DeploymentOperation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(DeploymentOperationsListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = None + + +class DeploymentProperties(msrest.serialization.Model): """Deployment properties. 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 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. + :param 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: object - :param 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. 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. + :param 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. + 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: object - :param 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 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 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 + 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 + :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 + :type on_error_deployment: ~azure.mgmt.resource.resources.v2018_02_01.models.OnErrorDeployment """ _validation = { @@ -395,64 +434,57 @@ class DeploymentProperties(Model): 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, 'parameters': {'key': 'parameters', 'type': 'object'}, 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, - 'mode': {'key': 'mode', 'type': 'DeploymentMode'}, + 'mode': {'key': 'mode', 'type': 'str'}, 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, 'on_error_deployment': {'key': 'onErrorDeployment', 'type': 'OnErrorDeployment'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentProperties, self).__init__(**kwargs) self.template = kwargs.get('template', None) self.template_link = kwargs.get('template_link', None) self.parameters = kwargs.get('parameters', None) self.parameters_link = kwargs.get('parameters_link', None) - self.mode = kwargs.get('mode', None) + self.mode = kwargs['mode'] self.debug_setting = kwargs.get('debug_setting', None) self.on_error_deployment = kwargs.get('on_error_deployment', None) -class DeploymentPropertiesExtended(Model): +class DeploymentPropertiesExtended(msrest.serialization.Model): """Deployment properties with additional details. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :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 + :vartype timestamp: ~datetime.datetime :param outputs: Key/value pairs that represent deployment output. :type outputs: object - :param providers: The list of resource providers needed for the - deployment. - :type providers: - list[~azure.mgmt.resource.resources.v2018_02_01.models.Provider] + :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 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: object - :param 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. + :param 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: object - :param 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 include: 'Incremental', 'Complete' - :type mode: str or - ~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentMode + :param 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 + 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 + :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.OnErrorDeploymentExtended @@ -475,12 +507,15 @@ class DeploymentPropertiesExtended(Model): 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, 'parameters': {'key': 'parameters', 'type': 'object'}, 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, - 'mode': {'key': 'mode', 'type': 'DeploymentMode'}, + 'mode': {'key': 'mode', 'type': 'str'}, 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, 'on_error_deployment': {'key': 'onErrorDeployment', 'type': 'OnErrorDeploymentExtended'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentPropertiesExtended, self).__init__(**kwargs) self.provisioning_state = None self.correlation_id = None @@ -497,7 +532,7 @@ def __init__(self, **kwargs): self.on_error_deployment = kwargs.get('on_error_deployment', None) -class DeploymentValidateResult(Model): +class DeploymentValidateResult(msrest.serialization.Model): """Information from validate template deployment response. :param error: Validation error. @@ -513,17 +548,19 @@ class DeploymentValidateResult(Model): 'properties': {'key': 'properties', 'type': 'DeploymentPropertiesExtended'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentValidateResult, self).__init__(**kwargs) self.error = kwargs.get('error', None) self.properties = kwargs.get('properties', None) -class ErrorAdditionalInfo(Model): +class ErrorAdditionalInfo(msrest.serialization.Model): """The resource management error additional info. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar type: The additional info type. :vartype type: str @@ -541,17 +578,19 @@ class ErrorAdditionalInfo(Model): 'info': {'key': 'info', 'type': 'object'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None -class ErrorResponse(Model): +class ErrorResponse(msrest.serialization.Model): """The resource management error response. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar code: The error code. :vartype code: str @@ -560,8 +599,7 @@ class ErrorResponse(Model): :ivar target: The error target. :vartype target: str :ivar details: The error details. - :vartype details: - list[~azure.mgmt.resource.resources.v2018_02_01.models.ErrorResponse] + :vartype details: list[~azure.mgmt.resource.resources.v2018_02_01.models.ErrorResponse] :ivar additional_info: The error additional info. :vartype additional_info: list[~azure.mgmt.resource.resources.v2018_02_01.models.ErrorAdditionalInfo] @@ -583,7 +621,10 @@ class ErrorResponse(Model): 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ErrorResponse, self).__init__(**kwargs) self.code = None self.message = None @@ -592,16 +633,15 @@ def __init__(self, **kwargs): self.additional_info = None -class ExportTemplateRequest(Model): +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, supply an array with single entry '*'. + :param 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', 'SkipResourceNameParameterization', - 'SkipAllParameterization' + :param options: The export template options. A CSV-formatted list containing zero or more of + the following: 'IncludeParameterDefaultValue', 'IncludeComments', + 'SkipResourceNameParameterization', 'SkipAllParameterization'. :type options: str """ @@ -610,27 +650,29 @@ class ExportTemplateRequest(Model): 'options': {'key': 'options', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ExportTemplateRequest, self).__init__(**kwargs) self.resources = kwargs.get('resources', None) self.options = kwargs.get('options', None) -class Resource(Model): +class Resource(msrest.serialization.Model): """Resource. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID + :ivar id: Resource ID. :vartype id: str - :ivar name: Resource name + :ivar name: Resource name. :vartype name: str - :ivar type: Resource type + :ivar type: Resource type. :vartype type: str - :param location: Resource location + :param location: Resource location. :type location: str - :param tags: Resource tags + :param tags: A set of tags. Resource tags. :type tags: dict[str, str] """ @@ -648,7 +690,10 @@ class Resource(Model): 'tags': {'key': 'tags', 'type': '{str}'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -660,18 +705,17 @@ def __init__(self, **kwargs): class GenericResource(Resource): """Resource information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID + :ivar id: Resource ID. :vartype id: str - :ivar name: Resource name + :ivar name: Resource name. :vartype name: str - :ivar type: Resource type + :ivar type: Resource type. :vartype type: str - :param location: Resource location + :param location: Resource location. :type location: str - :param tags: Resource tags + :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 @@ -708,7 +752,10 @@ class GenericResource(Resource): 'identity': {'key': 'identity', 'type': 'Identity'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(GenericResource, self).__init__(**kwargs) self.plan = kwargs.get('plan', None) self.properties = kwargs.get('properties', None) @@ -721,18 +768,17 @@ def __init__(self, **kwargs): class GenericResourceExpanded(GenericResource): """Resource information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID + :ivar id: Resource ID. :vartype id: str - :ivar name: Resource name + :ivar name: Resource name. :vartype name: str - :ivar type: Resource type + :ivar type: Resource type. :vartype type: str - :param location: Resource location + :param location: Resource location. :type location: str - :param tags: Resource tags + :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 @@ -746,14 +792,14 @@ class GenericResourceExpanded(GenericResource): :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 created_time: The created time of the resource. This is only present - if requested via the $expand query parameter. - :vartype created_time: datetime - :ivar changed_time: The changed time of the resource. This is only present - if requested via the $expand query parameter. - :vartype changed_time: datetime - :ivar provisioning_state: The provisioning state of the resource. This is - only present if requested via the $expand query parameter. + :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 + :ivar changed_time: The changed time of the resource. This is only present if requested via the + $expand query parameter. + :vartype changed_time: ~datetime.datetime + :ivar provisioning_state: The provisioning state of the resource. This is only present if + requested via the $expand query parameter. :vartype provisioning_state: str """ @@ -784,14 +830,17 @@ class GenericResourceExpanded(GenericResource): 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(GenericResourceExpanded, self).__init__(**kwargs) self.created_time = None self.changed_time = None self.provisioning_state = None -class GenericResourceFilter(Model): +class GenericResourceFilter(msrest.serialization.Model): """Resource filter. :param resource_type: The resource type. @@ -808,14 +857,17 @@ class GenericResourceFilter(Model): 'tagvalue': {'key': 'tagvalue', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(GenericResourceFilter, self).__init__(**kwargs) self.resource_type = kwargs.get('resource_type', None) self.tagname = kwargs.get('tagname', None) self.tagvalue = kwargs.get('tagvalue', None) -class HttpMessage(Model): +class HttpMessage(msrest.serialization.Model): """HTTP message. :param content: HTTP message content. @@ -826,25 +878,26 @@ class HttpMessage(Model): 'content': {'key': 'content', 'type': 'object'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(HttpMessage, self).__init__(**kwargs) self.content = kwargs.get('content', None) -class Identity(Model): +class Identity(msrest.serialization.Model): """Identity for the resource. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar principal_id: The principal ID of resource identity. :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :param 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 + :param 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 """ _validation = { @@ -855,53 +908,53 @@ class Identity(Model): _attribute_map = { 'principal_id': {'key': 'principalId', 'type': 'str'}, 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'ResourceIdentityType'}, + 'type': {'key': 'type', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Identity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None self.type = kwargs.get('type', None) -class OnErrorDeployment(Model): +class OnErrorDeployment(msrest.serialization.Model): """Deployment on error behavior. - :param 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 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 """ _attribute_map = { - 'type': {'key': 'type', 'type': 'OnErrorDeploymentType'}, + 'type': {'key': 'type', 'type': 'str'}, 'deployment_name': {'key': 'deploymentName', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(OnErrorDeployment, self).__init__(**kwargs) self.type = kwargs.get('type', None) self.deployment_name = kwargs.get('deployment_name', None) -class OnErrorDeploymentExtended(Model): +class OnErrorDeploymentExtended(msrest.serialization.Model): """Deployment on error behavior with additional details. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar provisioning_state: The state of the provisioning for the on error - deployment. + :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 SpecificDeployment. Possible values include: - 'LastSuccessful', 'SpecificDeployment' - :type type: str or - ~azure.mgmt.resource.resources.v2018_02_01.models.OnErrorDeploymentType + :param 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 """ @@ -912,26 +965,28 @@ class OnErrorDeploymentExtended(Model): _attribute_map = { 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'OnErrorDeploymentType'}, + 'type': {'key': 'type', 'type': 'str'}, 'deployment_name': {'key': 'deploymentName', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(OnErrorDeploymentExtended, self).__init__(**kwargs) self.provisioning_state = None self.type = kwargs.get('type', None) self.deployment_name = kwargs.get('deployment_name', None) -class ParametersLink(Model): +class ParametersLink(msrest.serialization.Model): """Entity representing the reference to the deployment parameters. 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. + :param content_version: If included, must match the ContentVersion in the template. :type content_version: str """ @@ -944,13 +999,16 @@ class ParametersLink(Model): 'content_version': {'key': 'contentVersion', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ParametersLink, self).__init__(**kwargs) - self.uri = kwargs.get('uri', None) + self.uri = kwargs['uri'] self.content_version = kwargs.get('content_version', None) -class Plan(Model): +class Plan(msrest.serialization.Model): """Plan for the resource. :param name: The plan ID. @@ -973,7 +1031,10 @@ class Plan(Model): 'version': {'key': 'version', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Plan, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.publisher = kwargs.get('publisher', None) @@ -982,11 +1043,10 @@ def __init__(self, **kwargs): self.version = kwargs.get('version', None) -class Provider(Model): +class Provider(msrest.serialization.Model): """Resource provider information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The provider ID. :vartype id: str @@ -1012,7 +1072,10 @@ class Provider(Model): 'resource_types': {'key': 'resourceTypes', 'type': '[ProviderResourceType]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Provider, self).__init__(**kwargs) self.id = None self.namespace = kwargs.get('namespace', None) @@ -1020,17 +1083,44 @@ def __init__(self, **kwargs): self.resource_types = None -class ProviderResourceType(Model): +class ProviderListResult(msrest.serialization.Model): + """List of resource providers. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Provider]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ProviderListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = None + + +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. + :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] + :type aliases: list[~azure.mgmt.resource.resources.v2018_02_01.models.AliasType] :param api_versions: The API version. :type api_versions: list[str] :param properties: The properties. @@ -1045,7 +1135,10 @@ class ProviderResourceType(Model): 'properties': {'key': 'properties', 'type': '{str}'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ProviderResourceType, self).__init__(**kwargs) self.resource_type = kwargs.get('resource_type', None) self.locations = kwargs.get('locations', None) @@ -1054,11 +1147,10 @@ def __init__(self, **kwargs): self.properties = kwargs.get('properties', None) -class ResourceGroup(Model): +class ResourceGroup(msrest.serialization.Model): """Resource group information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. @@ -1066,17 +1158,14 @@ class ResourceGroup(Model): :vartype id: str :param name: The name of the resource group. :type name: str - :param 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 resource group has been created. It must be one of - the supported Azure locations. + :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 + 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. + :param managed_by: The ID of the resource that manages this resource group. :type managed_by: str - :param tags: The tags attached to the resource group. + :param tags: A set of tags. The tags attached to the resource group. :type tags: dict[str, str] """ @@ -1094,17 +1183,20 @@ class ResourceGroup(Model): 'tags': {'key': 'tags', 'type': '{str}'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ResourceGroup, self).__init__(**kwargs) self.id = None self.name = kwargs.get('name', None) self.properties = kwargs.get('properties', None) - self.location = kwargs.get('location', None) + self.location = kwargs['location'] self.managed_by = kwargs.get('managed_by', None) self.tags = kwargs.get('tags', None) -class ResourceGroupExportResult(Model): +class ResourceGroupExportResult(msrest.serialization.Model): """Resource group export result. :param template: The template content. @@ -1119,13 +1211,16 @@ class ResourceGroupExportResult(Model): 'error': {'key': 'error', 'type': 'ResourceManagementErrorWithDetails'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ResourceGroupExportResult, self).__init__(**kwargs) self.template = kwargs.get('template', None) self.error = kwargs.get('error', None) -class ResourceGroupFilter(Model): +class ResourceGroupFilter(msrest.serialization.Model): """Resource group filter. :param tag_name: The tag name. @@ -1139,24 +1234,54 @@ class ResourceGroupFilter(Model): 'tag_value': {'key': 'tagValue', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ResourceGroupFilter, self).__init__(**kwargs) self.tag_name = kwargs.get('tag_name', None) self.tag_value = kwargs.get('tag_value', None) -class ResourceGroupPatchable(Model): +class ResourceGroupListResult(msrest.serialization.Model): + """List of resource groups. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ResourceGroup]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ResourceGroupListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = None + + +class ResourceGroupPatchable(msrest.serialization.Model): """Resource group information. :param name: The name of the resource group. :type name: str - :param 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. + :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: The tags attached to the resource group. + :param tags: A set of tags. The tags attached to the resource group. :type tags: dict[str, str] """ @@ -1167,7 +1292,10 @@ class ResourceGroupPatchable(Model): 'tags': {'key': 'tags', 'type': '{str}'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ResourceGroupPatchable, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.properties = kwargs.get('properties', None) @@ -1175,11 +1303,10 @@ def __init__(self, **kwargs): self.tags = kwargs.get('tags', None) -class ResourceGroupProperties(Model): +class ResourceGroupProperties(msrest.serialization.Model): """The resource group properties. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar provisioning_state: The provisioning state. :vartype provisioning_state: str @@ -1193,16 +1320,47 @@ class ResourceGroupProperties(Model): 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ResourceGroupProperties, self).__init__(**kwargs) self.provisioning_state = None -class ResourceManagementErrorWithDetails(Model): +class ResourceListResult(msrest.serialization.Model): + """List of resource groups. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[GenericResourceExpanded]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ResourceListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = None + + +class ResourceManagementErrorWithDetails(msrest.serialization.Model): """The detailed error message of resource management. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar code: The error code returned when exporting the template. :vartype code: str @@ -1229,7 +1387,10 @@ class ResourceManagementErrorWithDetails(Model): 'details': {'key': 'details', 'type': '[ResourceManagementErrorWithDetails]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ResourceManagementErrorWithDetails, self).__init__(**kwargs) self.code = None self.message = None @@ -1237,7 +1398,7 @@ def __init__(self, **kwargs): self.details = None -class ResourceProviderOperationDisplayProperties(Model): +class ResourceProviderOperationDisplayProperties(msrest.serialization.Model): """Resource provider operation's display properties. :param publisher: Operation description. @@ -1260,7 +1421,10 @@ class ResourceProviderOperationDisplayProperties(Model): 'description': {'key': 'description', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ResourceProviderOperationDisplayProperties, self).__init__(**kwargs) self.publisher = kwargs.get('publisher', None) self.provider = kwargs.get('provider', None) @@ -1269,7 +1433,7 @@ def __init__(self, **kwargs): self.description = kwargs.get('description', None) -class ResourcesMoveInfo(Model): +class ResourcesMoveInfo(msrest.serialization.Model): """Parameters of move resources. :param resources: The IDs of the resources. @@ -1283,13 +1447,16 @@ class ResourcesMoveInfo(Model): 'target_resource_group': {'key': 'targetResourceGroup', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ResourcesMoveInfo, self).__init__(**kwargs) self.resources = kwargs.get('resources', None) self.target_resource_group = kwargs.get('target_resource_group', None) -class Sku(Model): +class Sku(msrest.serialization.Model): """SKU for the resource. :param name: The SKU name. @@ -1315,7 +1482,10 @@ class Sku(Model): 'capacity': {'key': 'capacity', 'type': 'int'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Sku, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.tier = kwargs.get('tier', None) @@ -1325,10 +1495,10 @@ def __init__(self, **kwargs): self.capacity = kwargs.get('capacity', None) -class SubResource(Model): +class SubResource(msrest.serialization.Model): """Sub-resource. - :param id: Resource ID + :param id: Resource ID. :type id: str """ @@ -1336,12 +1506,15 @@ class SubResource(Model): 'id': {'key': 'id', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(SubResource, self).__init__(**kwargs) self.id = kwargs.get('id', None) -class TagCount(Model): +class TagCount(msrest.serialization.Model): """Tag count. :param type: Type of count. @@ -1355,29 +1528,29 @@ class TagCount(Model): 'value': {'key': 'value', 'type': 'int'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(TagCount, self).__init__(**kwargs) self.type = kwargs.get('type', None) self.value = kwargs.get('value', None) -class TagDetails(Model): +class TagDetails(msrest.serialization.Model): """Tag details. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :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 created and has no associated resources, the value - is 0. + :param 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] + :type values: list[~azure.mgmt.resource.resources.v2018_02_01.models.TagValue] """ _validation = { @@ -1391,7 +1564,10 @@ class TagDetails(Model): 'values': {'key': 'values', 'type': '[TagValue]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(TagDetails, self).__init__(**kwargs) self.id = None self.tag_name = kwargs.get('tag_name', None) @@ -1399,11 +1575,39 @@ def __init__(self, **kwargs): self.values = kwargs.get('values', None) -class TagValue(Model): +class TagsListResult(msrest.serialization.Model): + """List of subscription tags. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[TagDetails]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(TagsListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = None + + +class TagValue(msrest.serialization.Model): """Tag information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The tag ID. :vartype id: str @@ -1423,14 +1627,17 @@ class TagValue(Model): 'count': {'key': 'count', 'type': 'TagCount'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(TagValue, self).__init__(**kwargs) self.id = None self.tag_value = kwargs.get('tag_value', None) self.count = kwargs.get('count', None) -class TargetResource(Model): +class TargetResource(msrest.serialization.Model): """Target resource. :param id: The ID of the resource. @@ -1447,16 +1654,18 @@ class TargetResource(Model): 'resource_type': {'key': 'resourceType', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(TargetResource, self).__init__(**kwargs) self.id = kwargs.get('id', None) self.resource_name = kwargs.get('resource_name', None) self.resource_type = kwargs.get('resource_type', None) -class TemplateHashResult(Model): - """Result of the request to calculate template hash. It contains a string of - minified template and its hash. +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 @@ -1469,21 +1678,23 @@ class TemplateHashResult(Model): 'template_hash': {'key': 'templateHash', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(TemplateHashResult, self).__init__(**kwargs) self.minified_template = kwargs.get('minified_template', None) self.template_hash = kwargs.get('template_hash', None) -class TemplateLink(Model): +class TemplateLink(msrest.serialization.Model): """Entity representing the reference to the template. 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. + :param content_version: If included, must match the ContentVersion in the template. :type content_version: str """ @@ -1496,7 +1707,10 @@ class TemplateLink(Model): 'content_version': {'key': 'contentVersion', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(TemplateLink, self).__init__(**kwargs) - self.uri = kwargs.get('uri', None) + self.uri = kwargs['uri'] self.content_version = kwargs.get('content_version', 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 1664994dabc5..7c87ac810eb5 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 @@ -1,20 +1,20 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.serialization import Model -from msrest.exceptions import HttpOperationError +from typing import Dict, List, Optional, Union +import msrest.serialization -class AliasPathType(Model): - """The type of the paths for alias. . +from ._resource_management_client_enums import * + + +class AliasPathType(msrest.serialization.Model): + """The type of the paths for alias. :param path: The path of an alias. :type path: str @@ -27,20 +27,25 @@ class AliasPathType(Model): 'api_versions': {'key': 'apiVersions', 'type': '[str]'}, } - def __init__(self, *, path: str=None, api_versions=None, **kwargs) -> None: + def __init__( + self, + *, + path: Optional[str] = None, + api_versions: Optional[List[str]] = None, + **kwargs + ): super(AliasPathType, self).__init__(**kwargs) self.path = path self.api_versions = api_versions -class AliasType(Model): - """The alias type. . +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] + :type paths: list[~azure.mgmt.resource.resources.v2018_02_01.models.AliasPathType] """ _attribute_map = { @@ -48,13 +53,19 @@ class AliasType(Model): 'paths': {'key': 'paths', 'type': '[AliasPathType]'}, } - def __init__(self, *, name: str=None, paths=None, **kwargs) -> None: + def __init__( + self, + *, + name: Optional[str] = None, + paths: Optional[List["AliasPathType"]] = None, + **kwargs + ): super(AliasType, self).__init__(**kwargs) self.name = name self.paths = paths -class BasicDependency(Model): +class BasicDependency(msrest.serialization.Model): """Deployment dependency information. :param id: The ID of the dependency. @@ -71,52 +82,29 @@ class BasicDependency(Model): 'resource_name': {'key': 'resourceName', 'type': 'str'}, } - def __init__(self, *, id: str=None, resource_type: str=None, resource_name: str=None, **kwargs) -> None: + def __init__( + self, + *, + id: Optional[str] = None, + resource_type: Optional[str] = None, + resource_name: Optional[str] = None, + **kwargs + ): super(BasicDependency, self).__init__(**kwargs) self.id = id self.resource_type = resource_type self.resource_name = resource_name -class CloudError(Model): - """An error response for a resource management request. - - :param error: - :type error: - ~azure.mgmt.resource.resources.v2018_02_01.models.ErrorResponse - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorResponse'}, - } - - def __init__(self, *, error=None, **kwargs) -> None: - super(CloudError, self).__init__(**kwargs) - self.error = error - - -class CloudErrorException(HttpOperationError): - """Server responsed with exception of type: 'CloudError'. - - :param deserialize: A deserializer - :param response: Server response to be deserialized. - """ - - def __init__(self, deserialize, response, *args): - - super(CloudErrorException, self).__init__(deserialize, response, 'CloudError', *args) - - -class DebugSetting(Model): +class DebugSetting(msrest.serialization.Model): """DebugSetting. - :param 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. + :param 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 """ @@ -124,17 +112,21 @@ class DebugSetting(Model): 'detail_level': {'key': 'detailLevel', 'type': 'str'}, } - def __init__(self, *, detail_level: str=None, **kwargs) -> None: + def __init__( + self, + *, + detail_level: Optional[str] = None, + **kwargs + ): super(DebugSetting, self).__init__(**kwargs) self.detail_level = detail_level -class Dependency(Model): +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] + :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. @@ -150,7 +142,15 @@ class Dependency(Model): 'resource_name': {'key': 'resourceName', 'type': 'str'}, } - def __init__(self, *, depends_on=None, id: str=None, resource_type: str=None, resource_name: str=None, **kwargs) -> None: + def __init__( + self, + *, + depends_on: Optional[List["BasicDependency"]] = None, + id: Optional[str] = None, + resource_type: Optional[str] = None, + resource_name: Optional[str] = None, + **kwargs + ): super(Dependency, self).__init__(**kwargs) self.depends_on = depends_on self.id = id @@ -158,14 +158,13 @@ def __init__(self, *, depends_on=None, id: str=None, resource_type: str=None, re self.resource_name = resource_name -class Deployment(Model): +class Deployment(msrest.serialization.Model): """Deployment operation parameters. 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 + :type properties: ~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentProperties """ _validation = { @@ -176,13 +175,18 @@ class Deployment(Model): 'properties': {'key': 'properties', 'type': 'DeploymentProperties'}, } - def __init__(self, *, properties, **kwargs) -> None: + def __init__( + self, + *, + properties: "DeploymentProperties", + **kwargs + ): super(Deployment, self).__init__(**kwargs) self.properties = properties -class DeploymentExportResult(Model): - """The deployment export result. . +class DeploymentExportResult(msrest.serialization.Model): + """The deployment export result. :param template: The template content. :type template: object @@ -192,16 +196,20 @@ class DeploymentExportResult(Model): 'template': {'key': 'template', 'type': 'object'}, } - def __init__(self, *, template=None, **kwargs) -> None: + def __init__( + self, + *, + template: Optional[object] = None, + **kwargs + ): super(DeploymentExportResult, self).__init__(**kwargs) self.template = template -class DeploymentExtended(Model): +class DeploymentExtended(msrest.serialization.Model): """Deployment information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. @@ -225,14 +233,20 @@ class DeploymentExtended(Model): 'properties': {'key': 'properties', 'type': 'DeploymentPropertiesExtended'}, } - def __init__(self, *, name: str, properties=None, **kwargs) -> None: + def __init__( + self, + *, + name: str, + properties: Optional["DeploymentPropertiesExtended"] = None, + **kwargs + ): super(DeploymentExtended, self).__init__(**kwargs) self.id = None self.name = name self.properties = properties -class DeploymentExtendedFilter(Model): +class DeploymentExtendedFilter(msrest.serialization.Model): """Deployment filter. :param provisioning_state: The provisioning state. @@ -243,16 +257,51 @@ class DeploymentExtendedFilter(Model): 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, } - def __init__(self, *, provisioning_state: str=None, **kwargs) -> None: + def __init__( + self, + *, + provisioning_state: Optional[str] = None, + **kwargs + ): super(DeploymentExtendedFilter, self).__init__(**kwargs) self.provisioning_state = provisioning_state -class DeploymentOperation(Model): +class DeploymentListResult(msrest.serialization.Model): + """List of deployments. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[DeploymentExtended]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["DeploymentExtended"]] = None, + **kwargs + ): + super(DeploymentListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class DeploymentOperation(msrest.serialization.Model): """Deployment operation information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Full deployment operation ID. :vartype id: str @@ -274,23 +323,27 @@ class DeploymentOperation(Model): 'properties': {'key': 'properties', 'type': 'DeploymentOperationProperties'}, } - def __init__(self, *, properties=None, **kwargs) -> None: + def __init__( + self, + *, + properties: Optional["DeploymentOperationProperties"] = None, + **kwargs + ): super(DeploymentOperation, self).__init__(**kwargs) self.id = None self.operation_id = None self.properties = properties -class DeploymentOperationProperties(Model): +class DeploymentOperationProperties(msrest.serialization.Model): """Deployment operation properties. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar provisioning_state: The state of the provisioning. :vartype provisioning_state: str :ivar timestamp: The date and time of the operation. - :vartype timestamp: datetime + :vartype timestamp: ~datetime.datetime :ivar service_request_id: Deployment operation service request id. :vartype service_request_id: str :ivar status_code: Operation status code. @@ -298,14 +351,11 @@ class DeploymentOperationProperties(Model): :ivar status_message: Operation status message. :vartype status_message: object :ivar target_resource: The target resource. - :vartype target_resource: - ~azure.mgmt.resource.resources.v2018_02_01.models.TargetResource + :vartype target_resource: ~azure.mgmt.resource.resources.v2018_02_01.models.TargetResource :ivar request: The HTTP request message. - :vartype request: - ~azure.mgmt.resource.resources.v2018_02_01.models.HttpMessage + :vartype request: ~azure.mgmt.resource.resources.v2018_02_01.models.HttpMessage :ivar response: The HTTP response message. - :vartype response: - ~azure.mgmt.resource.resources.v2018_02_01.models.HttpMessage + :vartype response: ~azure.mgmt.resource.resources.v2018_02_01.models.HttpMessage """ _validation = { @@ -330,7 +380,10 @@ class DeploymentOperationProperties(Model): 'response': {'key': 'response', 'type': 'HttpMessage'}, } - def __init__(self, **kwargs) -> None: + def __init__( + self, + **kwargs + ): super(DeploymentOperationProperties, self).__init__(**kwargs) self.provisioning_state = None self.timestamp = None @@ -342,48 +395,70 @@ def __init__(self, **kwargs) -> None: self.response = None -class DeploymentProperties(Model): +class DeploymentOperationsListResult(msrest.serialization.Model): + """List of deployment operations. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[DeploymentOperation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["DeploymentOperation"]] = None, + **kwargs + ): + super(DeploymentOperationsListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class DeploymentProperties(msrest.serialization.Model): """Deployment properties. 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 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. + :param 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: object - :param 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. 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. + :param 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. + 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: object - :param 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 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 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 + 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 + :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 + :type on_error_deployment: ~azure.mgmt.resource.resources.v2018_02_01.models.OnErrorDeployment """ _validation = { @@ -395,12 +470,23 @@ class DeploymentProperties(Model): 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, 'parameters': {'key': 'parameters', 'type': 'object'}, 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, - 'mode': {'key': 'mode', 'type': 'DeploymentMode'}, + 'mode': {'key': 'mode', 'type': 'str'}, 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, 'on_error_deployment': {'key': 'onErrorDeployment', 'type': 'OnErrorDeployment'}, } - def __init__(self, *, mode, template=None, template_link=None, parameters=None, parameters_link=None, debug_setting=None, on_error_deployment=None, **kwargs) -> None: + def __init__( + self, + *, + mode: Union[str, "DeploymentMode"], + template: Optional[object] = None, + template_link: Optional["TemplateLink"] = None, + parameters: Optional[object] = None, + parameters_link: Optional["ParametersLink"] = None, + debug_setting: Optional["DebugSetting"] = None, + on_error_deployment: Optional["OnErrorDeployment"] = None, + **kwargs + ): super(DeploymentProperties, self).__init__(**kwargs) self.template = template self.template_link = template_link @@ -411,48 +497,38 @@ def __init__(self, *, mode, template=None, template_link=None, parameters=None, self.on_error_deployment = on_error_deployment -class DeploymentPropertiesExtended(Model): +class DeploymentPropertiesExtended(msrest.serialization.Model): """Deployment properties with additional details. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :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 + :vartype timestamp: ~datetime.datetime :param outputs: Key/value pairs that represent deployment output. :type outputs: object - :param providers: The list of resource providers needed for the - deployment. - :type providers: - list[~azure.mgmt.resource.resources.v2018_02_01.models.Provider] + :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 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: object - :param 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. + :param 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: object - :param 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 include: 'Incremental', 'Complete' - :type mode: str or - ~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentMode + :param 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 + 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 + :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.OnErrorDeploymentExtended @@ -475,12 +551,26 @@ class DeploymentPropertiesExtended(Model): 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, 'parameters': {'key': 'parameters', 'type': 'object'}, 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, - 'mode': {'key': 'mode', 'type': 'DeploymentMode'}, + 'mode': {'key': 'mode', 'type': 'str'}, 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, 'on_error_deployment': {'key': 'onErrorDeployment', 'type': 'OnErrorDeploymentExtended'}, } - def __init__(self, *, outputs=None, providers=None, dependencies=None, template=None, template_link=None, parameters=None, parameters_link=None, mode=None, debug_setting=None, on_error_deployment=None, **kwargs) -> None: + def __init__( + self, + *, + outputs: Optional[object] = None, + providers: Optional[List["Provider"]] = None, + dependencies: Optional[List["Dependency"]] = None, + template: Optional[object] = None, + template_link: Optional["TemplateLink"] = None, + parameters: Optional[object] = None, + parameters_link: Optional["ParametersLink"] = None, + mode: Optional[Union[str, "DeploymentMode"]] = None, + debug_setting: Optional["DebugSetting"] = None, + on_error_deployment: Optional["OnErrorDeploymentExtended"] = None, + **kwargs + ): super(DeploymentPropertiesExtended, self).__init__(**kwargs) self.provisioning_state = None self.correlation_id = None @@ -497,7 +587,7 @@ def __init__(self, *, outputs=None, providers=None, dependencies=None, template= self.on_error_deployment = on_error_deployment -class DeploymentValidateResult(Model): +class DeploymentValidateResult(msrest.serialization.Model): """Information from validate template deployment response. :param error: Validation error. @@ -513,17 +603,22 @@ class DeploymentValidateResult(Model): 'properties': {'key': 'properties', 'type': 'DeploymentPropertiesExtended'}, } - def __init__(self, *, error=None, properties=None, **kwargs) -> None: + def __init__( + self, + *, + error: Optional["ResourceManagementErrorWithDetails"] = None, + properties: Optional["DeploymentPropertiesExtended"] = None, + **kwargs + ): super(DeploymentValidateResult, self).__init__(**kwargs) self.error = error self.properties = properties -class ErrorAdditionalInfo(Model): +class ErrorAdditionalInfo(msrest.serialization.Model): """The resource management error additional info. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar type: The additional info type. :vartype type: str @@ -541,17 +636,19 @@ class ErrorAdditionalInfo(Model): 'info': {'key': 'info', 'type': 'object'}, } - def __init__(self, **kwargs) -> None: + def __init__( + self, + **kwargs + ): super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None -class ErrorResponse(Model): +class ErrorResponse(msrest.serialization.Model): """The resource management error response. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar code: The error code. :vartype code: str @@ -560,8 +657,7 @@ class ErrorResponse(Model): :ivar target: The error target. :vartype target: str :ivar details: The error details. - :vartype details: - list[~azure.mgmt.resource.resources.v2018_02_01.models.ErrorResponse] + :vartype details: list[~azure.mgmt.resource.resources.v2018_02_01.models.ErrorResponse] :ivar additional_info: The error additional info. :vartype additional_info: list[~azure.mgmt.resource.resources.v2018_02_01.models.ErrorAdditionalInfo] @@ -583,7 +679,10 @@ class ErrorResponse(Model): 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, } - def __init__(self, **kwargs) -> None: + def __init__( + self, + **kwargs + ): super(ErrorResponse, self).__init__(**kwargs) self.code = None self.message = None @@ -592,16 +691,15 @@ def __init__(self, **kwargs) -> None: self.additional_info = None -class ExportTemplateRequest(Model): +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, supply an array with single entry '*'. + :param 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', 'SkipResourceNameParameterization', - 'SkipAllParameterization' + :param options: The export template options. A CSV-formatted list containing zero or more of + the following: 'IncludeParameterDefaultValue', 'IncludeComments', + 'SkipResourceNameParameterization', 'SkipAllParameterization'. :type options: str """ @@ -610,27 +708,32 @@ class ExportTemplateRequest(Model): 'options': {'key': 'options', 'type': 'str'}, } - def __init__(self, *, resources=None, options: str=None, **kwargs) -> None: + def __init__( + self, + *, + resources: Optional[List[str]] = None, + options: Optional[str] = None, + **kwargs + ): super(ExportTemplateRequest, self).__init__(**kwargs) self.resources = resources self.options = options -class Resource(Model): +class Resource(msrest.serialization.Model): """Resource. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID + :ivar id: Resource ID. :vartype id: str - :ivar name: Resource name + :ivar name: Resource name. :vartype name: str - :ivar type: Resource type + :ivar type: Resource type. :vartype type: str - :param location: Resource location + :param location: Resource location. :type location: str - :param tags: Resource tags + :param tags: A set of tags. Resource tags. :type tags: dict[str, str] """ @@ -648,7 +751,13 @@ class Resource(Model): 'tags': {'key': 'tags', 'type': '{str}'}, } - def __init__(self, *, location: str=None, tags=None, **kwargs) -> None: + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -660,18 +769,17 @@ def __init__(self, *, location: str=None, tags=None, **kwargs) -> None: class GenericResource(Resource): """Resource information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID + :ivar id: Resource ID. :vartype id: str - :ivar name: Resource name + :ivar name: Resource name. :vartype name: str - :ivar type: Resource type + :ivar type: Resource type. :vartype type: str - :param location: Resource location + :param location: Resource location. :type location: str - :param tags: Resource tags + :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 @@ -708,7 +816,19 @@ class GenericResource(Resource): 'identity': {'key': 'identity', 'type': 'Identity'}, } - def __init__(self, *, location: str=None, tags=None, plan=None, properties=None, kind: str=None, managed_by: str=None, sku=None, identity=None, **kwargs) -> None: + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + plan: Optional["Plan"] = None, + properties: Optional[object] = None, + kind: Optional[str] = None, + managed_by: Optional[str] = None, + sku: Optional["Sku"] = None, + identity: Optional["Identity"] = None, + **kwargs + ): super(GenericResource, self).__init__(location=location, tags=tags, **kwargs) self.plan = plan self.properties = properties @@ -721,18 +841,17 @@ def __init__(self, *, location: str=None, tags=None, plan=None, properties=None, class GenericResourceExpanded(GenericResource): """Resource information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID + :ivar id: Resource ID. :vartype id: str - :ivar name: Resource name + :ivar name: Resource name. :vartype name: str - :ivar type: Resource type + :ivar type: Resource type. :vartype type: str - :param location: Resource location + :param location: Resource location. :type location: str - :param tags: Resource tags + :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 @@ -746,14 +865,14 @@ class GenericResourceExpanded(GenericResource): :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 created_time: The created time of the resource. This is only present - if requested via the $expand query parameter. - :vartype created_time: datetime - :ivar changed_time: The changed time of the resource. This is only present - if requested via the $expand query parameter. - :vartype changed_time: datetime - :ivar provisioning_state: The provisioning state of the resource. This is - only present if requested via the $expand query parameter. + :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 + :ivar changed_time: The changed time of the resource. This is only present if requested via the + $expand query parameter. + :vartype changed_time: ~datetime.datetime + :ivar provisioning_state: The provisioning state of the resource. This is only present if + requested via the $expand query parameter. :vartype provisioning_state: str """ @@ -784,14 +903,26 @@ class GenericResourceExpanded(GenericResource): 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, } - def __init__(self, *, location: str=None, tags=None, plan=None, properties=None, kind: str=None, managed_by: str=None, sku=None, identity=None, **kwargs) -> None: + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + plan: Optional["Plan"] = None, + properties: Optional[object] = None, + kind: Optional[str] = None, + managed_by: Optional[str] = None, + sku: Optional["Sku"] = None, + identity: Optional["Identity"] = None, + **kwargs + ): 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 self.provisioning_state = None -class GenericResourceFilter(Model): +class GenericResourceFilter(msrest.serialization.Model): """Resource filter. :param resource_type: The resource type. @@ -808,14 +939,21 @@ class GenericResourceFilter(Model): 'tagvalue': {'key': 'tagvalue', 'type': 'str'}, } - def __init__(self, *, resource_type: str=None, tagname: str=None, tagvalue: str=None, **kwargs) -> None: + def __init__( + self, + *, + resource_type: Optional[str] = None, + tagname: Optional[str] = None, + tagvalue: Optional[str] = None, + **kwargs + ): super(GenericResourceFilter, self).__init__(**kwargs) self.resource_type = resource_type self.tagname = tagname self.tagvalue = tagvalue -class HttpMessage(Model): +class HttpMessage(msrest.serialization.Model): """HTTP message. :param content: HTTP message content. @@ -826,25 +964,28 @@ class HttpMessage(Model): 'content': {'key': 'content', 'type': 'object'}, } - def __init__(self, *, content=None, **kwargs) -> None: + def __init__( + self, + *, + content: Optional[object] = None, + **kwargs + ): super(HttpMessage, self).__init__(**kwargs) self.content = content -class Identity(Model): +class Identity(msrest.serialization.Model): """Identity for the resource. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar principal_id: The principal ID of resource identity. :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :param 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 + :param 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 """ _validation = { @@ -855,53 +996,58 @@ class Identity(Model): _attribute_map = { 'principal_id': {'key': 'principalId', 'type': 'str'}, 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'ResourceIdentityType'}, + 'type': {'key': 'type', 'type': 'str'}, } - def __init__(self, *, type=None, **kwargs) -> None: + def __init__( + self, + *, + type: Optional[Union[str, "ResourceIdentityType"]] = None, + **kwargs + ): super(Identity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None self.type = type -class OnErrorDeployment(Model): +class OnErrorDeployment(msrest.serialization.Model): """Deployment on error behavior. - :param 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 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 """ _attribute_map = { - 'type': {'key': 'type', 'type': 'OnErrorDeploymentType'}, + 'type': {'key': 'type', 'type': 'str'}, 'deployment_name': {'key': 'deploymentName', 'type': 'str'}, } - def __init__(self, *, type=None, deployment_name: str=None, **kwargs) -> None: + def __init__( + self, + *, + type: Optional[Union[str, "OnErrorDeploymentType"]] = None, + deployment_name: Optional[str] = None, + **kwargs + ): super(OnErrorDeployment, self).__init__(**kwargs) self.type = type self.deployment_name = deployment_name -class OnErrorDeploymentExtended(Model): +class OnErrorDeploymentExtended(msrest.serialization.Model): """Deployment on error behavior with additional details. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar provisioning_state: The state of the provisioning for the on error - deployment. + :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 SpecificDeployment. Possible values include: - 'LastSuccessful', 'SpecificDeployment' - :type type: str or - ~azure.mgmt.resource.resources.v2018_02_01.models.OnErrorDeploymentType + :param 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 """ @@ -912,26 +1058,31 @@ class OnErrorDeploymentExtended(Model): _attribute_map = { 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'OnErrorDeploymentType'}, + 'type': {'key': 'type', 'type': 'str'}, 'deployment_name': {'key': 'deploymentName', 'type': 'str'}, } - def __init__(self, *, type=None, deployment_name: str=None, **kwargs) -> None: + def __init__( + self, + *, + type: Optional[Union[str, "OnErrorDeploymentType"]] = None, + deployment_name: Optional[str] = None, + **kwargs + ): super(OnErrorDeploymentExtended, self).__init__(**kwargs) self.provisioning_state = None self.type = type self.deployment_name = deployment_name -class ParametersLink(Model): +class ParametersLink(msrest.serialization.Model): """Entity representing the reference to the deployment parameters. 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. + :param content_version: If included, must match the ContentVersion in the template. :type content_version: str """ @@ -944,13 +1095,19 @@ class ParametersLink(Model): 'content_version': {'key': 'contentVersion', 'type': 'str'}, } - def __init__(self, *, uri: str, content_version: str=None, **kwargs) -> None: + def __init__( + self, + *, + uri: str, + content_version: Optional[str] = None, + **kwargs + ): super(ParametersLink, self).__init__(**kwargs) self.uri = uri self.content_version = content_version -class Plan(Model): +class Plan(msrest.serialization.Model): """Plan for the resource. :param name: The plan ID. @@ -973,7 +1130,16 @@ class Plan(Model): 'version': {'key': 'version', 'type': 'str'}, } - def __init__(self, *, name: str=None, publisher: str=None, product: str=None, promotion_code: str=None, version: str=None, **kwargs) -> None: + def __init__( + self, + *, + name: Optional[str] = None, + publisher: Optional[str] = None, + product: Optional[str] = None, + promotion_code: Optional[str] = None, + version: Optional[str] = None, + **kwargs + ): super(Plan, self).__init__(**kwargs) self.name = name self.publisher = publisher @@ -982,11 +1148,10 @@ def __init__(self, *, name: str=None, publisher: str=None, product: str=None, pr self.version = version -class Provider(Model): +class Provider(msrest.serialization.Model): """Resource provider information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The provider ID. :vartype id: str @@ -1012,7 +1177,12 @@ class Provider(Model): 'resource_types': {'key': 'resourceTypes', 'type': '[ProviderResourceType]'}, } - def __init__(self, *, namespace: str=None, **kwargs) -> None: + def __init__( + self, + *, + namespace: Optional[str] = None, + **kwargs + ): super(Provider, self).__init__(**kwargs) self.id = None self.namespace = namespace @@ -1020,17 +1190,46 @@ def __init__(self, *, namespace: str=None, **kwargs) -> None: self.resource_types = None -class ProviderResourceType(Model): +class ProviderListResult(msrest.serialization.Model): + """List of resource providers. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Provider]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["Provider"]] = None, + **kwargs + ): + super(ProviderListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +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. + :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] + :type aliases: list[~azure.mgmt.resource.resources.v2018_02_01.models.AliasType] :param api_versions: The API version. :type api_versions: list[str] :param properties: The properties. @@ -1045,7 +1244,16 @@ class ProviderResourceType(Model): 'properties': {'key': 'properties', 'type': '{str}'}, } - def __init__(self, *, resource_type: str=None, locations=None, aliases=None, api_versions=None, properties=None, **kwargs) -> None: + def __init__( + self, + *, + resource_type: Optional[str] = None, + locations: Optional[List[str]] = None, + aliases: Optional[List["AliasType"]] = None, + api_versions: Optional[List[str]] = None, + properties: Optional[Dict[str, str]] = None, + **kwargs + ): super(ProviderResourceType, self).__init__(**kwargs) self.resource_type = resource_type self.locations = locations @@ -1054,11 +1262,10 @@ def __init__(self, *, resource_type: str=None, locations=None, aliases=None, api self.properties = properties -class ResourceGroup(Model): +class ResourceGroup(msrest.serialization.Model): """Resource group information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. @@ -1066,17 +1273,14 @@ class ResourceGroup(Model): :vartype id: str :param name: The name of the resource group. :type name: str - :param 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 resource group has been created. It must be one of - the supported Azure locations. + :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 + 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. + :param managed_by: The ID of the resource that manages this resource group. :type managed_by: str - :param tags: The tags attached to the resource group. + :param tags: A set of tags. The tags attached to the resource group. :type tags: dict[str, str] """ @@ -1094,7 +1298,16 @@ class ResourceGroup(Model): 'tags': {'key': 'tags', 'type': '{str}'}, } - def __init__(self, *, location: str, name: str=None, properties=None, managed_by: str=None, tags=None, **kwargs) -> None: + def __init__( + self, + *, + location: str, + name: Optional[str] = None, + properties: Optional["ResourceGroupProperties"] = None, + managed_by: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): super(ResourceGroup, self).__init__(**kwargs) self.id = None self.name = name @@ -1104,7 +1317,7 @@ def __init__(self, *, location: str, name: str=None, properties=None, managed_by self.tags = tags -class ResourceGroupExportResult(Model): +class ResourceGroupExportResult(msrest.serialization.Model): """Resource group export result. :param template: The template content. @@ -1119,13 +1332,19 @@ class ResourceGroupExportResult(Model): 'error': {'key': 'error', 'type': 'ResourceManagementErrorWithDetails'}, } - def __init__(self, *, template=None, error=None, **kwargs) -> None: + def __init__( + self, + *, + template: Optional[object] = None, + error: Optional["ResourceManagementErrorWithDetails"] = None, + **kwargs + ): super(ResourceGroupExportResult, self).__init__(**kwargs) self.template = template self.error = error -class ResourceGroupFilter(Model): +class ResourceGroupFilter(msrest.serialization.Model): """Resource group filter. :param tag_name: The tag name. @@ -1139,24 +1358,59 @@ class ResourceGroupFilter(Model): 'tag_value': {'key': 'tagValue', 'type': 'str'}, } - def __init__(self, *, tag_name: str=None, tag_value: str=None, **kwargs) -> None: + def __init__( + self, + *, + tag_name: Optional[str] = None, + tag_value: Optional[str] = None, + **kwargs + ): super(ResourceGroupFilter, self).__init__(**kwargs) self.tag_name = tag_name self.tag_value = tag_value -class ResourceGroupPatchable(Model): +class ResourceGroupListResult(msrest.serialization.Model): + """List of resource groups. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ResourceGroup]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["ResourceGroup"]] = None, + **kwargs + ): + super(ResourceGroupListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class ResourceGroupPatchable(msrest.serialization.Model): """Resource group information. :param name: The name of the resource group. :type name: str - :param 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. + :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: The tags attached to the resource group. + :param tags: A set of tags. The tags attached to the resource group. :type tags: dict[str, str] """ @@ -1167,7 +1421,15 @@ class ResourceGroupPatchable(Model): 'tags': {'key': 'tags', 'type': '{str}'}, } - def __init__(self, *, name: str=None, properties=None, managed_by: str=None, tags=None, **kwargs) -> None: + def __init__( + self, + *, + name: Optional[str] = None, + properties: Optional["ResourceGroupProperties"] = None, + managed_by: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): super(ResourceGroupPatchable, self).__init__(**kwargs) self.name = name self.properties = properties @@ -1175,11 +1437,10 @@ def __init__(self, *, name: str=None, properties=None, managed_by: str=None, tag self.tags = tags -class ResourceGroupProperties(Model): +class ResourceGroupProperties(msrest.serialization.Model): """The resource group properties. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar provisioning_state: The provisioning state. :vartype provisioning_state: str @@ -1193,16 +1454,49 @@ class ResourceGroupProperties(Model): 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, } - def __init__(self, **kwargs) -> None: + def __init__( + self, + **kwargs + ): super(ResourceGroupProperties, self).__init__(**kwargs) self.provisioning_state = None -class ResourceManagementErrorWithDetails(Model): +class ResourceListResult(msrest.serialization.Model): + """List of resource groups. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[GenericResourceExpanded]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["GenericResourceExpanded"]] = None, + **kwargs + ): + super(ResourceListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class ResourceManagementErrorWithDetails(msrest.serialization.Model): """The detailed error message of resource management. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar code: The error code returned when exporting the template. :vartype code: str @@ -1229,7 +1523,10 @@ class ResourceManagementErrorWithDetails(Model): 'details': {'key': 'details', 'type': '[ResourceManagementErrorWithDetails]'}, } - def __init__(self, **kwargs) -> None: + def __init__( + self, + **kwargs + ): super(ResourceManagementErrorWithDetails, self).__init__(**kwargs) self.code = None self.message = None @@ -1237,7 +1534,7 @@ def __init__(self, **kwargs) -> None: self.details = None -class ResourceProviderOperationDisplayProperties(Model): +class ResourceProviderOperationDisplayProperties(msrest.serialization.Model): """Resource provider operation's display properties. :param publisher: Operation description. @@ -1260,7 +1557,16 @@ class ResourceProviderOperationDisplayProperties(Model): 'description': {'key': 'description', 'type': 'str'}, } - def __init__(self, *, publisher: str=None, provider: str=None, resource: str=None, operation: str=None, description: str=None, **kwargs) -> None: + def __init__( + self, + *, + publisher: Optional[str] = None, + provider: Optional[str] = None, + resource: Optional[str] = None, + operation: Optional[str] = None, + description: Optional[str] = None, + **kwargs + ): super(ResourceProviderOperationDisplayProperties, self).__init__(**kwargs) self.publisher = publisher self.provider = provider @@ -1269,7 +1575,7 @@ def __init__(self, *, publisher: str=None, provider: str=None, resource: str=Non self.description = description -class ResourcesMoveInfo(Model): +class ResourcesMoveInfo(msrest.serialization.Model): """Parameters of move resources. :param resources: The IDs of the resources. @@ -1283,13 +1589,19 @@ class ResourcesMoveInfo(Model): 'target_resource_group': {'key': 'targetResourceGroup', 'type': 'str'}, } - def __init__(self, *, resources=None, target_resource_group: str=None, **kwargs) -> None: + def __init__( + self, + *, + resources: Optional[List[str]] = None, + target_resource_group: Optional[str] = None, + **kwargs + ): super(ResourcesMoveInfo, self).__init__(**kwargs) self.resources = resources self.target_resource_group = target_resource_group -class Sku(Model): +class Sku(msrest.serialization.Model): """SKU for the resource. :param name: The SKU name. @@ -1315,7 +1627,17 @@ class Sku(Model): 'capacity': {'key': 'capacity', 'type': 'int'}, } - def __init__(self, *, name: str=None, tier: str=None, size: str=None, family: str=None, model: str=None, capacity: int=None, **kwargs) -> None: + def __init__( + self, + *, + name: Optional[str] = None, + tier: Optional[str] = None, + size: Optional[str] = None, + family: Optional[str] = None, + model: Optional[str] = None, + capacity: Optional[int] = None, + **kwargs + ): super(Sku, self).__init__(**kwargs) self.name = name self.tier = tier @@ -1325,10 +1647,10 @@ def __init__(self, *, name: str=None, tier: str=None, size: str=None, family: st self.capacity = capacity -class SubResource(Model): +class SubResource(msrest.serialization.Model): """Sub-resource. - :param id: Resource ID + :param id: Resource ID. :type id: str """ @@ -1336,12 +1658,17 @@ class SubResource(Model): 'id': {'key': 'id', 'type': 'str'}, } - def __init__(self, *, id: str=None, **kwargs) -> None: + def __init__( + self, + *, + id: Optional[str] = None, + **kwargs + ): super(SubResource, self).__init__(**kwargs) self.id = id -class TagCount(Model): +class TagCount(msrest.serialization.Model): """Tag count. :param type: Type of count. @@ -1355,29 +1682,32 @@ class TagCount(Model): 'value': {'key': 'value', 'type': 'int'}, } - def __init__(self, *, type: str=None, value: int=None, **kwargs) -> None: + def __init__( + self, + *, + type: Optional[str] = None, + value: Optional[int] = None, + **kwargs + ): super(TagCount, self).__init__(**kwargs) self.type = type self.value = value -class TagDetails(Model): +class TagDetails(msrest.serialization.Model): """Tag details. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :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 created and has no associated resources, the value - is 0. + :param 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] + :type values: list[~azure.mgmt.resource.resources.v2018_02_01.models.TagValue] """ _validation = { @@ -1391,7 +1721,14 @@ class TagDetails(Model): 'values': {'key': 'values', 'type': '[TagValue]'}, } - def __init__(self, *, tag_name: str=None, count=None, values=None, **kwargs) -> None: + def __init__( + self, + *, + tag_name: Optional[str] = None, + count: Optional["TagCount"] = None, + values: Optional[List["TagValue"]] = None, + **kwargs + ): super(TagDetails, self).__init__(**kwargs) self.id = None self.tag_name = tag_name @@ -1399,11 +1736,41 @@ def __init__(self, *, tag_name: str=None, count=None, values=None, **kwargs) -> self.values = values -class TagValue(Model): +class TagsListResult(msrest.serialization.Model): + """List of subscription tags. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[TagDetails]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["TagDetails"]] = None, + **kwargs + ): + super(TagsListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class TagValue(msrest.serialization.Model): """Tag information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The tag ID. :vartype id: str @@ -1423,14 +1790,20 @@ class TagValue(Model): 'count': {'key': 'count', 'type': 'TagCount'}, } - def __init__(self, *, tag_value: str=None, count=None, **kwargs) -> None: + def __init__( + self, + *, + tag_value: Optional[str] = None, + count: Optional["TagCount"] = None, + **kwargs + ): super(TagValue, self).__init__(**kwargs) self.id = None self.tag_value = tag_value self.count = count -class TargetResource(Model): +class TargetResource(msrest.serialization.Model): """Target resource. :param id: The ID of the resource. @@ -1447,16 +1820,22 @@ class TargetResource(Model): 'resource_type': {'key': 'resourceType', 'type': 'str'}, } - def __init__(self, *, id: str=None, resource_name: str=None, resource_type: str=None, **kwargs) -> None: + def __init__( + self, + *, + id: Optional[str] = None, + resource_name: Optional[str] = None, + resource_type: Optional[str] = None, + **kwargs + ): super(TargetResource, self).__init__(**kwargs) self.id = id self.resource_name = resource_name self.resource_type = resource_type -class TemplateHashResult(Model): - """Result of the request to calculate template hash. It contains a string of - minified template and its hash. +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 @@ -1469,21 +1848,26 @@ class TemplateHashResult(Model): 'template_hash': {'key': 'templateHash', 'type': 'str'}, } - def __init__(self, *, minified_template: str=None, template_hash: str=None, **kwargs) -> None: + def __init__( + self, + *, + minified_template: Optional[str] = None, + template_hash: Optional[str] = None, + **kwargs + ): super(TemplateHashResult, self).__init__(**kwargs) self.minified_template = minified_template self.template_hash = template_hash -class TemplateLink(Model): +class TemplateLink(msrest.serialization.Model): """Entity representing the reference to the template. 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. + :param content_version: If included, must match the ContentVersion in the template. :type content_version: str """ @@ -1496,7 +1880,13 @@ class TemplateLink(Model): 'content_version': {'key': 'contentVersion', 'type': 'str'}, } - def __init__(self, *, uri: str, content_version: str=None, **kwargs) -> None: + def __init__( + self, + *, + uri: str, + content_version: Optional[str] = None, + **kwargs + ): 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/v2018_02_01/models/_paged_models.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/models/_paged_models.py deleted file mode 100644 index 63baad6afdd9..000000000000 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/models/_paged_models.py +++ /dev/null @@ -1,92 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.paging import Paged - - -class DeploymentExtendedPaged(Paged): - """ - A paging container for iterating over a list of :class:`DeploymentExtended ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[DeploymentExtended]'} - } - - def __init__(self, *args, **kwargs): - - super(DeploymentExtendedPaged, self).__init__(*args, **kwargs) -class ProviderPaged(Paged): - """ - A paging container for iterating over a list of :class:`Provider ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[Provider]'} - } - - def __init__(self, *args, **kwargs): - - super(ProviderPaged, self).__init__(*args, **kwargs) -class GenericResourceExpandedPaged(Paged): - """ - A paging container for iterating over a list of :class:`GenericResourceExpanded ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[GenericResourceExpanded]'} - } - - def __init__(self, *args, **kwargs): - - super(GenericResourceExpandedPaged, self).__init__(*args, **kwargs) -class ResourceGroupPaged(Paged): - """ - A paging container for iterating over a list of :class:`ResourceGroup ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[ResourceGroup]'} - } - - def __init__(self, *args, **kwargs): - - super(ResourceGroupPaged, self).__init__(*args, **kwargs) -class TagDetailsPaged(Paged): - """ - A paging container for iterating over a list of :class:`TagDetails ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[TagDetails]'} - } - - def __init__(self, *args, **kwargs): - - super(TagDetailsPaged, self).__init__(*args, **kwargs) -class DeploymentOperationPaged(Paged): - """ - A paging container for iterating over a list of :class:`DeploymentOperation ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[DeploymentOperation]'} - } - - def __init__(self, *args, **kwargs): - - super(DeploymentOperationPaged, self).__init__(*args, **kwargs) 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 9fd73ca1de47..fb982486e0e9 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 @@ -1,30 +1,35 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from enum import Enum - class DeploymentMode(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 + the resource group that are not included in the template are deleted. Be careful when using + Complete mode as you may unintentionally delete resources. + """ incremental = "Incremental" complete = "Complete" - class OnErrorDeploymentType(str, Enum): + """The deployment on error behavior type. Possible values are LastSuccessful and + SpecificDeployment. + """ last_successful = "LastSuccessful" specific_deployment = "SpecificDeployment" - class ResourceIdentityType(str, Enum): + """The identity type. + """ system_assigned = "SystemAssigned" user_assigned = "UserAssigned" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/operations/__init__.py index 7ec2787ace60..75e22640321c 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/operations/__init__.py @@ -1,12 +1,9 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from ._deployments_operations import DeploymentsOperations @@ -14,7 +11,7 @@ from ._resources_operations import ResourcesOperations from ._resource_groups_operations import ResourceGroupsOperations from ._tags_operations import TagsOperations -from ._deployment_operations import DeploymentOperations +from ._deployment_operations_operations import DeploymentOperationsOperations __all__ = [ 'DeploymentsOperations', @@ -22,5 +19,5 @@ 'ResourcesOperations', 'ResourceGroupsOperations', 'TagsOperations', - 'DeploymentOperations', + 'DeploymentOperationsOperations', ] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/operations/_deployment_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/operations/_deployment_operations.py deleted file mode 100644 index 5594cf38c0de..000000000000 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/operations/_deployment_operations.py +++ /dev/null @@ -1,184 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError - -from .. import models - - -class DeploymentOperations(object): - """DeploymentOperations operations. - - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. - - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for this operation. Constant value: "2018-02-01". - """ - - models = models - - def __init__(self, client, config, serializer, deserializer): - - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self.api_version = "2018-02-01" - - self.config = config - - def get( - self, resource_group_name, deployment_name, operation_id, custom_headers=None, raw=False, **operation_config): - """Gets a deployments operation. - - :param resource_group_name: The name of the resource group. The name - is case insensitive. - :type resource_group_name: str - :param deployment_name: The name of the deployment. - :type deployment_name: str - :param operation_id: The ID of the operation to get. - :type operation_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentOperation or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentOperation - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` - """ - # Construct URL - url = self.get.metadata['url'] - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, 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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) - - if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentOperation', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}'} - - def list( - self, resource_group_name, deployment_name, top=None, custom_headers=None, raw=False, **operation_config): - """Gets all deployments operations for a deployment. - - :param resource_group_name: The name of the resource group. The name - is case insensitive. - :type resource_group_name: str - :param deployment_name: The name of the deployment with the operation - to get. - :type deployment_name: str - :param top: The number of results to return. - :type top: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of DeploymentOperation - :rtype: - ~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentOperationPaged[~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentOperation] - :raises: :class:`CloudError` - """ - def prepare_request(next_link=None): - if not next_link: - # Construct URL - url = self.list.metadata['url'] - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - else: - url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) - return request - - def internal_paging(next_link=None): - request = prepare_request(next_link) - - response = self._client.send(request, stream=False, **operation_config) - - if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response - - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.DeploymentOperationPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations'} 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 new file mode 100644 index 000000000000..9154845fb691 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/operations/_deployment_operations_operations.py @@ -0,0 +1,184 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class DeploymentOperationsOperations(object): + """DeploymentOperationsOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2018_02_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def get( + self, + resource_group_name, # type: str + deployment_name, # type: str + operation_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentOperation" + """Gets a deployments operation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param operation_id: The ID of the operation to get. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentOperation or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentOperation + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentOperation"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-02-01" + + # Construct URL + url = self.get.metadata['url'] # type: 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'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentOperation', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + def list( + self, + resource_group_name, # type: str + deployment_name, # type: str + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.DeploymentOperationsListResult"] + """Gets all deployments operations for a deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment with the operation to get. + :type deployment_name: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-02-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentOperationsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations'} # type: ignore 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 5012310faf04..1d36b4ff44b7 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 @@ -1,700 +1,685 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError -from msrest.polling import LROPoller, NoPolling -from msrestazure.polling.arm_polling import ARMPolling +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class DeploymentsOperations(object): """DeploymentsOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2018_02_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for this operation. Constant value: "2018-02-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2018-02-01" - - self.config = config - + self._config = config def _delete_initial( - self, resource_group_name, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-02-01" + # Construct URL - url = self.delete.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [202, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - - def delete( - self, resource_group_name, deployment_name, custom_headers=None, raw=False, polling=True, **operation_config): - """Deletes a deployment from the deployment history. - - A template deployment that is currently running cannot be deleted. - Deleting a template deployment removes the associated deployment - operations. Deleting a template deployment does not affect the state of - the resource group. This is an asynchronous operation that returns a - status of 202 until the template deployment is successfully deleted. - The Location response header contains the URI that is used to obtain - the status of the process. While the process is running, a call to the - URI in the Location header returns a status of 202. When the process - finishes, the URI in the Location header returns a status of 204 on - success. If the asynchronous request failed, the URI in the Location - header returns an error-level status code. - - :param resource_group_name: The name of the resource group with the - deployment to delete. The name is case insensitive. + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + def begin_delete( + self, + resource_group_name, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """A template deployment that is currently running cannot be deleted. Deleting a template deployment removes the associated deployment operations. Deleting a template deployment does not affect the state of the resource group. This is an asynchronous operation that returns a status of 202 until the template deployment is successfully deleted. The Location response header contains the URI that is used to obtain the status of the process. While the process is running, a call to the URI in the Location header returns a status of 202. When the process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. + + Deletes a deployment from the deployment history. + + :param resource_group_name: The name of the resource group with the deployment to delete. The + name is case insensitive. :type resource_group_name: str :param deployment_name: The name of the deployment to delete. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns None or - ClientRawResponse if raw==True - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._delete_initial( resource_group_name=resource_group_name, deployment_name=deployment_name, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore def check_existence( - self, resource_group_name, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Checks whether the deployment exists. - :param resource_group_name: The name of the resource group with the - deployment to check. The name is case insensitive. + :param resource_group_name: The name of the resource group with the deployment to check. The + name is case insensitive. :type resource_group_name: str :param deployment_name: The name of the deployment to check. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: bool or ClientRawResponse if raw=true - :rtype: bool or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-02-01" + # Construct URL - url = self.check_existence.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204, 404]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = (response.status_code == 204) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - return deserialized - check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + if cls: + return cls(pipeline_response, None, {}) + + 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, deployment_name, properties, custom_headers=None, raw=False, **operation_config): - parameters = models.Deployment(properties=properties) + self, + resource_group_name, # type: str + deployment_name, # type: str + properties, # type: "models.DeploymentProperties" + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentExtended" + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.Deployment(properties=properties) + api_version = "2018-02-01" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.create_or_update.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'Deployment') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 201]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', response) + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', response) + deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - - def create_or_update( - self, resource_group_name, deployment_name, properties, custom_headers=None, raw=False, polling=True, **operation_config): - """Deploys resources to a resource group. - - You can provide the template and parameters directly in the request or - link to JSON files. - - :param resource_group_name: The name of the resource group to deploy - the resources to. The name is case insensitive. The resource group - must already exist. + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + def begin_create_or_update( + self, + resource_group_name, # type: str + deployment_name, # type: str + properties, # type: "models.DeploymentProperties" + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """You can provide the template and parameters directly in the request or link to JSON files. + + Deploys resources to a resource group. + + :param resource_group_name: The name of the resource group to deploy the resources to. The name + is case insensitive. The resource group must already exist. :type resource_group_name: str :param deployment_name: The name of the deployment. :type deployment_name: str :param properties: The deployment properties. - :type properties: - ~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentProperties - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :type properties: ~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentProperties + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns DeploymentExtended or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentExtended] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentExtended]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 DeploymentExtended + :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] + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._create_or_update_initial( resource_group_name=resource_group_name, deployment_name=deployment_name, properties=properties, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - deserialized = self._deserialize('DeploymentExtended', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore def get( - self, resource_group_name, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentExtended" """Gets a deployment. - :param resource_group_name: The name of the resource group. The name - is case insensitive. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param deployment_name: The name of the deployment to get. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentExtended or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentExtended - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExtended or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentExtended + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-02-01" + # Construct URL - url = self.get.metadata['url'] + url = self.get.metadata['url'] # type: 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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', response) + deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore def cancel( - self, resource_group_name, deployment_name, custom_headers=None, raw=False, **operation_config): - """Cancels a currently running template deployment. + self, + resource_group_name, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """You can cancel a deployment only if the provisioningState is Accepted or Running. After the deployment is canceled, the provisioningState is set to Canceled. Canceling a template deployment stops the currently running template deployment and leaves the resource group partially deployed. - You can cancel a deployment only if the provisioningState is Accepted - or Running. After the deployment is canceled, the provisioningState is - set to Canceled. Canceling a template deployment stops the currently - running template deployment and leaves the resource group partially - deployed. + Cancels a currently running template deployment. - :param resource_group_name: The name of the resource group. The name - is case insensitive. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param deployment_name: The name of the deployment to cancel. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-02-01" + # Construct URL - url = self.cancel.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - cancel.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} + if cls: + return cls(pipeline_response, None, {}) - def validate( - self, resource_group_name, deployment_name, properties, custom_headers=None, raw=False, **operation_config): - """Validates whether the specified template is syntactically correct and - will be accepted by Azure Resource Manager.. + cancel.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore - :param resource_group_name: The name of the resource group the - template will be deployed to. The name is case insensitive. + def validate( + self, + resource_group_name, # type: str + deployment_name, # type: str + properties, # type: "models.DeploymentProperties" + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentValidateResult" + """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. :type resource_group_name: str :param deployment_name: The name of the deployment. :type deployment_name: str :param properties: The deployment properties. - :type properties: - ~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentProperties - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentValidateResult or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentValidateResult - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :type properties: ~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentProperties + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentValidateResult + :raises: ~azure.core.exceptions.HttpResponseError """ - parameters = models.Deployment(properties=properties) + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentValidateResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.Deployment(properties=properties) + api_version = "2018-02-01" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.validate.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'Deployment') # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 400]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', response) + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', response) + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - validate.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} + validate.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore def export_template( - self, resource_group_name, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentExportResult" """Exports the template used for specified deployment. - :param resource_group_name: The name of the resource group. The name - is case insensitive. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str - :param deployment_name: The name of the deployment from which to get - the template. + :param deployment_name: The name of the deployment from which to get the template. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentExportResult or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentExportResult - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentExportResult + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExportResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-02-01" + # Construct URL - url = self.export_template.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentExportResult', response) + deserialized = self._deserialize('DeploymentExportResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} + export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore def list_by_resource_group( - self, resource_group_name, filter=None, top=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.DeploymentListResult"] """Get all the deployments for a resource group. - :param resource_group_name: The name of the resource group with the - deployments to get. The name is case insensitive. + :param resource_group_name: The name of the resource group with the deployments to get. The + name is case insensitive. :type resource_group_name: str - :param filter: The filter to apply on the operation. For example, you - can use $filter=provisioningState eq '{state}'. + :param filter: The filter to apply on the operation. For example, you can use + $filter=provisioningState eq '{state}'. :type filter: str - :param top: The number of results to get. If null is passed, returns - all deployments. + :param top: The number of results to get. If null is passed, returns all deployments. :type top: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of DeploymentExtended - :rtype: - ~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentExtendedPaged[~azure.mgmt.resource.resources.v2018_02_01.models.DeploymentExtended] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-02-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_by_resource_group.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.DeploymentExtendedPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/'} + return ItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/'} # type: ignore def calculate_template_hash( - self, template, custom_headers=None, raw=False, **operation_config): + self, + template, # type: object + **kwargs # type: Any + ): + # type: (...) -> "models.TemplateHashResult" """Calculate the hash of the given template. :param template: The template provided to calculate hash. :type template: object - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: TemplateHashResult or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2018_02_01.models.TemplateHashResult - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateHashResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.TemplateHashResult + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TemplateHashResult"] + error_map = {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.calculate_template_hash.metadata['url'] + url = self.calculate_template_hash.metadata['url'] # type: ignore # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(template, 'object') # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('TemplateHashResult', response) + deserialized = self._deserialize('TemplateHashResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - calculate_template_hash.metadata = {'url': '/providers/Microsoft.Resources/calculateTemplateHash'} + 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 5c8aaad439f5..d2daec7ba5b5 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 @@ -1,300 +1,287 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class ProvidersOperations(object): """ProvidersOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2018_02_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for this operation. Constant value: "2018-02-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2018-02-01" - - self.config = config + self._config = config def unregister( - self, resource_provider_namespace, custom_headers=None, raw=False, **operation_config): + self, + resource_provider_namespace, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.Provider" """Unregisters a subscription from a resource provider. - :param resource_provider_namespace: The namespace of the resource - provider to unregister. + :param resource_provider_namespace: The namespace of the resource provider to unregister. :type resource_provider_namespace: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: Provider or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.Provider or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Provider or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.Provider + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Provider"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-02-01" + # Construct URL - url = self.unregister.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('Provider', response) + deserialized = self._deserialize('Provider', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - unregister.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister'} + unregister.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister'} # type: ignore def register( - self, resource_provider_namespace, custom_headers=None, raw=False, **operation_config): + self, + resource_provider_namespace, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.Provider" """Registers a subscription with a resource provider. - :param resource_provider_namespace: The namespace of the resource - provider to register. + :param resource_provider_namespace: The namespace of the resource provider to register. :type resource_provider_namespace: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: Provider or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.Provider or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Provider or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.Provider + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Provider"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-02-01" + # Construct URL - url = self.register.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('Provider', response) + deserialized = self._deserialize('Provider', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - register.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register'} + register.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register'} # type: ignore def list( - self, top=None, expand=None, custom_headers=None, raw=False, **operation_config): + self, + top=None, # type: Optional[int] + expand=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.ProviderListResult"] """Gets all resource providers for a subscription. - :param top: The number of results to return. If null is passed returns - all deployments. + :param top: The number of results to return. If null is passed returns all deployments. :type top: int - :param expand: The properties to include in the results. For example, - use &$expand=metadata in the query string to retrieve resource - provider metadata. To include property aliases in response, use - $expand=resourceTypes/aliases. + :param expand: The properties to include in the results. For example, use &$expand=metadata in + the query string to retrieve resource provider metadata. To include property aliases in + response, use $expand=resourceTypes/aliases. :type expand: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of Provider - :rtype: - ~azure.mgmt.resource.resources.v2018_02_01.models.ProviderPaged[~azure.mgmt.resource.resources.v2018_02_01.models.Provider] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of ProviderListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-02-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['url'] + url = self.list.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_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 = {} + 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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('ProviderListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.ProviderPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers'} # type: ignore def get( - self, resource_provider_namespace, expand=None, custom_headers=None, raw=False, **operation_config): + self, + resource_provider_namespace, # type: str + expand=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.Provider" """Gets the specified resource provider. - :param resource_provider_namespace: The namespace of the resource - provider. + :param resource_provider_namespace: The namespace of the resource provider. :type resource_provider_namespace: str - :param expand: The $expand query parameter. For example, to include - property aliases in response, use $expand=resourceTypes/aliases. + :param expand: The $expand query parameter. For example, to include property aliases in + response, use $expand=resourceTypes/aliases. :type expand: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: Provider or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.Provider or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Provider or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.Provider + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Provider"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-02-01" + # Construct URL - url = self.get.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('Provider', response) + deserialized = self._deserialize('Provider', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}'} + 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 0c957ce702c7..ea5fe773af40 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 @@ -1,526 +1,513 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError -from msrest.polling import LROPoller, NoPolling -from msrestazure.polling.arm_polling import ARMPolling +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, List, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class ResourceGroupsOperations(object): """ResourceGroupsOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2018_02_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for this operation. Constant value: "2018-02-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2018-02-01" - - self.config = config + self._config = config def check_existence( - self, resource_group_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Checks whether a resource group exists. - :param resource_group_name: The name of the resource group to check. - The name is case insensitive. + :param resource_group_name: The name of the resource group to check. The name is case + insensitive. :type resource_group_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: bool or ClientRawResponse if raw=true - :rtype: bool or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-02-01" + # Construct URL - url = self.check_existence.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204, 404]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = (response.status_code == 204) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - return deserialized - check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore def create_or_update( - self, resource_group_name, parameters, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + parameters, # type: "models.ResourceGroup" + **kwargs # type: Any + ): + # type: (...) -> "models.ResourceGroup" """Creates or updates a resource group. - :param resource_group_name: The name of the resource group to create - or update. + :param resource_group_name: The name of the resource group to create or update. :type resource_group_name: str - :param parameters: Parameters supplied to the create or update a - resource group. - :type parameters: - ~azure.mgmt.resource.resources.v2018_02_01.models.ResourceGroup - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: ResourceGroup or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2018_02_01.models.ResourceGroup or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :param parameters: Parameters supplied to the create or update a resource group. + :type parameters: ~azure.mgmt.resource.resources.v2018_02_01.models.ResourceGroup + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.ResourceGroup + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceGroup"] + error_map = {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.create_or_update.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'ResourceGroup') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 201]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ResourceGroup', response) + deserialized = self._deserialize('ResourceGroup', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('ResourceGroup', response) + deserialized = self._deserialize('ResourceGroup', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} - + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore def _delete_initial( - self, resource_group_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-02-01" + # Construct URL - url = self.delete.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 202]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore - def delete( - self, resource_group_name, custom_headers=None, raw=False, polling=True, **operation_config): - """Deletes a resource group. + def begin_delete( + self, + resource_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """When you delete a resource group, all of its resources are also deleted. Deleting a resource group deletes all of its template deployments and currently stored operations. - When you delete a resource group, all of its resources are also - deleted. Deleting a resource group deletes all of its template - deployments and currently stored operations. + Deletes a resource group. - :param resource_group_name: The name of the resource group to delete. - The name is case insensitive. + :param resource_group_name: The name of the resource group to delete. The name is case + insensitive. :type resource_group_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns None or - ClientRawResponse if raw==True - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._delete_initial( resource_group_name=resource_group_name, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore def get( - self, resource_group_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.ResourceGroup" """Gets a resource group. - :param resource_group_name: The name of the resource group to get. The - name is case insensitive. + :param resource_group_name: The name of the resource group to get. The name is case + insensitive. :type resource_group_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: ResourceGroup or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2018_02_01.models.ResourceGroup or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.ResourceGroup + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceGroup"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-02-01" + # Construct URL - url = self.get.metadata['url'] + url = self.get.metadata['url'] # type: 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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('ResourceGroup', response) + deserialized = self._deserialize('ResourceGroup', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore def update( - self, resource_group_name, parameters, custom_headers=None, raw=False, **operation_config): - """Updates a resource group. - - Resource groups can be updated through a simple PATCH operation to a - group address. The format of the request is the same as that for - creating a resource group. If a field is unspecified, the current value - is retained. - - :param resource_group_name: The name of the resource group to update. - The name is case insensitive. + self, + resource_group_name, # type: str + parameters, # type: "models.ResourceGroupPatchable" + **kwargs # type: Any + ): + # type: (...) -> "models.ResourceGroup" + """Resource groups can be updated through a simple PATCH operation to a group address. The format of the request is the same as that for creating a resource group. If a field is unspecified, the current value is retained. + + Updates a resource group. + + :param resource_group_name: The name of the resource group to update. The name is case + insensitive. :type resource_group_name: str :param parameters: Parameters supplied to update a resource group. - :type parameters: - ~azure.mgmt.resource.resources.v2018_02_01.models.ResourceGroupPatchable - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: ResourceGroup or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2018_02_01.models.ResourceGroup or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :type parameters: ~azure.mgmt.resource.resources.v2018_02_01.models.ResourceGroupPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.ResourceGroup + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceGroup"] + error_map = {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.update.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'ResourceGroupPatchable') # Construct and send request - request = self._client.patch(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('ResourceGroup', response) + deserialized = self._deserialize('ResourceGroup', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore def export_template( - self, resource_group_name, resources=None, options=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + resources=None, # type: Optional[List[str]] + options=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.ResourceGroupExportResult" """Captures the specified resource group as a template. - :param resource_group_name: The name of the resource group to export - as a template. + :param resource_group_name: The name of the resource group to export as a template. :type resource_group_name: str - :param resources: The IDs of the resources to filter the export by. To - export all resources, supply an array with single entry '*'. + :param 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', - 'SkipResourceNameParameterization', 'SkipAllParameterization' + :param options: The export template options. A CSV-formatted list containing zero or more of + the following: 'IncludeParameterDefaultValue', 'IncludeComments', + 'SkipResourceNameParameterization', 'SkipAllParameterization'. :type options: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: ResourceGroupExportResult or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2018_02_01.models.ResourceGroupExportResult - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroupExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.ResourceGroupExportResult + :raises: ~azure.core.exceptions.HttpResponseError """ - parameters = models.ExportTemplateRequest(resources=resources, options=options) + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceGroupExportResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.ExportTemplateRequest(resources=resources, options=options) + api_version = "2018-02-01" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.export_template.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'ExportTemplateRequest') # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('ResourceGroupExportResult', response) + deserialized = self._deserialize('ResourceGroupExportResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate'} + export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate'} # type: ignore def list( - self, filter=None, top=None, custom_headers=None, raw=False, **operation_config): + self, + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.ResourceGroupListResult"] """Gets all the resource groups for a subscription. :param filter: The filter to apply on the operation. :type filter: str - :param top: The number of results to return. If null is passed, - returns all resource groups. + :param top: The number of results to return. If null is passed, returns all resource groups. :type top: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of ResourceGroup - :rtype: - ~azure.mgmt.resource.resources.v2018_02_01.models.ResourceGroupPaged[~azure.mgmt.resource.resources.v2018_02_01.models.ResourceGroup] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-02-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['url'] + url = self.list.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_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 = {} + 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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('ResourceGroupListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.ResourceGroupPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups'} # type: ignore 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 4a473e543e23..01802a39236f 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 @@ -1,521 +1,551 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError -from msrest.polling import LROPoller, NoPolling -from msrestazure.polling.arm_polling import ARMPolling +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, List, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class ResourcesOperations(object): """ResourcesOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2018_02_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for this operation. Constant value: "2018-02-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2018-02-01" - - self.config = config + self._config = config def list_by_resource_group( - self, resource_group_name, filter=None, expand=None, top=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + filter=None, # type: Optional[str] + expand=None, # type: Optional[str] + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.ResourceListResult"] """Get all the resources for a resource group. - :param resource_group_name: The resource group with the resources to - get. + :param resource_group_name: The resource group with the resources to get. :type resource_group_name: str :param filter: The filter to apply on the operation. :type filter: str - :param expand: Comma-separated list of additional properties to be - included in the response. Valid values include `createdTime`, - `changedTime` and `provisioningState`. For example, - `$expand=createdTime,changedTime`. + :param expand: Comma-separated list of additional properties to be included in the response. + Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, + ``$expand=createdTime,changedTime``. :type expand: str - :param top: The 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 - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of GenericResourceExpanded - :rtype: - ~azure.mgmt.resource.resources.v2018_02_01.models.GenericResourceExpandedPaged[~azure.mgmt.resource.resources.v2018_02_01.models.GenericResourceExpanded] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of ResourceListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-02-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_by_resource_group.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('ResourceListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response - - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.GenericResourceExpandedPaged(internal_paging, self._deserialize.dependencies, header_dict) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return deserialized - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources'} + return pipeline_response + return ItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources'} # type: ignore def _move_resources_initial( - self, source_resource_group_name, resources=None, target_resource_group=None, custom_headers=None, raw=False, **operation_config): - parameters = models.ResourcesMoveInfo(resources=resources, target_resource_group=target_resource_group) + self, + source_resource_group_name, # type: str + resources=None, # type: Optional[List[str]] + target_resource_group=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.ResourcesMoveInfo(resources=resources, target_resource_group=target_resource_group) + api_version = "2018-02-01" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.move_resources.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'ResourcesMoveInfo') + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [202, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - - def move_resources( - self, source_resource_group_name, resources=None, target_resource_group=None, custom_headers=None, raw=False, polling=True, **operation_config): - """Moves resources from one resource group to another resource group. - - The resources to move must be in the same source resource group. The - target resource group may be in a different subscription. When moving - resources, both the source group and the target group are locked for - the duration of the operation. Write and delete operations are blocked - on the groups until the move completes. . - - :param source_resource_group_name: The name of the resource group - containing the resources to move. + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore + + def begin_move_resources( + self, + source_resource_group_name, # type: str + resources=None, # type: Optional[List[str]] + target_resource_group=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """The resources to move must be in the same source resource group. The target resource group may be in a different subscription. When moving resources, both the source group and the target group are locked for the duration of the operation. Write and delete operations are blocked on the groups until the move completes. + + Moves resources from one resource group to another resource group. + + :param source_resource_group_name: The name of the resource group containing the resources to + move. :type source_resource_group_name: str :param resources: The IDs of the resources. :type resources: list[str] :param target_resource_group: The target resource group. :type target_resource_group: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns None or - ClientRawResponse if raw==True - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._move_resources_initial( source_resource_group_name=source_resource_group_name, resources=resources, target_resource_group=target_resource_group, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} - + begin_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore def _validate_move_resources_initial( - self, source_resource_group_name, resources=None, target_resource_group=None, custom_headers=None, raw=False, **operation_config): - parameters = models.ResourcesMoveInfo(resources=resources, target_resource_group=target_resource_group) + self, + source_resource_group_name, # type: str + resources=None, # type: Optional[List[str]] + target_resource_group=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.ResourcesMoveInfo(resources=resources, target_resource_group=target_resource_group) + api_version = "2018-02-01" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.validate_move_resources.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'ResourcesMoveInfo') + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [202, 204, 409]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - - def validate_move_resources( - self, source_resource_group_name, resources=None, target_resource_group=None, custom_headers=None, raw=False, polling=True, **operation_config): - """Validates whether resources can be moved from one resource group to - another resource group. - - This operation checks whether the specified resources can be moved to - the target. The resources to move must be in the same source resource - group. The target resource group may be in a different subscription. If - validation succeeds, it returns HTTP response code 204 (no content). If - validation fails, it returns HTTP response code 409 (Conflict) with an - error message. Retrieve the URL in the Location header value to check - the result of the long-running operation. - - :param source_resource_group_name: The name of the resource group - containing the resources to validate for move. + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _validate_move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} # type: ignore + + def begin_validate_move_resources( + self, + source_resource_group_name, # type: str + resources=None, # type: Optional[List[str]] + target_resource_group=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """This operation checks whether the specified resources can be moved to the target. The resources to move must be in the same source resource group. The target resource group may be in a different subscription. If validation succeeds, it returns HTTP response code 204 (no content). If validation fails, it returns HTTP response code 409 (Conflict) with an error message. Retrieve the URL in the Location header value to check the result of the long-running operation. + + Validates whether resources can be moved from one resource group to another resource group. + + :param source_resource_group_name: The name of the resource group containing the resources to + validate for move. :type source_resource_group_name: str :param resources: The IDs of the resources. :type resources: list[str] :param target_resource_group: The target resource group. :type target_resource_group: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns None or - ClientRawResponse if raw==True - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._validate_move_resources_initial( source_resource_group_name=source_resource_group_name, resources=resources, target_resource_group=target_resource_group, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - validate_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} + begin_validate_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} # type: ignore def list( - self, filter=None, expand=None, top=None, custom_headers=None, raw=False, **operation_config): + self, + filter=None, # type: Optional[str] + expand=None, # type: Optional[str] + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.ResourceListResult"] """Get all the resources in a subscription. :param filter: The filter to apply on the operation. :type filter: str :param expand: The $expand query parameter. :type expand: str - :param top: The number of results to return. If null is passed, - returns all resource groups. + :param top: The number of results to return. If null is passed, returns all resource groups. :type top: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of GenericResourceExpanded - :rtype: - ~azure.mgmt.resource.resources.v2018_02_01.models.GenericResourceExpandedPaged[~azure.mgmt.resource.resources.v2018_02_01.models.GenericResourceExpanded] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of ResourceListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-02-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['url'] + url = self.list.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_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 = {} + 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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('ResourceListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.GenericResourceExpandedPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resources'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resources'} # type: ignore def check_existence( - self, resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, api_version, custom_headers=None, raw=False, **operation_config): + self, + 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: (...) -> None """Checks whether a resource exists. - :param resource_group_name: The name of the resource group containing - the resource to check. The name is case insensitive. + :param resource_group_name: The name of the resource group containing the resource to check. + The name is case insensitive. :type resource_group_name: str - :param resource_provider_namespace: The resource provider of the - resource to check. + :param resource_provider_namespace: The resource provider of the resource to check. :type resource_provider_namespace: str :param parent_resource_path: The parent resource identity. :type parent_resource_path: str :param resource_type: The resource type. :type resource_type: str - :param resource_name: The name of the resource to check whether it - exists. + :param resource_name: The name of the resource to check whether it exists. :type resource_name: str - :param api_version: The API version to use for the operation. - :type api_version: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: bool or ClientRawResponse if raw=true - :rtype: bool or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-02-01" + # Construct URL - url = self.check_existence.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204, 404]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = (response.status_code == 204) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - return deserialized - check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + 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, resource_provider_namespace, parent_resource_path, resource_type, resource_name, api_version, custom_headers=None, raw=False, **operation_config): + self, + 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: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-02-01" + # Construct URL - url = self.delete.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - - def delete( - self, resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, api_version, custom_headers=None, raw=False, polling=True, **operation_config): + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + def begin_delete( + self, + 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: (...) -> LROPoller """Deletes a resource. - :param resource_group_name: The name of the resource group that - contains the resource to delete. The name is case insensitive. + :param resource_group_name: The name of the resource group that contains the resource to + delete. The name is case insensitive. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource - provider. + :param resource_provider_namespace: The namespace of the resource provider. :type resource_provider_namespace: str :param parent_resource_path: The parent resource identity. :type parent_resource_path: str @@ -523,109 +553,122 @@ def delete( :type resource_type: str :param resource_name: The name of the resource to delete. :type resource_name: str - :param api_version: The API version to use for the operation. - :type api_version: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns None or - ClientRawResponse if raw==True - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._delete_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, - api_version=api_version, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} - + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore def _create_or_update_initial( - self, resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, api_version, parameters, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + parameters, # type: "models.GenericResource" + **kwargs # type: Any + ): + # type: (...) -> "models.GenericResource" + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {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.create_or_update.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'GenericResource') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 201, 202]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('GenericResource', response) + deserialized = self._deserialize('GenericResource', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('GenericResource', response) + deserialized = self._deserialize('GenericResource', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - - def create_or_update( - self, resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, api_version, parameters, custom_headers=None, raw=False, polling=True, **operation_config): + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + def begin_create_or_update( + self, + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + parameters, # type: "models.GenericResource" + **kwargs # type: Any + ): + # type: (...) -> LROPoller """Creates a resource. - :param resource_group_name: The name of the resource group for the - resource. The name is case insensitive. + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource - provider. + :param resource_provider_namespace: The namespace of the resource provider. :type resource_provider_namespace: str :param parent_resource_path: The parent resource identity. :type parent_resource_path: str @@ -633,117 +676,125 @@ def create_or_update( :type resource_type: str :param resource_name: The name of the resource to create. :type resource_name: str - :param api_version: The API version to use for the operation. - :type api_version: str :param parameters: Parameters for creating or updating the resource. - :type parameters: - ~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :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 polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns GenericResource or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 GenericResource + :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] + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._create_or_update_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, - api_version=api_version, parameters=parameters, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - deserialized = self._deserialize('GenericResource', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('GenericResource', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} - + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore def _update_initial( - self, resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, api_version, parameters, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + parameters, # type: "models.GenericResource" + **kwargs # type: Any + ): + # type: (...) -> "models.GenericResource" + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {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.update.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'GenericResource') # Construct and send request - request = self._client.patch(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 202]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('GenericResource', response) + deserialized = self._deserialize('GenericResource', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - - def update( - self, resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, api_version, parameters, custom_headers=None, raw=False, polling=True, **operation_config): + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + def begin_update( + self, + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + parameters, # type: "models.GenericResource" + **kwargs # type: Any + ): + # type: (...) -> LROPoller """Updates a resource. - :param resource_group_name: The name of the resource group for the - resource. The name is case insensitive. + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource - provider. + :param resource_provider_namespace: The namespace of the resource provider. :type resource_provider_namespace: str :param parent_resource_path: The parent resource identity. :type parent_resource_path: str @@ -751,64 +802,63 @@ def update( :type resource_type: str :param resource_name: The name of the resource to update. :type resource_name: str - :param api_version: The API version to use for the operation. - :type api_version: str :param parameters: Parameters for updating the resource. - :type parameters: - ~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :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 polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns GenericResource or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 GenericResource + :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] + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._update_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, - api_version=api_version, parameters=parameters, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - deserialized = self._deserialize('GenericResource', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('GenericResource', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore def get( - self, resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, api_version, custom_headers=None, raw=False, **operation_config): + self, + 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: (...) -> "models.GenericResource" """Gets a resource. - :param resource_group_name: The name of the resource group containing - the resource to get. The name is case insensitive. + :param resource_group_name: The name of the resource group containing the resource to get. The + name is case insensitive. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource - provider. + :param resource_provider_namespace: The namespace of the resource provider. :type resource_provider_namespace: str :param parent_resource_path: The parent resource identity. :type parent_resource_path: str @@ -816,461 +866,443 @@ def get( :type resource_type: str :param resource_name: The name of the resource to get. :type resource_name: str - :param api_version: The API version to use for the operation. - :type api_version: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: GenericResource or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GenericResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-02-01" + # Construct URL - url = self.get.metadata['url'] + url = self.get.metadata['url'] # type: 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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('GenericResource', response) + deserialized = self._deserialize('GenericResource', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore def check_existence_by_id( - self, resource_id, api_version, custom_headers=None, raw=False, **operation_config): + self, + resource_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Checks by ID whether a resource exists. - :param resource_id: The fully qualified ID of the resource, including - the resource name and resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. :type resource_id: str - :param api_version: The API version to use for the operation. - :type api_version: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: bool or ClientRawResponse if raw=true - :rtype: bool or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-02-01" + # Construct URL - url = self.check_existence_by_id.metadata['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) + '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 = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204, 404]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = (response.status_code == 204) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - return deserialized - check_existence_by_id.metadata = {'url': '/{resourceId}'} + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + return 200 <= response.status_code <= 299 + check_existence_by_id.metadata = {'url': '/{resourceId}'} # type: ignore def _delete_by_id_initial( - self, resource_id, api_version, custom_headers=None, raw=False, **operation_config): + self, + resource_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-02-01" + # Construct URL - url = self.delete_by_id.metadata['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) + '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 = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + _delete_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore - def delete_by_id( - self, resource_id, api_version, custom_headers=None, raw=False, polling=True, **operation_config): + def begin_delete_by_id( + self, + resource_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> LROPoller """Deletes a resource by ID. - :param resource_id: The fully qualified ID of the resource, including - the resource name and resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. :type resource_id: str - :param api_version: The API version to use for the operation. - :type api_version: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns None or - ClientRawResponse if raw==True - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._delete_by_id_initial( resource_id=resource_id, - api_version=api_version, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - delete_by_id.metadata = {'url': '/{resourceId}'} - + begin_delete_by_id.metadata = {'url': '/{resourceId}'} # type: ignore def _create_or_update_by_id_initial( - self, resource_id, api_version, parameters, custom_headers=None, raw=False, **operation_config): + self, + resource_id, # type: str + parameters, # type: "models.GenericResource" + **kwargs # type: Any + ): + # type: (...) -> "models.GenericResource" + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {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.create_or_update_by_id.metadata['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) + '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 = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'GenericResource') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 201, 202]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('GenericResource', response) + deserialized = self._deserialize('GenericResource', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('GenericResource', response) + deserialized = self._deserialize('GenericResource', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - - def create_or_update_by_id( - self, resource_id, api_version, parameters, custom_headers=None, raw=False, polling=True, **operation_config): + _create_or_update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + def begin_create_or_update_by_id( + self, + resource_id, # type: str + parameters, # type: "models.GenericResource" + **kwargs # type: Any + ): + # type: (...) -> LROPoller """Create a resource by ID. - :param resource_id: The fully qualified ID of the resource, including - the resource name and resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. :type resource_id: str - :param api_version: The API version to use for the operation. - :type api_version: str :param parameters: Create or update resource parameters. - :type parameters: - ~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :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 polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns GenericResource or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 GenericResource + :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] + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._create_or_update_by_id_initial( resource_id=resource_id, - api_version=api_version, parameters=parameters, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - deserialized = self._deserialize('GenericResource', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('GenericResource', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - create_or_update_by_id.metadata = {'url': '/{resourceId}'} - + begin_create_or_update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore def _update_by_id_initial( - self, resource_id, api_version, parameters, custom_headers=None, raw=False, **operation_config): + self, + resource_id, # type: str + parameters, # type: "models.GenericResource" + **kwargs # type: Any + ): + # type: (...) -> "models.GenericResource" + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {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.update_by_id.metadata['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) + '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 = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'GenericResource') # Construct and send request - request = self._client.patch(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 202]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('GenericResource', response) + deserialized = self._deserialize('GenericResource', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - - def update_by_id( - self, resource_id, api_version, parameters, custom_headers=None, raw=False, polling=True, **operation_config): + _update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + def begin_update_by_id( + self, + resource_id, # type: str + parameters, # type: "models.GenericResource" + **kwargs # type: Any + ): + # type: (...) -> LROPoller """Updates a resource by ID. - :param resource_id: The fully qualified ID of the resource, including - the resource name and resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. :type resource_id: str - :param api_version: The API version to use for the operation. - :type api_version: str :param parameters: Update resource parameters. - :type parameters: - ~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :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 polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns GenericResource or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 GenericResource + :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] + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._update_by_id_initial( resource_id=resource_id, - api_version=api_version, parameters=parameters, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - deserialized = self._deserialize('GenericResource', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('GenericResource', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - update_by_id.metadata = {'url': '/{resourceId}'} + begin_update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore def get_by_id( - self, resource_id, api_version, custom_headers=None, raw=False, **operation_config): + self, + resource_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.GenericResource" """Gets a resource by ID. - :param resource_id: The fully qualified ID of the resource, including - the resource name and resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. :type resource_id: str - :param api_version: The API version to use for the operation. - :type api_version: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: GenericResource or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GenericResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.GenericResource + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-02-01" + # Construct URL - url = self.get_by_id.metadata['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) + '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 = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('GenericResource', response) + deserialized = self._deserialize('GenericResource', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/{resourceId}'} + 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 dee545bf3450..99e4e37bbd6f 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 @@ -1,340 +1,336 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class TagsOperations(object): """TagsOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2018_02_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for this operation. Constant value: "2018-02-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2018-02-01" - - self.config = config + self._config = config def delete_value( - self, tag_name, tag_value, custom_headers=None, raw=False, **operation_config): + self, + tag_name, # type: str + tag_value, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Deletes a tag value. :param tag_name: The name of the tag. :type tag_name: str :param tag_value: The value of the tag to delete. :type tag_value: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-02-01" + # Construct URL - url = self.delete_value.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} + delete_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore def create_or_update_value( - self, tag_name, tag_value, custom_headers=None, raw=False, **operation_config): + self, + tag_name, # type: str + tag_value, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.TagValue" """Creates a tag value. The name of the tag must already exist. :param tag_name: The name of the tag. :type tag_name: str :param tag_value: The value of the tag to create. :type tag_value: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: TagValue or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.TagValue or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagValue or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.TagValue + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TagValue"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-02-01" + # Construct URL - url = self.create_or_update_value.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.put(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 201]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('TagValue', response) + deserialized = self._deserialize('TagValue', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('TagValue', response) + deserialized = self._deserialize('TagValue', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} + create_or_update_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore def create_or_update( - self, tag_name, custom_headers=None, raw=False, **operation_config): - """Creates a tag in the subscription. + self, + tag_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.TagDetails" + """The tag name can have a maximum of 512 characters and is case insensitive. Tag names created by Azure have prefixes of microsoft, azure, or windows. You cannot create tags with one of these prefixes. - The tag name can have a maximum of 512 characters and is case - insensitive. Tag names created by Azure have prefixes of microsoft, - azure, or windows. You cannot create tags with one of these prefixes. + Creates a tag in the subscription. :param tag_name: The name of the tag to create. :type tag_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: TagDetails or ClientRawResponse if raw=true + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagDetails or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2018_02_01.models.TagDetails - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TagDetails"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-02-01" + # Construct URL - url = self.create_or_update.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.put(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 201]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('TagDetails', response) + deserialized = self._deserialize('TagDetails', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('TagDetails', response) + deserialized = self._deserialize('TagDetails', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore def delete( - self, tag_name, custom_headers=None, raw=False, **operation_config): - """Deletes a tag from the subscription. + self, + tag_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """You must remove all values from a resource tag before you can delete it. - You must remove all values from a resource tag before you can delete - it. + Deletes a tag from the subscription. :param tag_name: The name of the tag. :type tag_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-02-01" + # Construct URL - url = self.delete.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} + delete.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore def list( - self, custom_headers=None, raw=False, **operation_config): - """Gets the names and values of all resource tags that are defined in a - subscription. - - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of TagDetails - :rtype: - ~azure.mgmt.resource.resources.v2018_02_01.models.TagDetailsPaged[~azure.mgmt.resource.resources.v2018_02_01.models.TagDetails] - :raises: :class:`CloudError` + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.TagsListResult"] + """Gets the names and values of all resource tags that are defined in a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of TagsListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-02-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['url'] + url = self.list.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('TagsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.TagDetailsPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/py.typed b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file 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 deleted file mode 100644 index 848a6c9f9e92..000000000000 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_02_01/version.py +++ /dev/null @@ -1,13 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -VERSION = "2018-02-01" - 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 68bc897193ac..fde2ed4c3b83 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 @@ -1,19 +1,16 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._configuration import ResourceManagementClientConfiguration from ._resource_management_client import ResourceManagementClient -__all__ = ['ResourceManagementClient', 'ResourceManagementClientConfiguration'] - -from .version import VERSION - -__version__ = VERSION +__all__ = ['ResourceManagementClient'] +try: + from ._patch import patch_sdk + patch_sdk() +except ImportError: + pass 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 3b326f792363..d4bbd9ddd899 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 @@ -1,48 +1,69 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrestazure import AzureConfiguration -from .version import VERSION +from typing import TYPE_CHECKING +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + + from azure.core.credentials import TokenCredential + +VERSION = "unknown" + +class ResourceManagementClientConfiguration(Configuration): + """Configuration for ResourceManagementClient. -class ResourceManagementClientConfiguration(AzureConfiguration): - """Configuration for ResourceManagementClient Note that all parameters used to create this instance are saved as instance attributes. - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` + :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 """ def __init__( - self, credentials, subscription_id, base_url=None): - - if credentials is None: - raise ValueError("Parameter 'credentials' must not be None.") + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + 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.") - if not base_url: - base_url = 'https://management.azure.com' + super(ResourceManagementClientConfiguration, self).__init__(**kwargs) - super(ResourceManagementClientConfiguration, self).__init__(base_url) - - # Starting Autorest.Python 4.0.64, make connection pool activated by default - self.keep_alive = True - - self.add_user_agent('azure-mgmt-resource/{}'.format(VERSION)) - self.add_user_agent('Azure-SDK-For-Python') - - self.credentials = credentials + self.credential = credential self.subscription_id = subscription_id + self.api_version = "2018-05-01" + self.credential_scopes = ['https://management.azure.com/.default'] + self.credential_scopes.extend(kwargs.pop('credential_scopes', [])) + kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + 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) 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 new file mode 100644 index 000000000000..6e7189cb2e74 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/_metadata.json @@ -0,0 +1,59 @@ +{ + "chosen_version": "2018-05-01", + "total_api_version_list": ["2018-05-01"], + "client": { + "name": "ResourceManagementClient", + "filename": "_resource_management_client", + "description": "Provides operations for working with resources and resource groups." + }, + "global_parameters": { + "sync_method": { + "credential": { + "method_signature": "credential, # type: \"TokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials.TokenCredential", + "required": true + }, + "subscription_id": { + "method_signature": "subscription_id, # type: str", + "description": "The ID of the target subscription.", + "docstring_type": "str", + "required": true + } + }, + "async_method": { + "credential": { + "method_signature": "credential, # type: \"AsyncTokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + }, + "subscription_id": { + "method_signature": "subscription_id, # type: str", + "description": "The ID of the target subscription.", + "docstring_type": "str", + "required": true + } + }, + "constant": { + }, + "call": "credential, subscription_id" + }, + "config": { + "credential": true, + "credential_scopes": ["https://management.azure.com/.default"] + }, + "operation_groups": { + "operations": "Operations", + "deployments": "DeploymentsOperations", + "providers": "ProvidersOperations", + "resources": "ResourcesOperations", + "resource_groups": "ResourceGroupsOperations", + "tags": "TagsOperations", + "deployment_operations": "DeploymentOperationsOperations" + }, + "operation_mixins": { + }, + "sync_imports": "None", + "async_imports": "None" +} \ 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 2211a65cf4b0..e8d06fd50046 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 @@ -1,16 +1,19 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.service_client import SDKClient -from msrest import Serializer, Deserializer +from typing import TYPE_CHECKING + +from azure.mgmt.core import ARMPipelineClient +from msrest import Deserializer, Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional from ._configuration import ResourceManagementClientConfiguration from .operations import Operations @@ -19,61 +22,76 @@ from .operations import ResourcesOperations from .operations import ResourceGroupsOperations from .operations import TagsOperations -from .operations import DeploymentOperations +from .operations import DeploymentOperationsOperations from . import models -class ResourceManagementClient(SDKClient): +class ResourceManagementClient(object): """Provides operations for working with resources and resource groups. - :ivar config: Configuration for client. - :vartype config: ResourceManagementClientConfiguration - :ivar operations: Operations operations :vartype operations: azure.mgmt.resource.resources.v2018_05_01.operations.Operations - :ivar deployments: Deployments operations + :ivar deployments: DeploymentsOperations operations :vartype deployments: azure.mgmt.resource.resources.v2018_05_01.operations.DeploymentsOperations - :ivar providers: Providers operations + :ivar providers: ProvidersOperations operations :vartype providers: azure.mgmt.resource.resources.v2018_05_01.operations.ProvidersOperations - :ivar resources: Resources operations + :ivar resources: ResourcesOperations operations :vartype resources: azure.mgmt.resource.resources.v2018_05_01.operations.ResourcesOperations - :ivar resource_groups: ResourceGroups operations + :ivar resource_groups: ResourceGroupsOperations operations :vartype resource_groups: azure.mgmt.resource.resources.v2018_05_01.operations.ResourceGroupsOperations - :ivar tags: Tags operations + :ivar tags: TagsOperations operations :vartype tags: azure.mgmt.resource.resources.v2018_05_01.operations.TagsOperations - :ivar deployment_operations: DeploymentOperations operations - :vartype deployment_operations: azure.mgmt.resource.resources.v2018_05_01.operations.DeploymentOperations - - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` + :ivar deployment_operations: DeploymentOperationsOperations operations + :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. """ def __init__( - self, credentials, subscription_id, base_url=None): - - self.config = ResourceManagementClientConfiguration(credentials, subscription_id, base_url) - super(ResourceManagementClient, self).__init__(self.config.credentials, self.config) + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = 'https://management.azure.com' + self._config = ResourceManagementClientConfiguration(credential, 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.api_version = '2018-05-01' self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self.operations = Operations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.deployments = DeploymentsOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.providers = ProvidersOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.resources = ResourcesOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.resource_groups = ResourceGroupsOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.tags = TagsOperations( - self._client, self.config, self._serialize, self._deserialize) - self.deployment_operations = DeploymentOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) + self.deployment_operations = DeploymentOperationsOperations( + self._client, self._config, self._serialize, self._deserialize) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> ResourceManagementClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) 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 new file mode 100644 index 000000000000..7f9b1bac71c5 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/__init__.py @@ -0,0 +1,10 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._resource_management_client_async import ResourceManagementClient +__all__ = ['ResourceManagementClient'] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/_configuration_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/_configuration_async.py new file mode 100644 index 000000000000..9e2cad2542bf --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/_configuration_async.py @@ -0,0 +1,65 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + +VERSION = "unknown" + +class ResourceManagementClientConfiguration(Configuration): + """Configuration for ResourceManagementClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :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 + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + 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 + self.api_version = "2018-05-01" + self.credential_scopes = ['https://management.azure.com/.default'] + self.credential_scopes.extend(kwargs.pop('credential_scopes', [])) + kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs: Any + ) -> None: + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + 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) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/_resource_management_client_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/_resource_management_client_async.py new file mode 100644 index 000000000000..5e51678ec599 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/_resource_management_client_async.py @@ -0,0 +1,89 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, Optional + +from azure.mgmt.core import AsyncARMPipelineClient +from msrest import Deserializer, Serializer + +from ._configuration_async import ResourceManagementClientConfiguration +from .operations_async import Operations +from .operations_async import DeploymentsOperations +from .operations_async import ProvidersOperations +from .operations_async import ResourcesOperations +from .operations_async import ResourceGroupsOperations +from .operations_async import TagsOperations +from .operations_async import DeploymentOperationsOperations +from .. import models + + +class ResourceManagementClient(object): + """Provides operations for working with resources and resource groups. + + :ivar operations: Operations operations + :vartype operations: azure.mgmt.resource.resources.v2018_05_01.aio.operations_async.Operations + :ivar deployments: DeploymentsOperations operations + :vartype deployments: azure.mgmt.resource.resources.v2018_05_01.aio.operations_async.DeploymentsOperations + :ivar providers: ProvidersOperations operations + :vartype providers: azure.mgmt.resource.resources.v2018_05_01.aio.operations_async.ProvidersOperations + :ivar resources: ResourcesOperations operations + :vartype resources: azure.mgmt.resource.resources.v2018_05_01.aio.operations_async.ResourcesOperations + :ivar resource_groups: ResourceGroupsOperations operations + :vartype resource_groups: azure.mgmt.resource.resources.v2018_05_01.aio.operations_async.ResourceGroupsOperations + :ivar tags: TagsOperations operations + :vartype tags: azure.mgmt.resource.resources.v2018_05_01.aio.operations_async.TagsOperations + :ivar deployment_operations: DeploymentOperationsOperations operations + :vartype deployment_operations: azure.mgmt.resource.resources.v2018_05_01.aio.operations_async.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. + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: Optional[str] = None, + **kwargs: 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) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + + self.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 close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "ResourceManagementClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/operations_async/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/operations_async/__init__.py new file mode 100644 index 000000000000..f1fd8637fa69 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/operations_async/__init__.py @@ -0,0 +1,25 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._operations_async import Operations +from ._deployments_operations_async import DeploymentsOperations +from ._providers_operations_async import ProvidersOperations +from ._resources_operations_async import ResourcesOperations +from ._resource_groups_operations_async import ResourceGroupsOperations +from ._tags_operations_async import TagsOperations +from ._deployment_operations_operations_async import DeploymentOperationsOperations + +__all__ = [ + 'Operations', + 'DeploymentsOperations', + 'ProvidersOperations', + 'ResourcesOperations', + 'ResourceGroupsOperations', + 'TagsOperations', + 'DeploymentOperationsOperations', +] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/operations_async/_deployment_operations_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/operations_async/_deployment_operations_operations_async.py new file mode 100644 index 000000000000..7403f358e893 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/operations_async/_deployment_operations_operations_async.py @@ -0,0 +1,306 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import 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 ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class DeploymentOperationsOperations: + """DeploymentOperationsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2018_05_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def get_at_subscription_scope( + self, + deployment_name: str, + operation_id: str, + **kwargs + ) -> "models.DeploymentOperation": + """Gets a deployments operation. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param operation_id: The ID of the operation to get. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentOperation or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentOperation + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentOperation"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentOperation', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + def list_at_subscription_scope( + self, + deployment_name: str, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.DeploymentOperationsListResult"]: + """Gets all deployments operations for a deployment. + + :param deployment_name: The name of the deployment with the operation to get. + :type deployment_name: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentOperationsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + 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 + + async def get( + self, + resource_group_name: str, + deployment_name: str, + operation_id: str, + **kwargs + ) -> "models.DeploymentOperation": + """Gets a deployments operation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param operation_id: The ID of the operation to get. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentOperation or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentOperation + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentOperation"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + + # Construct URL + url = self.get.metadata['url'] # type: 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentOperation', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + def list( + self, + resource_group_name: str, + deployment_name: str, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.DeploymentOperationsListResult"]: + """Gets all deployments operations for a deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment with the operation to get. + :type deployment_name: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentOperationsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/operations_async/_deployments_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/operations_async/_deployments_operations_async.py new file mode 100644 index 000000000000..968b044e1447 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/operations_async/_deployments_operations_async.py @@ -0,0 +1,1218 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.polling import AsyncNoPolling, AsyncPollingMethod, async_poller +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class DeploymentsOperations: + """DeploymentsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2018_05_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def _delete_at_subscription_scope_initial( + self, + deployment_name: str, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def delete_at_subscription_scope( + self, + deployment_name: str, + **kwargs + ) -> None: + """A template deployment that is currently running cannot be deleted. Deleting a template deployment removes the associated deployment operations. This is an asynchronous operation that returns a status of 202 until the template deployment is successfully deleted. The Location response header contains the URI that is used to obtain the status of the process. While the process is running, a call to the URI in the Location header returns a status of 202. When the process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. + + Deletes a deployment from the deployment history. + + :param deployment_name: The name of the deployment to delete. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._delete_at_subscription_scope_initial( + deployment_name=deployment_name, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + delete_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def check_existence_at_subscription_scope( + self, + deployment_name: str, + **kwargs + ) -> None: + """Checks whether the deployment exists. + + :param deployment_name: The name of the deployment to check. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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] + + # Construct and send request + 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 + + if response.status_code not in [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + 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, + properties: "models.DeploymentProperties", + location: Optional[str] = None, + **kwargs + ) -> "models.DeploymentExtended": + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.Deployment(location=location, properties=properties) + api_version = "2018-05-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + 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 + + async def create_or_update_at_subscription_scope( + self, + deployment_name: str, + properties: "models.DeploymentProperties", + location: Optional[str] = None, + **kwargs + ) -> "models.DeploymentExtended": + """You can provide the template and parameters directly in the request or link to JSON files. + + Deploys resources at subscription scope. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param properties: The deployment properties. + :type properties: ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentProperties + :param location: The location to store the deployment data. + :type location: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: DeploymentExtended + :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentExtended + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._create_or_update_at_subscription_scope_initial( + deployment_name=deployment_name, + properties=properties, + location=location, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + create_or_update_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def get_at_subscription_scope( + self, + deployment_name: str, + **kwargs + ) -> "models.DeploymentExtended": + """Gets a deployment. + + :param deployment_name: The name of the deployment to get. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExtended or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentExtended + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def cancel_at_subscription_scope( + self, + deployment_name: str, + **kwargs + ) -> None: + """You can cancel a deployment only if the provisioningState is Accepted or Running. After the deployment is canceled, the provisioningState is set to Canceled. Canceling a template deployment stops the currently running template deployment and leaves the resources partially deployed. + + Cancels a currently running template deployment. + + :param deployment_name: The name of the deployment to cancel. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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] + + # Construct and send request + 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 [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + cancel_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + + async def validate_at_subscription_scope( + self, + deployment_name: str, + properties: "models.DeploymentProperties", + location: Optional[str] = None, + **kwargs + ) -> "models.DeploymentValidateResult": + """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param properties: The deployment properties. + :type properties: ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentProperties + :param location: The location to store the deployment data. + :type location: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentValidateResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentValidateResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.Deployment(location=location, properties=properties) + api_version = "2018-05-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 400]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + + if response.status_code == 400: + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + + if cls: + 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 export_template_at_subscription_scope( + self, + deployment_name: str, + **kwargs + ) -> "models.DeploymentExportResult": + """Exports the template used for specified deployment. + + :param deployment_name: The name of the deployment from which to get the template. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentExportResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExportResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + + # 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'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + export_template_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + def list_at_subscription_scope( + self, + filter: Optional[str] = None, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.DeploymentListResult"]: + """Get all the deployments for a subscription. + + :param filter: The filter to apply on the operation. For example, you can use + $filter=provisioningState eq '{state}'. + :type filter: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/'} # type: ignore + + async def _delete_initial( + self, + resource_group_name: str, + deployment_name: str, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def delete( + self, + resource_group_name: str, + deployment_name: str, + **kwargs + ) -> None: + """A template deployment that is currently running cannot be deleted. Deleting a template deployment removes the associated deployment operations. Deleting a template deployment does not affect the state of the resource group. This is an asynchronous operation that returns a status of 202 until the template deployment is successfully deleted. The Location response header contains the URI that is used to obtain the status of the process. While the process is running, a call to the URI in the Location header returns a status of 202. When the process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. + + Deletes a deployment from the deployment history. + + :param resource_group_name: The name of the resource group with the deployment to delete. The + name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment to delete. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def check_existence( + self, + resource_group_name: str, + deployment_name: str, + **kwargs + ) -> None: + """Checks whether the deployment exists. + + :param resource_group_name: The name of the resource group with the deployment to check. The + name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment to check. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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] + + # Construct and send request + 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 + + if response.status_code not in [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + 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, + deployment_name: str, + properties: "models.DeploymentProperties", + location: Optional[str] = None, + **kwargs + ) -> "models.DeploymentExtended": + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.Deployment(location=location, properties=properties) + api_version = "2018-05-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def create_or_update( + self, + resource_group_name: str, + deployment_name: str, + properties: "models.DeploymentProperties", + location: Optional[str] = None, + **kwargs + ) -> "models.DeploymentExtended": + """You can provide the template and parameters directly in the request or link to JSON files. + + Deploys resources to a resource group. + + :param resource_group_name: The name of the resource group to deploy the resources to. The name + is case insensitive. The resource group must already exist. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param properties: The deployment properties. + :type properties: ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentProperties + :param location: The location to store the deployment data. + :type location: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: DeploymentExtended + :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentExtended + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + properties=properties, + location=location, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def get( + self, + resource_group_name: str, + deployment_name: str, + **kwargs + ) -> "models.DeploymentExtended": + """Gets a deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment to get. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExtended or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentExtended + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + + # Construct URL + url = self.get.metadata['url'] # type: 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def cancel( + self, + resource_group_name: str, + deployment_name: str, + **kwargs + ) -> None: + """You can cancel a deployment only if the provisioningState is Accepted or Running. After the deployment is canceled, the provisioningState is set to Canceled. Canceling a template deployment stops the currently running template deployment and leaves the resource group partially deployed. + + Cancels a currently running template deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment to cancel. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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] + + # Construct and send request + 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 [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + cancel.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + + async def validate( + self, + resource_group_name: str, + deployment_name: str, + properties: "models.DeploymentProperties", + location: Optional[str] = None, + **kwargs + ) -> "models.DeploymentValidateResult": + """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param properties: The deployment properties. + :type properties: ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentProperties + :param location: The location to store the deployment data. + :type location: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentValidateResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentValidateResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.Deployment(location=location, properties=properties) + api_version = "2018-05-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 400]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + + if response.status_code == 400: + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + validate.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + async def export_template( + self, + resource_group_name: str, + deployment_name: str, + **kwargs + ) -> "models.DeploymentExportResult": + """Exports the template used for specified deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment from which to get the template. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentExportResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExportResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + + # 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'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + def list_by_resource_group( + self, + resource_group_name: str, + filter: Optional[str] = None, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.DeploymentListResult"]: + """Get all the deployments for a resource group. + + :param resource_group_name: The name of the resource group with the deployments to get. The + name is case insensitive. + :type resource_group_name: str + :param filter: The filter to apply on the operation. For example, you can use + $filter=provisioningState eq '{state}'. + :type filter: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + 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 + + async def calculate_template_hash( + self, + template: object, + **kwargs + ) -> "models.TemplateHashResult": + """Calculate the hash of the given template. + + :param template: The template provided to calculate hash. + :type template: object + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateHashResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.TemplateHashResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TemplateHashResult"] + error_map = {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.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'] = 'application/json' + + # Construct and send request + 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) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('TemplateHashResult', pipeline_response) + + if cls: + 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_async/_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/operations_async/_operations_async.py new file mode 100644 index 000000000000..2eaa00f2fbac --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/operations_async/_operations_async.py @@ -0,0 +1,101 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import 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 ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class Operations: + """Operations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2018_05_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + **kwargs + ) -> AsyncIterable["models.OperationListResult"]: + """Lists all of the available Microsoft.Resources REST API operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of OperationListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('OperationListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.Resources/operations'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/operations_async/_providers_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/operations_async/_providers_operations_async.py new file mode 100644 index 000000000000..56471ea98f18 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/operations_async/_providers_operations_async.py @@ -0,0 +1,279 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import 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 ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ProvidersOperations: + """ProvidersOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2018_05_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def unregister( + self, + resource_provider_namespace: str, + **kwargs + ) -> "models.Provider": + """Unregisters a subscription from a resource provider. + + :param resource_provider_namespace: The namespace of the resource provider to unregister. + :type resource_provider_namespace: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Provider or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.Provider + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Provider"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + + # 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'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Provider', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + unregister.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister'} # type: ignore + + async def register( + self, + resource_provider_namespace: str, + **kwargs + ) -> "models.Provider": + """Registers a subscription with a resource provider. + + :param resource_provider_namespace: The namespace of the resource provider to register. + :type resource_provider_namespace: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Provider or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.Provider + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Provider"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + + # 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'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Provider', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + register.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register'} # type: ignore + + def list( + self, + top: Optional[int] = None, + expand: Optional[str] = None, + **kwargs + ) -> AsyncIterable["models.ProviderListResult"]: + """Gets all resource providers for a subscription. + + :param top: The number of results to return. If null is passed returns all deployments. + :type top: int + :param expand: The properties to include in the results. For example, use &$expand=metadata in + the query string to retrieve resource provider metadata. To include property aliases in + response, use $expand=resourceTypes/aliases. + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of ProviderListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ProviderListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers'} # type: ignore + + async def get( + self, + resource_provider_namespace: str, + expand: Optional[str] = None, + **kwargs + ) -> "models.Provider": + """Gets the specified resource provider. + + :param resource_provider_namespace: The namespace of the resource provider. + :type resource_provider_namespace: str + :param expand: The $expand query parameter. For example, to include property aliases in + response, use $expand=resourceTypes/aliases. + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Provider or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.Provider + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Provider"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Provider', pipeline_response) + + if cls: + 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_async/_resource_groups_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/operations_async/_resource_groups_operations_async.py new file mode 100644 index 000000000000..62c9bfae07d0 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/operations_async/_resource_groups_operations_async.py @@ -0,0 +1,505 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, List, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.polling import AsyncNoPolling, AsyncPollingMethod, async_poller +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ResourceGroupsOperations: + """ResourceGroupsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2018_05_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def check_existence( + self, + resource_group_name: str, + **kwargs + ) -> None: + """Checks whether a resource group exists. + + :param resource_group_name: The name of the resource group to check. 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: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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] + + # Construct and send request + 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 + + if response.status_code not in [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + async def create_or_update( + self, + resource_group_name: str, + parameters: "models.ResourceGroup", + **kwargs + ) -> "models.ResourceGroup": + """Creates or updates a resource group. + + :param resource_group_name: The name of the resource group to create or update. Can include + alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters + that match the allowed characters. + :type resource_group_name: str + :param parameters: Parameters supplied to the create or update a resource group. + :type parameters: ~azure.mgmt.resource.resources.v2018_05_01.models.ResourceGroup + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.ResourceGroup + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceGroup"] + error_map = {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.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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ResourceGroup', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ResourceGroup', pipeline_response) + + if cls: + 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, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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] + + # Construct and send request + 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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + async def delete( + self, + resource_group_name: str, + **kwargs + ) -> None: + """When you delete a resource group, all of its resources are also deleted. Deleting a resource group deletes all of its template deployments and currently stored operations. + + Deletes a resource group. + + :param resource_group_name: The name of the resource group to delete. 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 + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + async def get( + self, + resource_group_name: str, + **kwargs + ) -> "models.ResourceGroup": + """Gets a resource group. + + :param resource_group_name: The name of the resource group to get. 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: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.ResourceGroup + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceGroup"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + + # Construct URL + url = self.get.metadata['url'] # type: 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ResourceGroup', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + async def update( + self, + resource_group_name: str, + parameters: "models.ResourceGroupPatchable", + **kwargs + ) -> "models.ResourceGroup": + """Resource groups can be updated through a simple PATCH operation to a group address. The format of the request is the same as that for creating a resource group. If a field is unspecified, the current value is retained. + + Updates a resource group. + + :param resource_group_name: The name of the resource group to update. The name is case + insensitive. + :type resource_group_name: str + :param parameters: Parameters supplied to update a resource group. + :type parameters: ~azure.mgmt.resource.resources.v2018_05_01.models.ResourceGroupPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.ResourceGroup + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceGroup"] + error_map = {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.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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ResourceGroup', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + async def export_template( + self, + resource_group_name: str, + resources: Optional[List[str]] = None, + options: Optional[str] = None, + **kwargs + ) -> "models.ResourceGroupExportResult": + """Captures the specified resource group as a template. + + :param resource_group_name: The name of the resource group to export as a template. + :type resource_group_name: str + :param 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', + 'SkipResourceNameParameterization', 'SkipAllParameterization'. + :type options: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroupExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.ResourceGroupExportResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceGroupExportResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.ExportTemplateRequest(resources=resources, options=options) + api_version = "2018-05-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ResourceGroupExportResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate'} # type: ignore + + def list( + self, + filter: Optional[str] = None, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.ResourceGroupListResult"]: + """Gets all the resource groups for a subscription. + + :param filter: The filter to apply on the operation.:code:`
`:code:`
`You can filter by + tag names and values. For example, to filter for a tag name and value, use $filter=tagName eq + 'tag1' and tagValue eq 'Value1'. + :type filter: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ResourceGroupListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/operations_async/_resources_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/operations_async/_resources_operations_async.py new file mode 100644 index 000000000000..6e001a9c4c60 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/operations_async/_resources_operations_async.py @@ -0,0 +1,1308 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, List, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.polling import AsyncNoPolling, AsyncPollingMethod, async_poller +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ResourcesOperations: + """ResourcesOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2018_05_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list_by_resource_group( + self, + resource_group_name: str, + filter: Optional[str] = None, + expand: Optional[str] = None, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.ResourceListResult"]: + """Get all the resources for a resource group. + + :param resource_group_name: The resource group with the resources to get. + :type resource_group_name: str + :param filter: The filter to apply on the operation.:code:`
`:code:`
`The properties you + can use for eq (equals) or ne (not equals) are: location, resourceType, name, resourceGroup, + identity, identity/principalId, plan, plan/publisher, plan/product, plan/name, plan/version, + and plan/promotionCode.:code:`
`:code:`
`For example, to filter by a resource type, use: + $filter=resourceType eq 'Microsoft.Network/virtualNetworks':code:`
`:code:`
`You can use + substringof(value, property) in the filter. The properties you can use for substring are: name + and resourceGroup.:code:`
`:code:`
`For example, to get all resources with 'demo' + anywhere in the name, use: $filter=substringof('demo', name):code:`
`:code:`
`You can + link more than one substringof together by adding and/or operators.:code:`
`:code:`
`You + can filter by tag names and values. For example, to filter for a tag name and value, use + $filter=tagName eq 'tag1' and tagValue eq 'Value1':code:`
`:code:`
`You can use some + properties together when filtering. The combinations you can use are: substringof and/or + resourceType, plan and plan/publisher and plan/name, identity and identity/principalId. + :type filter: str + :param expand: Comma-separated list of additional properties to be included in the response. + Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, + ``$expand=createdTime,changedTime``. + :type expand: str + :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 ResourceListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ResourceListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources'} # type: ignore + + async def _move_resources_initial( + self, + source_resource_group_name: str, + resources: Optional[List[str]] = None, + target_resource_group: Optional[str] = None, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.ResourcesMoveInfo(resources=resources, target_resource_group=target_resource_group) + 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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + + # Construct and send request + 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 + + if response.status_code not in [202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore + + async def move_resources( + self, + source_resource_group_name: str, + resources: Optional[List[str]] = None, + target_resource_group: Optional[str] = None, + **kwargs + ) -> None: + """The resources to move must be in the same source resource group. The target resource group may be in a different subscription. When moving resources, both the source group and the target group are locked for the duration of the operation. Write and delete operations are blocked on the groups until the move completes. + + Moves resources from one resource group to another resource group. + + :param source_resource_group_name: The name of the resource group containing the resources to + move. + :type source_resource_group_name: str + :param resources: The IDs of the resources. + :type resources: list[str] + :param target_resource_group: The target resource group. + :type target_resource_group: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._move_resources_initial( + source_resource_group_name=source_resource_group_name, + resources=resources, + target_resource_group=target_resource_group, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore + + async def _validate_move_resources_initial( + self, + source_resource_group_name: str, + resources: Optional[List[str]] = None, + target_resource_group: Optional[str] = None, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.ResourcesMoveInfo(resources=resources, target_resource_group=target_resource_group) + 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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + + # Construct and send request + 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 + + if response.status_code not in [202, 204, 409]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _validate_move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} # type: ignore + + async def validate_move_resources( + self, + source_resource_group_name: str, + resources: Optional[List[str]] = None, + target_resource_group: Optional[str] = None, + **kwargs + ) -> None: + """This operation checks whether the specified resources can be moved to the target. The resources to move must be in the same source resource group. The target resource group may be in a different subscription. If validation succeeds, it returns HTTP response code 204 (no content). If validation fails, it returns HTTP response code 409 (Conflict) with an error message. Retrieve the URL in the Location header value to check the result of the long-running operation. + + Validates whether resources can be moved from one resource group to another resource group. + + :param source_resource_group_name: The name of the resource group containing the resources to + validate for move. + :type source_resource_group_name: str + :param resources: The IDs of the resources. + :type resources: list[str] + :param target_resource_group: The target resource group. + :type target_resource_group: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._validate_move_resources_initial( + source_resource_group_name=source_resource_group_name, + resources=resources, + target_resource_group=target_resource_group, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + validate_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} # type: ignore + + def list( + self, + filter: Optional[str] = None, + expand: Optional[str] = None, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.ResourceListResult"]: + """Get all the resources in a subscription. + + :param filter: The filter to apply on the operation.:code:`
`:code:`
`The properties you + can use for eq (equals) or ne (not equals) are: location, resourceType, name, resourceGroup, + identity, identity/principalId, plan, plan/publisher, plan/product, plan/name, plan/version, + and plan/promotionCode.:code:`
`:code:`
`For example, to filter by a resource type, use: + $filter=resourceType eq 'Microsoft.Network/virtualNetworks':code:`
`:code:`
`You can use + substringof(value, property) in the filter. The properties you can use for substring are: name + and resourceGroup.:code:`
`:code:`
`For example, to get all resources with 'demo' + anywhere in the name, use: $filter=substringof('demo', name):code:`
`:code:`
`You can + link more than one substringof together by adding and/or operators.:code:`
`:code:`
`You + can filter by tag names and values. For example, to filter for a tag name and value, use + $filter=tagName eq 'tag1' and tagValue eq 'Value1':code:`
`:code:`
`You can use some + properties together when filtering. The combinations you can use are: substringof and/or + resourceType, plan and plan/publisher and plan/name, identity and identity/principalId. + :type filter: str + :param expand: Comma-separated list of additional properties to be included in the response. + Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, + ``$expand=createdTime,changedTime``. + :type expand: str + :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 ResourceListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ResourceListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resources'} # type: ignore + + async def check_existence( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + **kwargs + ) -> None: + """Checks whether a resource exists. + + :param resource_group_name: The name of the resource group containing the resource to check. + The name is case insensitive. + :type resource_group_name: str + :param resource_provider_namespace: The resource provider of the resource to check. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. + :type parent_resource_path: str + :param resource_type: The resource type. + :type resource_type: str + :param resource_name: The name of the resource to check whether it exists. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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\._\(\)]+$'), + 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), + 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_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] + + # Construct and send request + 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 + + if response.status_code not in [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + 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, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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\._\(\)]+$'), + 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), + 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + async def delete( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + **kwargs + ) -> None: + """Deletes a resource. + + :param resource_group_name: The name of the resource group that contains the resource to + delete. The name is case insensitive. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. + :type parent_resource_path: str + :param resource_type: The resource type. + :type resource_type: str + :param resource_name: The name of the resource to delete. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._delete_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, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + parameters: "models.GenericResource", + **kwargs + ) -> "models.GenericResource": + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {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._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'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 201, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('GenericResource', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + async def create_or_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + parameters: "models.GenericResource", + **kwargs + ) -> "models.GenericResource": + """Creates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to create. + :type resource_type: str + :param resource_name: The name of the resource to create. + :type resource_name: str + :param parameters: Parameters for creating or updating the resource. + :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 polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: GenericResource + :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._create_or_update_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, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + 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, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + parameters: "models.GenericResource", + **kwargs + ) -> "models.GenericResource": + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {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._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'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + async def update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + parameters: "models.GenericResource", + **kwargs + ) -> "models.GenericResource": + """Updates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to update. + :type resource_type: str + :param resource_name: The name of the resource to update. + :type resource_name: str + :param parameters: Parameters for updating the resource. + :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 polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: GenericResource + :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._update_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, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + async def get( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + **kwargs + ) -> "models.GenericResource": + """Gets a resource. + + :param resource_group_name: The name of the resource group containing the resource to get. The + name is case insensitive. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. + :type parent_resource_path: str + :param resource_type: The resource type of the resource. + :type resource_type: str + :param resource_name: The name of the resource to get. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GenericResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + + # Construct URL + url = self.get.metadata['url'] # type: 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + async def check_existence_by_id( + self, + resource_id: str, + **kwargs + ) -> None: + """Checks by ID whether a resource exists. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + :type resource_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + + # 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] + + # Construct and send request + 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 + + if response.status_code not in [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + 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, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + + # 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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + async def delete_by_id( + self, + resource_id: str, + **kwargs + ) -> None: + """Deletes a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + :type resource_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._delete_by_id_initial( + resource_id=resource_id, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + delete_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + + async def _create_or_update_by_id_initial( + self, + resource_id: str, + parameters: "models.GenericResource", + **kwargs + ) -> "models.GenericResource": + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {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._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) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 201, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('GenericResource', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + async def create_or_update_by_id( + self, + resource_id: str, + parameters: "models.GenericResource", + **kwargs + ) -> "models.GenericResource": + """Create a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + :type resource_id: str + :param parameters: Create or update resource parameters. + :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 polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: GenericResource + :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._create_or_update_by_id_initial( + resource_id=resource_id, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + create_or_update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + + async def _update_by_id_initial( + self, + resource_id: str, + parameters: "models.GenericResource", + **kwargs + ) -> "models.GenericResource": + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {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._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) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + async def update_by_id( + self, + resource_id: str, + parameters: "models.GenericResource", + **kwargs + ) -> "models.GenericResource": + """Updates a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + :type resource_id: str + :param parameters: Update resource parameters. + :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 polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: GenericResource + :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._update_by_id_initial( + resource_id=resource_id, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + + async def get_by_id( + self, + resource_id: str, + **kwargs + ) -> "models.GenericResource": + """Gets a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + :type resource_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GenericResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + 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_async/_tags_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/operations_async/_tags_operations_async.py new file mode 100644 index 000000000000..9e6868fac783 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/aio/operations_async/_tags_operations_async.py @@ -0,0 +1,327 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import 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 ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class TagsOperations: + """TagsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2018_05_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def delete_value( + self, + tag_name: str, + tag_value: str, + **kwargs + ) -> None: + """Deletes a tag value. + + :param tag_name: The name of the tag. + :type tag_name: str + :param tag_value: The value of the tag to delete. + :type tag_value: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore + + async def create_or_update_value( + self, + tag_name: str, + tag_value: str, + **kwargs + ) -> "models.TagValue": + """Creates a tag value. The name of the tag must already exist. + + :param tag_name: The name of the tag. + :type tag_name: str + :param tag_value: The value of the tag to create. + :type tag_value: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagValue or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.TagValue + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TagValue"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + + # 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'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('TagValue', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('TagValue', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore + + async def create_or_update( + self, + tag_name: str, + **kwargs + ) -> "models.TagDetails": + """The tag name can have a maximum of 512 characters and is case insensitive. Tag names created by Azure have prefixes of microsoft, azure, or windows. You cannot create tags with one of these prefixes. + + Creates a tag in the subscription. + + :param tag_name: The name of the tag to create. + :type tag_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagDetails or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.TagDetails + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TagDetails"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + + # 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'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('TagDetails', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('TagDetails', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore + + async def delete( + self, + tag_name: str, + **kwargs + ) -> None: + """You must remove all values from a resource tag before you can delete it. + + Deletes a tag from the subscription. + + :param tag_name: The name of the tag. + :type tag_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore + + def list( + self, + **kwargs + ) -> AsyncIterable["models.TagsListResult"]: + """Gets the names and values of all resource tags that are defined in a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of TagsListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('TagsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/models/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/models/__init__.py index a4e62c5bf265..b94776ab3cce 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/models/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/models/__init__.py @@ -1,26 +1,26 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- try: from ._models_py3 import AliasPathType from ._models_py3 import AliasType from ._models_py3 import BasicDependency + from ._models_py3 import ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties from ._models_py3 import DebugSetting from ._models_py3 import Dependency from ._models_py3 import Deployment from ._models_py3 import DeploymentExportResult from ._models_py3 import DeploymentExtended from ._models_py3 import DeploymentExtendedFilter + from ._models_py3 import DeploymentListResult from ._models_py3 import DeploymentOperation from ._models_py3 import DeploymentOperationProperties + from ._models_py3 import DeploymentOperationsListResult from ._models_py3 import DeploymentProperties from ._models_py3 import DeploymentPropertiesExtended from ._models_py3 import DeploymentValidateResult @@ -32,21 +32,24 @@ from ._models_py3 import GenericResourceFilter from ._models_py3 import HttpMessage from ._models_py3 import Identity - from ._models_py3 import IdentityUserAssignedIdentitiesValue from ._models_py3 import OnErrorDeployment from ._models_py3 import OnErrorDeploymentExtended from ._models_py3 import Operation from ._models_py3 import OperationDisplay + from ._models_py3 import OperationListResult from ._models_py3 import ParametersLink from ._models_py3 import Plan from ._models_py3 import Provider + from ._models_py3 import ProviderListResult from ._models_py3 import ProviderResourceType from ._models_py3 import Resource from ._models_py3 import ResourceGroup from ._models_py3 import ResourceGroupExportResult from ._models_py3 import ResourceGroupFilter + from ._models_py3 import ResourceGroupListResult from ._models_py3 import ResourceGroupPatchable from ._models_py3 import ResourceGroupProperties + from ._models_py3 import ResourceListResult from ._models_py3 import ResourceManagementErrorWithDetails from ._models_py3 import ResourceProviderOperationDisplayProperties from ._models_py3 import ResourcesMoveInfo @@ -55,65 +58,67 @@ from ._models_py3 import TagCount from ._models_py3 import TagDetails from ._models_py3 import TagValue + from ._models_py3 import TagsListResult from ._models_py3 import TargetResource from ._models_py3 import TemplateHashResult from ._models_py3 import TemplateLink except (SyntaxError, ImportError): - from ._models import AliasPathType - from ._models import AliasType - from ._models import BasicDependency - from ._models import DebugSetting - from ._models import Dependency - from ._models import Deployment - from ._models import DeploymentExportResult - from ._models import DeploymentExtended - from ._models import DeploymentExtendedFilter - from ._models import DeploymentOperation - from ._models import DeploymentOperationProperties - from ._models import DeploymentProperties - from ._models import DeploymentPropertiesExtended - from ._models import DeploymentValidateResult - from ._models import ErrorAdditionalInfo - from ._models import ErrorResponse - from ._models import ExportTemplateRequest - from ._models import GenericResource - from ._models import GenericResourceExpanded - from ._models import GenericResourceFilter - from ._models import HttpMessage - from ._models import Identity - from ._models import IdentityUserAssignedIdentitiesValue - from ._models import OnErrorDeployment - from ._models import OnErrorDeploymentExtended - from ._models import Operation - from ._models import OperationDisplay - from ._models import ParametersLink - from ._models import Plan - from ._models import Provider - from ._models import ProviderResourceType - from ._models import Resource - from ._models import ResourceGroup - from ._models import ResourceGroupExportResult - from ._models import ResourceGroupFilter - from ._models import ResourceGroupPatchable - from ._models import ResourceGroupProperties - from ._models import ResourceManagementErrorWithDetails - from ._models import ResourceProviderOperationDisplayProperties - from ._models import ResourcesMoveInfo - from ._models import Sku - from ._models import SubResource - from ._models import TagCount - from ._models import TagDetails - from ._models import TagValue - from ._models import TargetResource - from ._models import TemplateHashResult - from ._models import TemplateLink -from ._paged_models import DeploymentExtendedPaged -from ._paged_models import DeploymentOperationPaged -from ._paged_models import GenericResourceExpandedPaged -from ._paged_models import OperationPaged -from ._paged_models import ProviderPaged -from ._paged_models import ResourceGroupPaged -from ._paged_models import TagDetailsPaged + from ._models import AliasPathType # type: ignore + from ._models import AliasType # type: ignore + from ._models import BasicDependency # type: ignore + from ._models import ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties # type: ignore + from ._models import DebugSetting # type: ignore + from ._models import Dependency # type: ignore + from ._models import Deployment # type: ignore + from ._models import DeploymentExportResult # type: ignore + from ._models import DeploymentExtended # type: ignore + from ._models import DeploymentExtendedFilter # type: ignore + from ._models import DeploymentListResult # type: ignore + from ._models import DeploymentOperation # type: ignore + from ._models import DeploymentOperationProperties # type: ignore + from ._models import DeploymentOperationsListResult # type: ignore + from ._models import DeploymentProperties # type: ignore + from ._models import DeploymentPropertiesExtended # type: ignore + from ._models import DeploymentValidateResult # type: ignore + from ._models import ErrorAdditionalInfo # type: ignore + from ._models import ErrorResponse # type: ignore + from ._models import ExportTemplateRequest # type: ignore + from ._models import GenericResource # type: ignore + from ._models import GenericResourceExpanded # type: ignore + from ._models import GenericResourceFilter # type: ignore + from ._models import HttpMessage # type: ignore + from ._models import Identity # type: ignore + from ._models import OnErrorDeployment # type: ignore + from ._models import OnErrorDeploymentExtended # type: ignore + from ._models import Operation # type: ignore + from ._models import OperationDisplay # type: ignore + from ._models import OperationListResult # type: ignore + from ._models import ParametersLink # type: ignore + from ._models import Plan # type: ignore + from ._models import Provider # type: ignore + from ._models import ProviderListResult # type: ignore + from ._models import ProviderResourceType # type: ignore + from ._models import Resource # type: ignore + from ._models import ResourceGroup # type: ignore + from ._models import ResourceGroupExportResult # type: ignore + from ._models import ResourceGroupFilter # type: ignore + from ._models import ResourceGroupListResult # type: ignore + from ._models import ResourceGroupPatchable # type: ignore + from ._models import ResourceGroupProperties # type: ignore + from ._models import ResourceListResult # type: ignore + from ._models import ResourceManagementErrorWithDetails # type: ignore + from ._models import ResourceProviderOperationDisplayProperties # type: ignore + from ._models import ResourcesMoveInfo # type: ignore + from ._models import Sku # type: ignore + from ._models import SubResource # type: ignore + from ._models import TagCount # type: ignore + from ._models import TagDetails # type: ignore + from ._models import TagValue # type: ignore + from ._models import TagsListResult # type: ignore + from ._models import TargetResource # type: ignore + from ._models import TemplateHashResult # type: ignore + from ._models import TemplateLink # type: ignore + from ._resource_management_client_enums import ( DeploymentMode, OnErrorDeploymentType, @@ -124,14 +129,17 @@ 'AliasPathType', 'AliasType', 'BasicDependency', + 'ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties', 'DebugSetting', 'Dependency', 'Deployment', 'DeploymentExportResult', 'DeploymentExtended', 'DeploymentExtendedFilter', + 'DeploymentListResult', 'DeploymentOperation', 'DeploymentOperationProperties', + 'DeploymentOperationsListResult', 'DeploymentProperties', 'DeploymentPropertiesExtended', 'DeploymentValidateResult', @@ -143,21 +151,24 @@ 'GenericResourceFilter', 'HttpMessage', 'Identity', - 'IdentityUserAssignedIdentitiesValue', 'OnErrorDeployment', 'OnErrorDeploymentExtended', 'Operation', 'OperationDisplay', + 'OperationListResult', 'ParametersLink', 'Plan', 'Provider', + 'ProviderListResult', 'ProviderResourceType', 'Resource', 'ResourceGroup', 'ResourceGroupExportResult', 'ResourceGroupFilter', + 'ResourceGroupListResult', 'ResourceGroupPatchable', 'ResourceGroupProperties', + 'ResourceListResult', 'ResourceManagementErrorWithDetails', 'ResourceProviderOperationDisplayProperties', 'ResourcesMoveInfo', @@ -166,16 +177,10 @@ 'TagCount', 'TagDetails', 'TagValue', + 'TagsListResult', 'TargetResource', 'TemplateHashResult', 'TemplateLink', - 'OperationPaged', - 'DeploymentExtendedPaged', - 'ProviderPaged', - 'GenericResourceExpandedPaged', - 'ResourceGroupPaged', - 'TagDetailsPaged', - 'DeploymentOperationPaged', 'DeploymentMode', 'OnErrorDeploymentType', 'ResourceIdentityType', 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 c565a95fcc69..d0795ab8abbc 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 @@ -1,20 +1,16 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.serialization import Model -from msrest.exceptions import HttpOperationError +import msrest.serialization -class AliasPathType(Model): - """The type of the paths for alias. . +class AliasPathType(msrest.serialization.Model): + """The type of the paths for alias. :param path: The path of an alias. :type path: str @@ -27,20 +23,22 @@ class AliasPathType(Model): 'api_versions': {'key': 'apiVersions', 'type': '[str]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(AliasPathType, self).__init__(**kwargs) self.path = kwargs.get('path', None) self.api_versions = kwargs.get('api_versions', None) -class AliasType(Model): - """The alias type. . +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] + :type paths: list[~azure.mgmt.resource.resources.v2018_05_01.models.AliasPathType] """ _attribute_map = { @@ -48,13 +46,16 @@ class AliasType(Model): 'paths': {'key': 'paths', 'type': '[AliasPathType]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(AliasType, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.paths = kwargs.get('paths', None) -class BasicDependency(Model): +class BasicDependency(msrest.serialization.Model): """Deployment dependency information. :param id: The ID of the dependency. @@ -71,52 +72,55 @@ class BasicDependency(Model): 'resource_name': {'key': 'resourceName', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(BasicDependency, self).__init__(**kwargs) self.id = kwargs.get('id', None) self.resource_type = kwargs.get('resource_type', None) self.resource_name = kwargs.get('resource_name', None) -class CloudError(Model): - """An error response for a resource management request. +class ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties(msrest.serialization.Model): + """ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties. - :param error: - :type error: - ~azure.mgmt.resource.resources.v2018_05_01.models.ErrorResponse + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar principal_id: The principal id of user assigned identity. + :vartype principal_id: str + :ivar client_id: The client id of user assigned identity. + :vartype client_id: str """ - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorResponse'}, + _validation = { + 'principal_id': {'readonly': True}, + 'client_id': {'readonly': True}, } - def __init__(self, **kwargs): - super(CloudError, self).__init__(**kwargs) - self.error = kwargs.get('error', None) - - -class CloudErrorException(HttpOperationError): - """Server responsed with exception of type: 'CloudError'. - - :param deserialize: A deserializer - :param response: Server response to be deserialized. - """ - - def __init__(self, deserialize, response, *args): + _attribute_map = { + 'principal_id': {'key': 'principalId', 'type': 'str'}, + 'client_id': {'key': 'clientId', 'type': 'str'}, + } - super(CloudErrorException, self).__init__(deserialize, response, 'CloudError', *args) + def __init__( + self, + **kwargs + ): + super(ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties, self).__init__(**kwargs) + self.principal_id = None + self.client_id = None -class DebugSetting(Model): +class DebugSetting(msrest.serialization.Model): """DebugSetting. - :param 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. + :param 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 """ @@ -124,17 +128,19 @@ class DebugSetting(Model): 'detail_level': {'key': 'detailLevel', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DebugSetting, self).__init__(**kwargs) self.detail_level = kwargs.get('detail_level', None) -class Dependency(Model): +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] + :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. @@ -150,7 +156,10 @@ class Dependency(Model): 'resource_name': {'key': 'resourceName', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Dependency, self).__init__(**kwargs) self.depends_on = kwargs.get('depends_on', None) self.id = kwargs.get('id', None) @@ -158,7 +167,7 @@ def __init__(self, **kwargs): self.resource_name = kwargs.get('resource_name', None) -class Deployment(Model): +class Deployment(msrest.serialization.Model): """Deployment operation parameters. All required parameters must be populated in order to send to Azure. @@ -166,8 +175,7 @@ class Deployment(Model): :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 + :type properties: ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentProperties """ _validation = { @@ -179,14 +187,17 @@ class Deployment(Model): 'properties': {'key': 'properties', 'type': 'DeploymentProperties'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Deployment, self).__init__(**kwargs) self.location = kwargs.get('location', None) - self.properties = kwargs.get('properties', None) + self.properties = kwargs['properties'] -class DeploymentExportResult(Model): - """The deployment export result. . +class DeploymentExportResult(msrest.serialization.Model): + """The deployment export result. :param template: The template content. :type template: object @@ -196,16 +207,18 @@ class DeploymentExportResult(Model): 'template': {'key': 'template', 'type': 'object'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentExportResult, self).__init__(**kwargs) self.template = kwargs.get('template', None) -class DeploymentExtended(Model): +class DeploymentExtended(msrest.serialization.Model): """Deployment information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The ID of the deployment. :vartype id: str @@ -234,7 +247,10 @@ class DeploymentExtended(Model): 'properties': {'key': 'properties', 'type': 'DeploymentPropertiesExtended'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentExtended, self).__init__(**kwargs) self.id = None self.name = None @@ -243,7 +259,7 @@ def __init__(self, **kwargs): self.properties = kwargs.get('properties', None) -class DeploymentExtendedFilter(Model): +class DeploymentExtendedFilter(msrest.serialization.Model): """Deployment filter. :param provisioning_state: The provisioning state. @@ -254,16 +270,47 @@ class DeploymentExtendedFilter(Model): 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentExtendedFilter, self).__init__(**kwargs) self.provisioning_state = kwargs.get('provisioning_state', None) -class DeploymentOperation(Model): +class DeploymentListResult(msrest.serialization.Model): + """List of deployments. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[DeploymentExtended]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(DeploymentListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = None + + +class DeploymentOperation(msrest.serialization.Model): """Deployment operation information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Full deployment operation ID. :vartype id: str @@ -285,23 +332,25 @@ class DeploymentOperation(Model): 'properties': {'key': 'properties', 'type': 'DeploymentOperationProperties'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentOperation, self).__init__(**kwargs) self.id = None self.operation_id = None self.properties = kwargs.get('properties', None) -class DeploymentOperationProperties(Model): +class DeploymentOperationProperties(msrest.serialization.Model): """Deployment operation properties. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar provisioning_state: The state of the provisioning. :vartype provisioning_state: str :ivar timestamp: The date and time of the operation. - :vartype timestamp: datetime + :vartype timestamp: ~datetime.datetime :ivar service_request_id: Deployment operation service request id. :vartype service_request_id: str :ivar status_code: Operation status code. @@ -309,14 +358,11 @@ class DeploymentOperationProperties(Model): :ivar status_message: Operation status message. :vartype status_message: object :ivar target_resource: The target resource. - :vartype target_resource: - ~azure.mgmt.resource.resources.v2018_05_01.models.TargetResource + :vartype target_resource: ~azure.mgmt.resource.resources.v2018_05_01.models.TargetResource :ivar request: The HTTP request message. - :vartype request: - ~azure.mgmt.resource.resources.v2018_05_01.models.HttpMessage + :vartype request: ~azure.mgmt.resource.resources.v2018_05_01.models.HttpMessage :ivar response: The HTTP response message. - :vartype response: - ~azure.mgmt.resource.resources.v2018_05_01.models.HttpMessage + :vartype response: ~azure.mgmt.resource.resources.v2018_05_01.models.HttpMessage """ _validation = { @@ -341,7 +387,10 @@ class DeploymentOperationProperties(Model): 'response': {'key': 'response', 'type': 'HttpMessage'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentOperationProperties, self).__init__(**kwargs) self.provisioning_state = None self.timestamp = None @@ -353,48 +402,68 @@ def __init__(self, **kwargs): self.response = None -class DeploymentProperties(Model): +class DeploymentOperationsListResult(msrest.serialization.Model): + """List of deployment operations. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[DeploymentOperation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(DeploymentOperationsListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = None + + +class DeploymentProperties(msrest.serialization.Model): """Deployment properties. 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 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. + :param 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: object - :param 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. 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. + :param 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. + 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: object - :param 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 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 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 + 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 + :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 + :type on_error_deployment: ~azure.mgmt.resource.resources.v2018_05_01.models.OnErrorDeployment """ _validation = { @@ -406,64 +475,57 @@ class DeploymentProperties(Model): 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, 'parameters': {'key': 'parameters', 'type': 'object'}, 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, - 'mode': {'key': 'mode', 'type': 'DeploymentMode'}, + 'mode': {'key': 'mode', 'type': 'str'}, 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, 'on_error_deployment': {'key': 'onErrorDeployment', 'type': 'OnErrorDeployment'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentProperties, self).__init__(**kwargs) self.template = kwargs.get('template', None) self.template_link = kwargs.get('template_link', None) self.parameters = kwargs.get('parameters', None) self.parameters_link = kwargs.get('parameters_link', None) - self.mode = kwargs.get('mode', None) + self.mode = kwargs['mode'] self.debug_setting = kwargs.get('debug_setting', None) self.on_error_deployment = kwargs.get('on_error_deployment', None) -class DeploymentPropertiesExtended(Model): +class DeploymentPropertiesExtended(msrest.serialization.Model): """Deployment properties with additional details. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :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 + :vartype timestamp: ~datetime.datetime :param outputs: Key/value pairs that represent deployment output. :type outputs: object - :param providers: The list of resource providers needed for the - deployment. - :type providers: - list[~azure.mgmt.resource.resources.v2018_05_01.models.Provider] + :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 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: object - :param 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. + :param 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: object - :param 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 include: 'Incremental', 'Complete' - :type mode: str or - ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentMode + :param 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 + 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 + :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.OnErrorDeploymentExtended @@ -486,12 +548,15 @@ class DeploymentPropertiesExtended(Model): 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, 'parameters': {'key': 'parameters', 'type': 'object'}, 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, - 'mode': {'key': 'mode', 'type': 'DeploymentMode'}, + 'mode': {'key': 'mode', 'type': 'str'}, 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, 'on_error_deployment': {'key': 'onErrorDeployment', 'type': 'OnErrorDeploymentExtended'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentPropertiesExtended, self).__init__(**kwargs) self.provisioning_state = None self.correlation_id = None @@ -508,7 +573,7 @@ def __init__(self, **kwargs): self.on_error_deployment = kwargs.get('on_error_deployment', None) -class DeploymentValidateResult(Model): +class DeploymentValidateResult(msrest.serialization.Model): """Information from validate template deployment response. :param error: Validation error. @@ -524,17 +589,19 @@ class DeploymentValidateResult(Model): 'properties': {'key': 'properties', 'type': 'DeploymentPropertiesExtended'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentValidateResult, self).__init__(**kwargs) self.error = kwargs.get('error', None) self.properties = kwargs.get('properties', None) -class ErrorAdditionalInfo(Model): +class ErrorAdditionalInfo(msrest.serialization.Model): """The resource management error additional info. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar type: The additional info type. :vartype type: str @@ -552,17 +619,19 @@ class ErrorAdditionalInfo(Model): 'info': {'key': 'info', 'type': 'object'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None -class ErrorResponse(Model): +class ErrorResponse(msrest.serialization.Model): """The resource management error response. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar code: The error code. :vartype code: str @@ -571,8 +640,7 @@ class ErrorResponse(Model): :ivar target: The error target. :vartype target: str :ivar details: The error details. - :vartype details: - list[~azure.mgmt.resource.resources.v2018_05_01.models.ErrorResponse] + :vartype details: list[~azure.mgmt.resource.resources.v2018_05_01.models.ErrorResponse] :ivar additional_info: The error additional info. :vartype additional_info: list[~azure.mgmt.resource.resources.v2018_05_01.models.ErrorAdditionalInfo] @@ -594,7 +662,10 @@ class ErrorResponse(Model): 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ErrorResponse, self).__init__(**kwargs) self.code = None self.message = None @@ -603,16 +674,15 @@ def __init__(self, **kwargs): self.additional_info = None -class ExportTemplateRequest(Model): +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, supply an array with single entry '*'. + :param 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', 'SkipResourceNameParameterization', - 'SkipAllParameterization' + :param options: The export template options. A CSV-formatted list containing zero or more of + the following: 'IncludeParameterDefaultValue', 'IncludeComments', + 'SkipResourceNameParameterization', 'SkipAllParameterization'. :type options: str """ @@ -621,27 +691,29 @@ class ExportTemplateRequest(Model): 'options': {'key': 'options', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ExportTemplateRequest, self).__init__(**kwargs) self.resources = kwargs.get('resources', None) self.options = kwargs.get('options', None) -class Resource(Model): +class Resource(msrest.serialization.Model): """Specified resource. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID + :ivar id: Resource ID. :vartype id: str - :ivar name: Resource name + :ivar name: Resource name. :vartype name: str - :ivar type: Resource type + :ivar type: Resource type. :vartype type: str - :param location: Resource location + :param location: Resource location. :type location: str - :param tags: Resource tags + :param tags: A set of tags. Resource tags. :type tags: dict[str, str] """ @@ -659,7 +731,10 @@ class Resource(Model): 'tags': {'key': 'tags', 'type': '{str}'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -671,18 +746,17 @@ def __init__(self, **kwargs): class GenericResource(Resource): """Resource information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID + :ivar id: Resource ID. :vartype id: str - :ivar name: Resource name + :ivar name: Resource name. :vartype name: str - :ivar type: Resource type + :ivar type: Resource type. :vartype type: str - :param location: Resource location + :param location: Resource location. :type location: str - :param tags: Resource tags + :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 @@ -719,7 +793,10 @@ class GenericResource(Resource): 'identity': {'key': 'identity', 'type': 'Identity'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(GenericResource, self).__init__(**kwargs) self.plan = kwargs.get('plan', None) self.properties = kwargs.get('properties', None) @@ -732,18 +809,17 @@ def __init__(self, **kwargs): class GenericResourceExpanded(GenericResource): """Resource information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID + :ivar id: Resource ID. :vartype id: str - :ivar name: Resource name + :ivar name: Resource name. :vartype name: str - :ivar type: Resource type + :ivar type: Resource type. :vartype type: str - :param location: Resource location + :param location: Resource location. :type location: str - :param tags: Resource tags + :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 @@ -757,14 +833,14 @@ class GenericResourceExpanded(GenericResource): :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 created_time: The created time of the resource. This is only present - if requested via the $expand query parameter. - :vartype created_time: datetime - :ivar changed_time: The changed time of the resource. This is only present - if requested via the $expand query parameter. - :vartype changed_time: datetime - :ivar provisioning_state: The provisioning state of the resource. This is - only present if requested via the $expand query parameter. + :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 + :ivar changed_time: The changed time of the resource. This is only present if requested via the + $expand query parameter. + :vartype changed_time: ~datetime.datetime + :ivar provisioning_state: The provisioning state of the resource. This is only present if + requested via the $expand query parameter. :vartype provisioning_state: str """ @@ -795,14 +871,17 @@ class GenericResourceExpanded(GenericResource): 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(GenericResourceExpanded, self).__init__(**kwargs) self.created_time = None self.changed_time = None self.provisioning_state = None -class GenericResourceFilter(Model): +class GenericResourceFilter(msrest.serialization.Model): """Resource filter. :param resource_type: The resource type. @@ -819,14 +898,17 @@ class GenericResourceFilter(Model): 'tagvalue': {'key': 'tagvalue', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(GenericResourceFilter, self).__init__(**kwargs) self.resource_type = kwargs.get('resource_type', None) self.tagname = kwargs.get('tagname', None) self.tagvalue = kwargs.get('tagvalue', None) -class HttpMessage(Model): +class HttpMessage(msrest.serialization.Model): """HTTP message. :param content: HTTP message content. @@ -837,31 +919,31 @@ class HttpMessage(Model): 'content': {'key': 'content', 'type': 'object'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(HttpMessage, self).__init__(**kwargs) self.content = kwargs.get('content', None) -class Identity(Model): +class Identity(msrest.serialization.Model): """Identity for the resource. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar principal_id: The principal ID of resource identity. :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :param 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 user identity dictionary key references will be ARM - resource ids in the form: + :param 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 + 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, - ~azure.mgmt.resource.resources.v2018_05_01.models.IdentityUserAssignedIdentitiesValue] + ~azure.mgmt.resource.resources.v2018_05_01.models.ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties] """ _validation = { @@ -872,11 +954,14 @@ class Identity(Model): _attribute_map = { 'principal_id': {'key': 'principalId', 'type': 'str'}, 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'ResourceIdentityType'}, - 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{IdentityUserAssignedIdentitiesValue}'}, + 'type': {'key': 'type', 'type': 'str'}, + 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties}'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Identity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None @@ -884,71 +969,40 @@ def __init__(self, **kwargs): self.user_assigned_identities = kwargs.get('user_assigned_identities', None) -class IdentityUserAssignedIdentitiesValue(Model): - """IdentityUserAssignedIdentitiesValue. - - Variables are only populated by the server, and will be ignored when - sending a request. - - :ivar principal_id: The principal id of user assigned identity. - :vartype principal_id: str - :ivar client_id: The client id of user assigned identity. - :vartype client_id: str - """ - - _validation = { - 'principal_id': {'readonly': True}, - 'client_id': {'readonly': True}, - } - - _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'client_id': {'key': 'clientId', 'type': 'str'}, - } - - def __init__(self, **kwargs): - super(IdentityUserAssignedIdentitiesValue, self).__init__(**kwargs) - self.principal_id = None - self.client_id = None - - -class OnErrorDeployment(Model): +class OnErrorDeployment(msrest.serialization.Model): """Deployment on error behavior. - :param 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 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 """ _attribute_map = { - 'type': {'key': 'type', 'type': 'OnErrorDeploymentType'}, + 'type': {'key': 'type', 'type': 'str'}, 'deployment_name': {'key': 'deploymentName', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(OnErrorDeployment, self).__init__(**kwargs) self.type = kwargs.get('type', None) self.deployment_name = kwargs.get('deployment_name', None) -class OnErrorDeploymentExtended(Model): +class OnErrorDeploymentExtended(msrest.serialization.Model): """Deployment on error behavior with additional details. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar provisioning_state: The state of the provisioning for the on error - deployment. + :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 SpecificDeployment. Possible values include: - 'LastSuccessful', 'SpecificDeployment' - :type type: str or - ~azure.mgmt.resource.resources.v2018_05_01.models.OnErrorDeploymentType + :param 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 """ @@ -959,25 +1013,27 @@ class OnErrorDeploymentExtended(Model): _attribute_map = { 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'OnErrorDeploymentType'}, + 'type': {'key': 'type', 'type': 'str'}, 'deployment_name': {'key': 'deploymentName', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(OnErrorDeploymentExtended, self).__init__(**kwargs) self.provisioning_state = None self.type = kwargs.get('type', None) self.deployment_name = kwargs.get('deployment_name', None) -class Operation(Model): +class Operation(msrest.serialization.Model): """Microsoft.Resources operation. - :param name: Operation name: {provider}/{resource}/{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 + :type display: ~azure.mgmt.resource.resources.v2018_05_01.models.OperationDisplay """ _attribute_map = { @@ -985,19 +1041,21 @@ class Operation(Model): 'display': {'key': 'display', 'type': 'OperationDisplay'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Operation, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.display = kwargs.get('display', None) -class OperationDisplay(Model): +class OperationDisplay(msrest.serialization.Model): """The object that represents the operation. - :param provider: Service provider: Microsoft.Resources + :param provider: Service provider: Microsoft.Resources. :type provider: str - :param resource: Resource on which the operation is performed: Profile, - endpoint, etc. + :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 @@ -1012,7 +1070,10 @@ class OperationDisplay(Model): 'description': {'key': 'description', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(OperationDisplay, self).__init__(**kwargs) self.provider = kwargs.get('provider', None) self.resource = kwargs.get('resource', None) @@ -1020,15 +1081,37 @@ def __init__(self, **kwargs): self.description = kwargs.get('description', None) -class ParametersLink(Model): +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 + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Operation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(OperationListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class ParametersLink(msrest.serialization.Model): """Entity representing the reference to the deployment parameters. 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. + :param content_version: If included, must match the ContentVersion in the template. :type content_version: str """ @@ -1041,13 +1124,16 @@ class ParametersLink(Model): 'content_version': {'key': 'contentVersion', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ParametersLink, self).__init__(**kwargs) - self.uri = kwargs.get('uri', None) + self.uri = kwargs['uri'] self.content_version = kwargs.get('content_version', None) -class Plan(Model): +class Plan(msrest.serialization.Model): """Plan for the resource. :param name: The plan ID. @@ -1070,7 +1156,10 @@ class Plan(Model): 'version': {'key': 'version', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Plan, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.publisher = kwargs.get('publisher', None) @@ -1079,11 +1168,10 @@ def __init__(self, **kwargs): self.version = kwargs.get('version', None) -class Provider(Model): +class Provider(msrest.serialization.Model): """Resource provider information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The provider ID. :vartype id: str @@ -1109,7 +1197,10 @@ class Provider(Model): 'resource_types': {'key': 'resourceTypes', 'type': '[ProviderResourceType]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Provider, self).__init__(**kwargs) self.id = None self.namespace = kwargs.get('namespace', None) @@ -1117,17 +1208,44 @@ def __init__(self, **kwargs): self.resource_types = None -class ProviderResourceType(Model): +class ProviderListResult(msrest.serialization.Model): + """List of resource providers. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Provider]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ProviderListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = None + + +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. + :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] + :type aliases: list[~azure.mgmt.resource.resources.v2018_05_01.models.AliasType] :param api_versions: The API version. :type api_versions: list[str] :param properties: The properties. @@ -1142,7 +1260,10 @@ class ProviderResourceType(Model): 'properties': {'key': 'properties', 'type': '{str}'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ProviderResourceType, self).__init__(**kwargs) self.resource_type = kwargs.get('resource_type', None) self.locations = kwargs.get('locations', None) @@ -1151,11 +1272,10 @@ def __init__(self, **kwargs): self.properties = kwargs.get('properties', None) -class ResourceGroup(Model): +class ResourceGroup(msrest.serialization.Model): """Resource group information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. @@ -1165,17 +1285,14 @@ class ResourceGroup(Model): :vartype name: str :ivar type: The type of the resource group. :vartype type: str - :param 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 resource group has been created. It must be one of - the supported Azure locations. + :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 + 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. + :param managed_by: The ID of the resource that manages this resource group. :type managed_by: str - :param tags: The tags attached to the resource group. + :param tags: A set of tags. The tags attached to the resource group. :type tags: dict[str, str] """ @@ -1196,18 +1313,21 @@ class ResourceGroup(Model): 'tags': {'key': 'tags', 'type': '{str}'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ResourceGroup, self).__init__(**kwargs) self.id = None self.name = None self.type = None self.properties = kwargs.get('properties', None) - self.location = kwargs.get('location', None) + self.location = kwargs['location'] self.managed_by = kwargs.get('managed_by', None) self.tags = kwargs.get('tags', None) -class ResourceGroupExportResult(Model): +class ResourceGroupExportResult(msrest.serialization.Model): """Resource group export result. :param template: The template content. @@ -1222,13 +1342,16 @@ class ResourceGroupExportResult(Model): 'error': {'key': 'error', 'type': 'ResourceManagementErrorWithDetails'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ResourceGroupExportResult, self).__init__(**kwargs) self.template = kwargs.get('template', None) self.error = kwargs.get('error', None) -class ResourceGroupFilter(Model): +class ResourceGroupFilter(msrest.serialization.Model): """Resource group filter. :param tag_name: The tag name. @@ -1242,24 +1365,54 @@ class ResourceGroupFilter(Model): 'tag_value': {'key': 'tagValue', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ResourceGroupFilter, self).__init__(**kwargs) self.tag_name = kwargs.get('tag_name', None) self.tag_value = kwargs.get('tag_value', None) -class ResourceGroupPatchable(Model): +class ResourceGroupListResult(msrest.serialization.Model): + """List of resource groups. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ResourceGroup]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ResourceGroupListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = None + + +class ResourceGroupPatchable(msrest.serialization.Model): """Resource group information. :param name: The name of the resource group. :type name: str - :param 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. + :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: The tags attached to the resource group. + :param tags: A set of tags. The tags attached to the resource group. :type tags: dict[str, str] """ @@ -1270,7 +1423,10 @@ class ResourceGroupPatchable(Model): 'tags': {'key': 'tags', 'type': '{str}'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ResourceGroupPatchable, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.properties = kwargs.get('properties', None) @@ -1278,11 +1434,10 @@ def __init__(self, **kwargs): self.tags = kwargs.get('tags', None) -class ResourceGroupProperties(Model): +class ResourceGroupProperties(msrest.serialization.Model): """The resource group properties. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar provisioning_state: The provisioning state. :vartype provisioning_state: str @@ -1296,16 +1451,47 @@ class ResourceGroupProperties(Model): 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ResourceGroupProperties, self).__init__(**kwargs) self.provisioning_state = None -class ResourceManagementErrorWithDetails(Model): +class ResourceListResult(msrest.serialization.Model): + """List of resource groups. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[GenericResourceExpanded]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ResourceListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = None + + +class ResourceManagementErrorWithDetails(msrest.serialization.Model): """The detailed error message of resource management. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar code: The error code returned when exporting the template. :vartype code: str @@ -1332,7 +1518,10 @@ class ResourceManagementErrorWithDetails(Model): 'details': {'key': 'details', 'type': '[ResourceManagementErrorWithDetails]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ResourceManagementErrorWithDetails, self).__init__(**kwargs) self.code = None self.message = None @@ -1340,7 +1529,7 @@ def __init__(self, **kwargs): self.details = None -class ResourceProviderOperationDisplayProperties(Model): +class ResourceProviderOperationDisplayProperties(msrest.serialization.Model): """Resource provider operation's display properties. :param publisher: Operation description. @@ -1363,7 +1552,10 @@ class ResourceProviderOperationDisplayProperties(Model): 'description': {'key': 'description', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ResourceProviderOperationDisplayProperties, self).__init__(**kwargs) self.publisher = kwargs.get('publisher', None) self.provider = kwargs.get('provider', None) @@ -1372,7 +1564,7 @@ def __init__(self, **kwargs): self.description = kwargs.get('description', None) -class ResourcesMoveInfo(Model): +class ResourcesMoveInfo(msrest.serialization.Model): """Parameters of move resources. :param resources: The IDs of the resources. @@ -1386,13 +1578,16 @@ class ResourcesMoveInfo(Model): 'target_resource_group': {'key': 'targetResourceGroup', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ResourcesMoveInfo, self).__init__(**kwargs) self.resources = kwargs.get('resources', None) self.target_resource_group = kwargs.get('target_resource_group', None) -class Sku(Model): +class Sku(msrest.serialization.Model): """SKU for the resource. :param name: The SKU name. @@ -1418,7 +1613,10 @@ class Sku(Model): 'capacity': {'key': 'capacity', 'type': 'int'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Sku, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.tier = kwargs.get('tier', None) @@ -1428,10 +1626,10 @@ def __init__(self, **kwargs): self.capacity = kwargs.get('capacity', None) -class SubResource(Model): +class SubResource(msrest.serialization.Model): """Sub-resource. - :param id: Resource ID + :param id: Resource ID. :type id: str """ @@ -1439,12 +1637,15 @@ class SubResource(Model): 'id': {'key': 'id', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(SubResource, self).__init__(**kwargs) self.id = kwargs.get('id', None) -class TagCount(Model): +class TagCount(msrest.serialization.Model): """Tag count. :param type: Type of count. @@ -1458,29 +1659,29 @@ class TagCount(Model): 'value': {'key': 'value', 'type': 'int'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(TagCount, self).__init__(**kwargs) self.type = kwargs.get('type', None) self.value = kwargs.get('value', None) -class TagDetails(Model): +class TagDetails(msrest.serialization.Model): """Tag details. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :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 created and has no associated resources, the value - is 0. + :param 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] + :type values: list[~azure.mgmt.resource.resources.v2018_05_01.models.TagValue] """ _validation = { @@ -1494,7 +1695,10 @@ class TagDetails(Model): 'values': {'key': 'values', 'type': '[TagValue]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(TagDetails, self).__init__(**kwargs) self.id = None self.tag_name = kwargs.get('tag_name', None) @@ -1502,11 +1706,39 @@ def __init__(self, **kwargs): self.values = kwargs.get('values', None) -class TagValue(Model): +class TagsListResult(msrest.serialization.Model): + """List of subscription tags. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[TagDetails]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(TagsListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = None + + +class TagValue(msrest.serialization.Model): """Tag information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The tag ID. :vartype id: str @@ -1526,14 +1758,17 @@ class TagValue(Model): 'count': {'key': 'count', 'type': 'TagCount'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(TagValue, self).__init__(**kwargs) self.id = None self.tag_value = kwargs.get('tag_value', None) self.count = kwargs.get('count', None) -class TargetResource(Model): +class TargetResource(msrest.serialization.Model): """Target resource. :param id: The ID of the resource. @@ -1550,16 +1785,18 @@ class TargetResource(Model): 'resource_type': {'key': 'resourceType', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(TargetResource, self).__init__(**kwargs) self.id = kwargs.get('id', None) self.resource_name = kwargs.get('resource_name', None) self.resource_type = kwargs.get('resource_type', None) -class TemplateHashResult(Model): - """Result of the request to calculate template hash. It contains a string of - minified template and its hash. +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 @@ -1572,21 +1809,23 @@ class TemplateHashResult(Model): 'template_hash': {'key': 'templateHash', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(TemplateHashResult, self).__init__(**kwargs) self.minified_template = kwargs.get('minified_template', None) self.template_hash = kwargs.get('template_hash', None) -class TemplateLink(Model): +class TemplateLink(msrest.serialization.Model): """Entity representing the reference to the template. 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. + :param content_version: If included, must match the ContentVersion in the template. :type content_version: str """ @@ -1599,7 +1838,10 @@ class TemplateLink(Model): 'content_version': {'key': 'contentVersion', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(TemplateLink, self).__init__(**kwargs) - self.uri = kwargs.get('uri', None) + self.uri = kwargs['uri'] self.content_version = kwargs.get('content_version', 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 737862b6abbd..571ff69fcbc3 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 @@ -1,20 +1,20 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.serialization import Model -from msrest.exceptions import HttpOperationError +from typing import Dict, List, Optional, Union +import msrest.serialization -class AliasPathType(Model): - """The type of the paths for alias. . +from ._resource_management_client_enums import * + + +class AliasPathType(msrest.serialization.Model): + """The type of the paths for alias. :param path: The path of an alias. :type path: str @@ -27,20 +27,25 @@ class AliasPathType(Model): 'api_versions': {'key': 'apiVersions', 'type': '[str]'}, } - def __init__(self, *, path: str=None, api_versions=None, **kwargs) -> None: + def __init__( + self, + *, + path: Optional[str] = None, + api_versions: Optional[List[str]] = None, + **kwargs + ): super(AliasPathType, self).__init__(**kwargs) self.path = path self.api_versions = api_versions -class AliasType(Model): - """The alias type. . +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] + :type paths: list[~azure.mgmt.resource.resources.v2018_05_01.models.AliasPathType] """ _attribute_map = { @@ -48,13 +53,19 @@ class AliasType(Model): 'paths': {'key': 'paths', 'type': '[AliasPathType]'}, } - def __init__(self, *, name: str=None, paths=None, **kwargs) -> None: + def __init__( + self, + *, + name: Optional[str] = None, + paths: Optional[List["AliasPathType"]] = None, + **kwargs + ): super(AliasType, self).__init__(**kwargs) self.name = name self.paths = paths -class BasicDependency(Model): +class BasicDependency(msrest.serialization.Model): """Deployment dependency information. :param id: The ID of the dependency. @@ -71,52 +82,59 @@ class BasicDependency(Model): 'resource_name': {'key': 'resourceName', 'type': 'str'}, } - def __init__(self, *, id: str=None, resource_type: str=None, resource_name: str=None, **kwargs) -> None: + def __init__( + self, + *, + id: Optional[str] = None, + resource_type: Optional[str] = None, + resource_name: Optional[str] = None, + **kwargs + ): super(BasicDependency, self).__init__(**kwargs) self.id = id self.resource_type = resource_type self.resource_name = resource_name -class CloudError(Model): - """An error response for a resource management request. +class ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties(msrest.serialization.Model): + """ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties. - :param error: - :type error: - ~azure.mgmt.resource.resources.v2018_05_01.models.ErrorResponse + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar principal_id: The principal id of user assigned identity. + :vartype principal_id: str + :ivar client_id: The client id of user assigned identity. + :vartype client_id: str """ - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorResponse'}, + _validation = { + 'principal_id': {'readonly': True}, + 'client_id': {'readonly': True}, } - def __init__(self, *, error=None, **kwargs) -> None: - super(CloudError, self).__init__(**kwargs) - self.error = error - - -class CloudErrorException(HttpOperationError): - """Server responsed with exception of type: 'CloudError'. - - :param deserialize: A deserializer - :param response: Server response to be deserialized. - """ - - def __init__(self, deserialize, response, *args): + _attribute_map = { + 'principal_id': {'key': 'principalId', 'type': 'str'}, + 'client_id': {'key': 'clientId', 'type': 'str'}, + } - super(CloudErrorException, self).__init__(deserialize, response, 'CloudError', *args) + def __init__( + self, + **kwargs + ): + super(ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties, self).__init__(**kwargs) + self.principal_id = None + self.client_id = None -class DebugSetting(Model): +class DebugSetting(msrest.serialization.Model): """DebugSetting. - :param 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. + :param 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 """ @@ -124,17 +142,21 @@ class DebugSetting(Model): 'detail_level': {'key': 'detailLevel', 'type': 'str'}, } - def __init__(self, *, detail_level: str=None, **kwargs) -> None: + def __init__( + self, + *, + detail_level: Optional[str] = None, + **kwargs + ): super(DebugSetting, self).__init__(**kwargs) self.detail_level = detail_level -class Dependency(Model): +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] + :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. @@ -150,7 +172,15 @@ class Dependency(Model): 'resource_name': {'key': 'resourceName', 'type': 'str'}, } - def __init__(self, *, depends_on=None, id: str=None, resource_type: str=None, resource_name: str=None, **kwargs) -> None: + def __init__( + self, + *, + depends_on: Optional[List["BasicDependency"]] = None, + id: Optional[str] = None, + resource_type: Optional[str] = None, + resource_name: Optional[str] = None, + **kwargs + ): super(Dependency, self).__init__(**kwargs) self.depends_on = depends_on self.id = id @@ -158,7 +188,7 @@ def __init__(self, *, depends_on=None, id: str=None, resource_type: str=None, re self.resource_name = resource_name -class Deployment(Model): +class Deployment(msrest.serialization.Model): """Deployment operation parameters. All required parameters must be populated in order to send to Azure. @@ -166,8 +196,7 @@ class Deployment(Model): :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 + :type properties: ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentProperties """ _validation = { @@ -179,14 +208,20 @@ class Deployment(Model): 'properties': {'key': 'properties', 'type': 'DeploymentProperties'}, } - def __init__(self, *, properties, location: str=None, **kwargs) -> None: + def __init__( + self, + *, + properties: "DeploymentProperties", + location: Optional[str] = None, + **kwargs + ): super(Deployment, self).__init__(**kwargs) self.location = location self.properties = properties -class DeploymentExportResult(Model): - """The deployment export result. . +class DeploymentExportResult(msrest.serialization.Model): + """The deployment export result. :param template: The template content. :type template: object @@ -196,16 +231,20 @@ class DeploymentExportResult(Model): 'template': {'key': 'template', 'type': 'object'}, } - def __init__(self, *, template=None, **kwargs) -> None: + def __init__( + self, + *, + template: Optional[object] = None, + **kwargs + ): super(DeploymentExportResult, self).__init__(**kwargs) self.template = template -class DeploymentExtended(Model): +class DeploymentExtended(msrest.serialization.Model): """Deployment information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The ID of the deployment. :vartype id: str @@ -234,7 +273,13 @@ class DeploymentExtended(Model): 'properties': {'key': 'properties', 'type': 'DeploymentPropertiesExtended'}, } - def __init__(self, *, location: str=None, properties=None, **kwargs) -> None: + def __init__( + self, + *, + location: Optional[str] = None, + properties: Optional["DeploymentPropertiesExtended"] = None, + **kwargs + ): super(DeploymentExtended, self).__init__(**kwargs) self.id = None self.name = None @@ -243,7 +288,7 @@ def __init__(self, *, location: str=None, properties=None, **kwargs) -> None: self.properties = properties -class DeploymentExtendedFilter(Model): +class DeploymentExtendedFilter(msrest.serialization.Model): """Deployment filter. :param provisioning_state: The provisioning state. @@ -254,16 +299,51 @@ class DeploymentExtendedFilter(Model): 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, } - def __init__(self, *, provisioning_state: str=None, **kwargs) -> None: + def __init__( + self, + *, + provisioning_state: Optional[str] = None, + **kwargs + ): super(DeploymentExtendedFilter, self).__init__(**kwargs) self.provisioning_state = provisioning_state -class DeploymentOperation(Model): +class DeploymentListResult(msrest.serialization.Model): + """List of deployments. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[DeploymentExtended]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["DeploymentExtended"]] = None, + **kwargs + ): + super(DeploymentListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class DeploymentOperation(msrest.serialization.Model): """Deployment operation information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Full deployment operation ID. :vartype id: str @@ -285,23 +365,27 @@ class DeploymentOperation(Model): 'properties': {'key': 'properties', 'type': 'DeploymentOperationProperties'}, } - def __init__(self, *, properties=None, **kwargs) -> None: + def __init__( + self, + *, + properties: Optional["DeploymentOperationProperties"] = None, + **kwargs + ): super(DeploymentOperation, self).__init__(**kwargs) self.id = None self.operation_id = None self.properties = properties -class DeploymentOperationProperties(Model): +class DeploymentOperationProperties(msrest.serialization.Model): """Deployment operation properties. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar provisioning_state: The state of the provisioning. :vartype provisioning_state: str :ivar timestamp: The date and time of the operation. - :vartype timestamp: datetime + :vartype timestamp: ~datetime.datetime :ivar service_request_id: Deployment operation service request id. :vartype service_request_id: str :ivar status_code: Operation status code. @@ -309,14 +393,11 @@ class DeploymentOperationProperties(Model): :ivar status_message: Operation status message. :vartype status_message: object :ivar target_resource: The target resource. - :vartype target_resource: - ~azure.mgmt.resource.resources.v2018_05_01.models.TargetResource + :vartype target_resource: ~azure.mgmt.resource.resources.v2018_05_01.models.TargetResource :ivar request: The HTTP request message. - :vartype request: - ~azure.mgmt.resource.resources.v2018_05_01.models.HttpMessage + :vartype request: ~azure.mgmt.resource.resources.v2018_05_01.models.HttpMessage :ivar response: The HTTP response message. - :vartype response: - ~azure.mgmt.resource.resources.v2018_05_01.models.HttpMessage + :vartype response: ~azure.mgmt.resource.resources.v2018_05_01.models.HttpMessage """ _validation = { @@ -341,7 +422,10 @@ class DeploymentOperationProperties(Model): 'response': {'key': 'response', 'type': 'HttpMessage'}, } - def __init__(self, **kwargs) -> None: + def __init__( + self, + **kwargs + ): super(DeploymentOperationProperties, self).__init__(**kwargs) self.provisioning_state = None self.timestamp = None @@ -353,48 +437,70 @@ def __init__(self, **kwargs) -> None: self.response = None -class DeploymentProperties(Model): +class DeploymentOperationsListResult(msrest.serialization.Model): + """List of deployment operations. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[DeploymentOperation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["DeploymentOperation"]] = None, + **kwargs + ): + super(DeploymentOperationsListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class DeploymentProperties(msrest.serialization.Model): """Deployment properties. 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 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. + :param 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: object - :param 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. 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. + :param 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. + 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: object - :param 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 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 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 + 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 + :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 + :type on_error_deployment: ~azure.mgmt.resource.resources.v2018_05_01.models.OnErrorDeployment """ _validation = { @@ -406,12 +512,23 @@ class DeploymentProperties(Model): 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, 'parameters': {'key': 'parameters', 'type': 'object'}, 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, - 'mode': {'key': 'mode', 'type': 'DeploymentMode'}, + 'mode': {'key': 'mode', 'type': 'str'}, 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, 'on_error_deployment': {'key': 'onErrorDeployment', 'type': 'OnErrorDeployment'}, } - def __init__(self, *, mode, template=None, template_link=None, parameters=None, parameters_link=None, debug_setting=None, on_error_deployment=None, **kwargs) -> None: + def __init__( + self, + *, + mode: Union[str, "DeploymentMode"], + template: Optional[object] = None, + template_link: Optional["TemplateLink"] = None, + parameters: Optional[object] = None, + parameters_link: Optional["ParametersLink"] = None, + debug_setting: Optional["DebugSetting"] = None, + on_error_deployment: Optional["OnErrorDeployment"] = None, + **kwargs + ): super(DeploymentProperties, self).__init__(**kwargs) self.template = template self.template_link = template_link @@ -422,48 +539,38 @@ def __init__(self, *, mode, template=None, template_link=None, parameters=None, self.on_error_deployment = on_error_deployment -class DeploymentPropertiesExtended(Model): +class DeploymentPropertiesExtended(msrest.serialization.Model): """Deployment properties with additional details. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :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 + :vartype timestamp: ~datetime.datetime :param outputs: Key/value pairs that represent deployment output. :type outputs: object - :param providers: The list of resource providers needed for the - deployment. - :type providers: - list[~azure.mgmt.resource.resources.v2018_05_01.models.Provider] + :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 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: object - :param 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. + :param 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: object - :param 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 include: 'Incremental', 'Complete' - :type mode: str or - ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentMode + :param 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 + 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 + :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.OnErrorDeploymentExtended @@ -486,12 +593,26 @@ class DeploymentPropertiesExtended(Model): 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, 'parameters': {'key': 'parameters', 'type': 'object'}, 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, - 'mode': {'key': 'mode', 'type': 'DeploymentMode'}, + 'mode': {'key': 'mode', 'type': 'str'}, 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, 'on_error_deployment': {'key': 'onErrorDeployment', 'type': 'OnErrorDeploymentExtended'}, } - def __init__(self, *, outputs=None, providers=None, dependencies=None, template=None, template_link=None, parameters=None, parameters_link=None, mode=None, debug_setting=None, on_error_deployment=None, **kwargs) -> None: + def __init__( + self, + *, + outputs: Optional[object] = None, + providers: Optional[List["Provider"]] = None, + dependencies: Optional[List["Dependency"]] = None, + template: Optional[object] = None, + template_link: Optional["TemplateLink"] = None, + parameters: Optional[object] = None, + parameters_link: Optional["ParametersLink"] = None, + mode: Optional[Union[str, "DeploymentMode"]] = None, + debug_setting: Optional["DebugSetting"] = None, + on_error_deployment: Optional["OnErrorDeploymentExtended"] = None, + **kwargs + ): super(DeploymentPropertiesExtended, self).__init__(**kwargs) self.provisioning_state = None self.correlation_id = None @@ -508,7 +629,7 @@ def __init__(self, *, outputs=None, providers=None, dependencies=None, template= self.on_error_deployment = on_error_deployment -class DeploymentValidateResult(Model): +class DeploymentValidateResult(msrest.serialization.Model): """Information from validate template deployment response. :param error: Validation error. @@ -524,17 +645,22 @@ class DeploymentValidateResult(Model): 'properties': {'key': 'properties', 'type': 'DeploymentPropertiesExtended'}, } - def __init__(self, *, error=None, properties=None, **kwargs) -> None: + def __init__( + self, + *, + error: Optional["ResourceManagementErrorWithDetails"] = None, + properties: Optional["DeploymentPropertiesExtended"] = None, + **kwargs + ): super(DeploymentValidateResult, self).__init__(**kwargs) self.error = error self.properties = properties -class ErrorAdditionalInfo(Model): +class ErrorAdditionalInfo(msrest.serialization.Model): """The resource management error additional info. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar type: The additional info type. :vartype type: str @@ -552,17 +678,19 @@ class ErrorAdditionalInfo(Model): 'info': {'key': 'info', 'type': 'object'}, } - def __init__(self, **kwargs) -> None: + def __init__( + self, + **kwargs + ): super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None -class ErrorResponse(Model): +class ErrorResponse(msrest.serialization.Model): """The resource management error response. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar code: The error code. :vartype code: str @@ -571,8 +699,7 @@ class ErrorResponse(Model): :ivar target: The error target. :vartype target: str :ivar details: The error details. - :vartype details: - list[~azure.mgmt.resource.resources.v2018_05_01.models.ErrorResponse] + :vartype details: list[~azure.mgmt.resource.resources.v2018_05_01.models.ErrorResponse] :ivar additional_info: The error additional info. :vartype additional_info: list[~azure.mgmt.resource.resources.v2018_05_01.models.ErrorAdditionalInfo] @@ -594,7 +721,10 @@ class ErrorResponse(Model): 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, } - def __init__(self, **kwargs) -> None: + def __init__( + self, + **kwargs + ): super(ErrorResponse, self).__init__(**kwargs) self.code = None self.message = None @@ -603,16 +733,15 @@ def __init__(self, **kwargs) -> None: self.additional_info = None -class ExportTemplateRequest(Model): +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, supply an array with single entry '*'. + :param 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', 'SkipResourceNameParameterization', - 'SkipAllParameterization' + :param options: The export template options. A CSV-formatted list containing zero or more of + the following: 'IncludeParameterDefaultValue', 'IncludeComments', + 'SkipResourceNameParameterization', 'SkipAllParameterization'. :type options: str """ @@ -621,27 +750,32 @@ class ExportTemplateRequest(Model): 'options': {'key': 'options', 'type': 'str'}, } - def __init__(self, *, resources=None, options: str=None, **kwargs) -> None: + def __init__( + self, + *, + resources: Optional[List[str]] = None, + options: Optional[str] = None, + **kwargs + ): super(ExportTemplateRequest, self).__init__(**kwargs) self.resources = resources self.options = options -class Resource(Model): +class Resource(msrest.serialization.Model): """Specified resource. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID + :ivar id: Resource ID. :vartype id: str - :ivar name: Resource name + :ivar name: Resource name. :vartype name: str - :ivar type: Resource type + :ivar type: Resource type. :vartype type: str - :param location: Resource location + :param location: Resource location. :type location: str - :param tags: Resource tags + :param tags: A set of tags. Resource tags. :type tags: dict[str, str] """ @@ -659,7 +793,13 @@ class Resource(Model): 'tags': {'key': 'tags', 'type': '{str}'}, } - def __init__(self, *, location: str=None, tags=None, **kwargs) -> None: + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -671,18 +811,17 @@ def __init__(self, *, location: str=None, tags=None, **kwargs) -> None: class GenericResource(Resource): """Resource information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID + :ivar id: Resource ID. :vartype id: str - :ivar name: Resource name + :ivar name: Resource name. :vartype name: str - :ivar type: Resource type + :ivar type: Resource type. :vartype type: str - :param location: Resource location + :param location: Resource location. :type location: str - :param tags: Resource tags + :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 @@ -719,7 +858,19 @@ class GenericResource(Resource): 'identity': {'key': 'identity', 'type': 'Identity'}, } - def __init__(self, *, location: str=None, tags=None, plan=None, properties=None, kind: str=None, managed_by: str=None, sku=None, identity=None, **kwargs) -> None: + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + plan: Optional["Plan"] = None, + properties: Optional[object] = None, + kind: Optional[str] = None, + managed_by: Optional[str] = None, + sku: Optional["Sku"] = None, + identity: Optional["Identity"] = None, + **kwargs + ): super(GenericResource, self).__init__(location=location, tags=tags, **kwargs) self.plan = plan self.properties = properties @@ -732,18 +883,17 @@ def __init__(self, *, location: str=None, tags=None, plan=None, properties=None, class GenericResourceExpanded(GenericResource): """Resource information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID + :ivar id: Resource ID. :vartype id: str - :ivar name: Resource name + :ivar name: Resource name. :vartype name: str - :ivar type: Resource type + :ivar type: Resource type. :vartype type: str - :param location: Resource location + :param location: Resource location. :type location: str - :param tags: Resource tags + :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 @@ -757,14 +907,14 @@ class GenericResourceExpanded(GenericResource): :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 created_time: The created time of the resource. This is only present - if requested via the $expand query parameter. - :vartype created_time: datetime - :ivar changed_time: The changed time of the resource. This is only present - if requested via the $expand query parameter. - :vartype changed_time: datetime - :ivar provisioning_state: The provisioning state of the resource. This is - only present if requested via the $expand query parameter. + :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 + :ivar changed_time: The changed time of the resource. This is only present if requested via the + $expand query parameter. + :vartype changed_time: ~datetime.datetime + :ivar provisioning_state: The provisioning state of the resource. This is only present if + requested via the $expand query parameter. :vartype provisioning_state: str """ @@ -795,14 +945,26 @@ class GenericResourceExpanded(GenericResource): 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, } - def __init__(self, *, location: str=None, tags=None, plan=None, properties=None, kind: str=None, managed_by: str=None, sku=None, identity=None, **kwargs) -> None: + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + plan: Optional["Plan"] = None, + properties: Optional[object] = None, + kind: Optional[str] = None, + managed_by: Optional[str] = None, + sku: Optional["Sku"] = None, + identity: Optional["Identity"] = None, + **kwargs + ): 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 self.provisioning_state = None -class GenericResourceFilter(Model): +class GenericResourceFilter(msrest.serialization.Model): """Resource filter. :param resource_type: The resource type. @@ -819,14 +981,21 @@ class GenericResourceFilter(Model): 'tagvalue': {'key': 'tagvalue', 'type': 'str'}, } - def __init__(self, *, resource_type: str=None, tagname: str=None, tagvalue: str=None, **kwargs) -> None: + def __init__( + self, + *, + resource_type: Optional[str] = None, + tagname: Optional[str] = None, + tagvalue: Optional[str] = None, + **kwargs + ): super(GenericResourceFilter, self).__init__(**kwargs) self.resource_type = resource_type self.tagname = tagname self.tagvalue = tagvalue -class HttpMessage(Model): +class HttpMessage(msrest.serialization.Model): """HTTP message. :param content: HTTP message content. @@ -837,31 +1006,33 @@ class HttpMessage(Model): 'content': {'key': 'content', 'type': 'object'}, } - def __init__(self, *, content=None, **kwargs) -> None: + def __init__( + self, + *, + content: Optional[object] = None, + **kwargs + ): super(HttpMessage, self).__init__(**kwargs) self.content = content -class Identity(Model): +class Identity(msrest.serialization.Model): """Identity for the resource. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar principal_id: The principal ID of resource identity. :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :param 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 user identity dictionary key references will be ARM - resource ids in the form: + :param 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 + 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, - ~azure.mgmt.resource.resources.v2018_05_01.models.IdentityUserAssignedIdentitiesValue] + ~azure.mgmt.resource.resources.v2018_05_01.models.ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties] """ _validation = { @@ -872,11 +1043,17 @@ class Identity(Model): _attribute_map = { 'principal_id': {'key': 'principalId', 'type': 'str'}, 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'ResourceIdentityType'}, - 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{IdentityUserAssignedIdentitiesValue}'}, + 'type': {'key': 'type', 'type': 'str'}, + 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties}'}, } - def __init__(self, *, type=None, user_assigned_identities=None, **kwargs) -> None: + def __init__( + self, + *, + type: Optional[Union[str, "ResourceIdentityType"]] = None, + user_assigned_identities: Optional[Dict[str, "ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties"]] = None, + **kwargs + ): super(Identity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None @@ -884,71 +1061,43 @@ def __init__(self, *, type=None, user_assigned_identities=None, **kwargs) -> Non self.user_assigned_identities = user_assigned_identities -class IdentityUserAssignedIdentitiesValue(Model): - """IdentityUserAssignedIdentitiesValue. - - Variables are only populated by the server, and will be ignored when - sending a request. - - :ivar principal_id: The principal id of user assigned identity. - :vartype principal_id: str - :ivar client_id: The client id of user assigned identity. - :vartype client_id: str - """ - - _validation = { - 'principal_id': {'readonly': True}, - 'client_id': {'readonly': True}, - } - - _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'client_id': {'key': 'clientId', 'type': 'str'}, - } - - def __init__(self, **kwargs) -> None: - super(IdentityUserAssignedIdentitiesValue, self).__init__(**kwargs) - self.principal_id = None - self.client_id = None - - -class OnErrorDeployment(Model): +class OnErrorDeployment(msrest.serialization.Model): """Deployment on error behavior. - :param 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 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 """ _attribute_map = { - 'type': {'key': 'type', 'type': 'OnErrorDeploymentType'}, + 'type': {'key': 'type', 'type': 'str'}, 'deployment_name': {'key': 'deploymentName', 'type': 'str'}, } - def __init__(self, *, type=None, deployment_name: str=None, **kwargs) -> None: + def __init__( + self, + *, + type: Optional[Union[str, "OnErrorDeploymentType"]] = None, + deployment_name: Optional[str] = None, + **kwargs + ): super(OnErrorDeployment, self).__init__(**kwargs) self.type = type self.deployment_name = deployment_name -class OnErrorDeploymentExtended(Model): +class OnErrorDeploymentExtended(msrest.serialization.Model): """Deployment on error behavior with additional details. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar provisioning_state: The state of the provisioning for the on error - deployment. + :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 SpecificDeployment. Possible values include: - 'LastSuccessful', 'SpecificDeployment' - :type type: str or - ~azure.mgmt.resource.resources.v2018_05_01.models.OnErrorDeploymentType + :param 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 """ @@ -959,25 +1108,30 @@ class OnErrorDeploymentExtended(Model): _attribute_map = { 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'OnErrorDeploymentType'}, + 'type': {'key': 'type', 'type': 'str'}, 'deployment_name': {'key': 'deploymentName', 'type': 'str'}, } - def __init__(self, *, type=None, deployment_name: str=None, **kwargs) -> None: + def __init__( + self, + *, + type: Optional[Union[str, "OnErrorDeploymentType"]] = None, + deployment_name: Optional[str] = None, + **kwargs + ): super(OnErrorDeploymentExtended, self).__init__(**kwargs) self.provisioning_state = None self.type = type self.deployment_name = deployment_name -class Operation(Model): +class Operation(msrest.serialization.Model): """Microsoft.Resources operation. - :param name: Operation name: {provider}/{resource}/{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 + :type display: ~azure.mgmt.resource.resources.v2018_05_01.models.OperationDisplay """ _attribute_map = { @@ -985,19 +1139,24 @@ class Operation(Model): 'display': {'key': 'display', 'type': 'OperationDisplay'}, } - def __init__(self, *, name: str=None, display=None, **kwargs) -> None: + def __init__( + self, + *, + name: Optional[str] = None, + display: Optional["OperationDisplay"] = None, + **kwargs + ): super(Operation, self).__init__(**kwargs) self.name = name self.display = display -class OperationDisplay(Model): +class OperationDisplay(msrest.serialization.Model): """The object that represents the operation. - :param provider: Service provider: Microsoft.Resources + :param provider: Service provider: Microsoft.Resources. :type provider: str - :param resource: Resource on which the operation is performed: Profile, - endpoint, etc. + :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 @@ -1012,7 +1171,15 @@ class OperationDisplay(Model): 'description': {'key': 'description', 'type': 'str'}, } - def __init__(self, *, provider: str=None, resource: str=None, operation: str=None, description: str=None, **kwargs) -> None: + def __init__( + self, + *, + provider: Optional[str] = None, + resource: Optional[str] = None, + operation: Optional[str] = None, + description: Optional[str] = None, + **kwargs + ): super(OperationDisplay, self).__init__(**kwargs) self.provider = provider self.resource = resource @@ -1020,15 +1187,40 @@ def __init__(self, *, provider: str=None, resource: str=None, operation: str=Non self.description = description -class ParametersLink(Model): +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 + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Operation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["Operation"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(OperationListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ParametersLink(msrest.serialization.Model): """Entity representing the reference to the deployment parameters. 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. + :param content_version: If included, must match the ContentVersion in the template. :type content_version: str """ @@ -1041,13 +1233,19 @@ class ParametersLink(Model): 'content_version': {'key': 'contentVersion', 'type': 'str'}, } - def __init__(self, *, uri: str, content_version: str=None, **kwargs) -> None: + def __init__( + self, + *, + uri: str, + content_version: Optional[str] = None, + **kwargs + ): super(ParametersLink, self).__init__(**kwargs) self.uri = uri self.content_version = content_version -class Plan(Model): +class Plan(msrest.serialization.Model): """Plan for the resource. :param name: The plan ID. @@ -1070,7 +1268,16 @@ class Plan(Model): 'version': {'key': 'version', 'type': 'str'}, } - def __init__(self, *, name: str=None, publisher: str=None, product: str=None, promotion_code: str=None, version: str=None, **kwargs) -> None: + def __init__( + self, + *, + name: Optional[str] = None, + publisher: Optional[str] = None, + product: Optional[str] = None, + promotion_code: Optional[str] = None, + version: Optional[str] = None, + **kwargs + ): super(Plan, self).__init__(**kwargs) self.name = name self.publisher = publisher @@ -1079,11 +1286,10 @@ def __init__(self, *, name: str=None, publisher: str=None, product: str=None, pr self.version = version -class Provider(Model): +class Provider(msrest.serialization.Model): """Resource provider information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The provider ID. :vartype id: str @@ -1109,7 +1315,12 @@ class Provider(Model): 'resource_types': {'key': 'resourceTypes', 'type': '[ProviderResourceType]'}, } - def __init__(self, *, namespace: str=None, **kwargs) -> None: + def __init__( + self, + *, + namespace: Optional[str] = None, + **kwargs + ): super(Provider, self).__init__(**kwargs) self.id = None self.namespace = namespace @@ -1117,17 +1328,46 @@ def __init__(self, *, namespace: str=None, **kwargs) -> None: self.resource_types = None -class ProviderResourceType(Model): +class ProviderListResult(msrest.serialization.Model): + """List of resource providers. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Provider]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["Provider"]] = None, + **kwargs + ): + super(ProviderListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +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. + :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] + :type aliases: list[~azure.mgmt.resource.resources.v2018_05_01.models.AliasType] :param api_versions: The API version. :type api_versions: list[str] :param properties: The properties. @@ -1142,7 +1382,16 @@ class ProviderResourceType(Model): 'properties': {'key': 'properties', 'type': '{str}'}, } - def __init__(self, *, resource_type: str=None, locations=None, aliases=None, api_versions=None, properties=None, **kwargs) -> None: + def __init__( + self, + *, + resource_type: Optional[str] = None, + locations: Optional[List[str]] = None, + aliases: Optional[List["AliasType"]] = None, + api_versions: Optional[List[str]] = None, + properties: Optional[Dict[str, str]] = None, + **kwargs + ): super(ProviderResourceType, self).__init__(**kwargs) self.resource_type = resource_type self.locations = locations @@ -1151,11 +1400,10 @@ def __init__(self, *, resource_type: str=None, locations=None, aliases=None, api self.properties = properties -class ResourceGroup(Model): +class ResourceGroup(msrest.serialization.Model): """Resource group information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. @@ -1165,17 +1413,14 @@ class ResourceGroup(Model): :vartype name: str :ivar type: The type of the resource group. :vartype type: str - :param 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 resource group has been created. It must be one of - the supported Azure locations. + :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 + 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. + :param managed_by: The ID of the resource that manages this resource group. :type managed_by: str - :param tags: The tags attached to the resource group. + :param tags: A set of tags. The tags attached to the resource group. :type tags: dict[str, str] """ @@ -1196,7 +1441,15 @@ class ResourceGroup(Model): 'tags': {'key': 'tags', 'type': '{str}'}, } - def __init__(self, *, location: str, properties=None, managed_by: str=None, tags=None, **kwargs) -> None: + def __init__( + self, + *, + location: str, + properties: Optional["ResourceGroupProperties"] = None, + managed_by: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): super(ResourceGroup, self).__init__(**kwargs) self.id = None self.name = None @@ -1207,7 +1460,7 @@ def __init__(self, *, location: str, properties=None, managed_by: str=None, tags self.tags = tags -class ResourceGroupExportResult(Model): +class ResourceGroupExportResult(msrest.serialization.Model): """Resource group export result. :param template: The template content. @@ -1222,13 +1475,19 @@ class ResourceGroupExportResult(Model): 'error': {'key': 'error', 'type': 'ResourceManagementErrorWithDetails'}, } - def __init__(self, *, template=None, error=None, **kwargs) -> None: + def __init__( + self, + *, + template: Optional[object] = None, + error: Optional["ResourceManagementErrorWithDetails"] = None, + **kwargs + ): super(ResourceGroupExportResult, self).__init__(**kwargs) self.template = template self.error = error -class ResourceGroupFilter(Model): +class ResourceGroupFilter(msrest.serialization.Model): """Resource group filter. :param tag_name: The tag name. @@ -1242,24 +1501,59 @@ class ResourceGroupFilter(Model): 'tag_value': {'key': 'tagValue', 'type': 'str'}, } - def __init__(self, *, tag_name: str=None, tag_value: str=None, **kwargs) -> None: + def __init__( + self, + *, + tag_name: Optional[str] = None, + tag_value: Optional[str] = None, + **kwargs + ): super(ResourceGroupFilter, self).__init__(**kwargs) self.tag_name = tag_name self.tag_value = tag_value -class ResourceGroupPatchable(Model): +class ResourceGroupListResult(msrest.serialization.Model): + """List of resource groups. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ResourceGroup]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["ResourceGroup"]] = None, + **kwargs + ): + super(ResourceGroupListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class ResourceGroupPatchable(msrest.serialization.Model): """Resource group information. :param name: The name of the resource group. :type name: str - :param 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. + :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: The tags attached to the resource group. + :param tags: A set of tags. The tags attached to the resource group. :type tags: dict[str, str] """ @@ -1270,7 +1564,15 @@ class ResourceGroupPatchable(Model): 'tags': {'key': 'tags', 'type': '{str}'}, } - def __init__(self, *, name: str=None, properties=None, managed_by: str=None, tags=None, **kwargs) -> None: + def __init__( + self, + *, + name: Optional[str] = None, + properties: Optional["ResourceGroupProperties"] = None, + managed_by: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): super(ResourceGroupPatchable, self).__init__(**kwargs) self.name = name self.properties = properties @@ -1278,11 +1580,10 @@ def __init__(self, *, name: str=None, properties=None, managed_by: str=None, tag self.tags = tags -class ResourceGroupProperties(Model): +class ResourceGroupProperties(msrest.serialization.Model): """The resource group properties. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar provisioning_state: The provisioning state. :vartype provisioning_state: str @@ -1296,16 +1597,49 @@ class ResourceGroupProperties(Model): 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, } - def __init__(self, **kwargs) -> None: + def __init__( + self, + **kwargs + ): super(ResourceGroupProperties, self).__init__(**kwargs) self.provisioning_state = None -class ResourceManagementErrorWithDetails(Model): +class ResourceListResult(msrest.serialization.Model): + """List of resource groups. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[GenericResourceExpanded]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["GenericResourceExpanded"]] = None, + **kwargs + ): + super(ResourceListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class ResourceManagementErrorWithDetails(msrest.serialization.Model): """The detailed error message of resource management. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar code: The error code returned when exporting the template. :vartype code: str @@ -1332,7 +1666,10 @@ class ResourceManagementErrorWithDetails(Model): 'details': {'key': 'details', 'type': '[ResourceManagementErrorWithDetails]'}, } - def __init__(self, **kwargs) -> None: + def __init__( + self, + **kwargs + ): super(ResourceManagementErrorWithDetails, self).__init__(**kwargs) self.code = None self.message = None @@ -1340,7 +1677,7 @@ def __init__(self, **kwargs) -> None: self.details = None -class ResourceProviderOperationDisplayProperties(Model): +class ResourceProviderOperationDisplayProperties(msrest.serialization.Model): """Resource provider operation's display properties. :param publisher: Operation description. @@ -1363,7 +1700,16 @@ class ResourceProviderOperationDisplayProperties(Model): 'description': {'key': 'description', 'type': 'str'}, } - def __init__(self, *, publisher: str=None, provider: str=None, resource: str=None, operation: str=None, description: str=None, **kwargs) -> None: + def __init__( + self, + *, + publisher: Optional[str] = None, + provider: Optional[str] = None, + resource: Optional[str] = None, + operation: Optional[str] = None, + description: Optional[str] = None, + **kwargs + ): super(ResourceProviderOperationDisplayProperties, self).__init__(**kwargs) self.publisher = publisher self.provider = provider @@ -1372,7 +1718,7 @@ def __init__(self, *, publisher: str=None, provider: str=None, resource: str=Non self.description = description -class ResourcesMoveInfo(Model): +class ResourcesMoveInfo(msrest.serialization.Model): """Parameters of move resources. :param resources: The IDs of the resources. @@ -1386,13 +1732,19 @@ class ResourcesMoveInfo(Model): 'target_resource_group': {'key': 'targetResourceGroup', 'type': 'str'}, } - def __init__(self, *, resources=None, target_resource_group: str=None, **kwargs) -> None: + def __init__( + self, + *, + resources: Optional[List[str]] = None, + target_resource_group: Optional[str] = None, + **kwargs + ): super(ResourcesMoveInfo, self).__init__(**kwargs) self.resources = resources self.target_resource_group = target_resource_group -class Sku(Model): +class Sku(msrest.serialization.Model): """SKU for the resource. :param name: The SKU name. @@ -1418,7 +1770,17 @@ class Sku(Model): 'capacity': {'key': 'capacity', 'type': 'int'}, } - def __init__(self, *, name: str=None, tier: str=None, size: str=None, family: str=None, model: str=None, capacity: int=None, **kwargs) -> None: + def __init__( + self, + *, + name: Optional[str] = None, + tier: Optional[str] = None, + size: Optional[str] = None, + family: Optional[str] = None, + model: Optional[str] = None, + capacity: Optional[int] = None, + **kwargs + ): super(Sku, self).__init__(**kwargs) self.name = name self.tier = tier @@ -1428,10 +1790,10 @@ def __init__(self, *, name: str=None, tier: str=None, size: str=None, family: st self.capacity = capacity -class SubResource(Model): +class SubResource(msrest.serialization.Model): """Sub-resource. - :param id: Resource ID + :param id: Resource ID. :type id: str """ @@ -1439,12 +1801,17 @@ class SubResource(Model): 'id': {'key': 'id', 'type': 'str'}, } - def __init__(self, *, id: str=None, **kwargs) -> None: + def __init__( + self, + *, + id: Optional[str] = None, + **kwargs + ): super(SubResource, self).__init__(**kwargs) self.id = id -class TagCount(Model): +class TagCount(msrest.serialization.Model): """Tag count. :param type: Type of count. @@ -1458,29 +1825,32 @@ class TagCount(Model): 'value': {'key': 'value', 'type': 'int'}, } - def __init__(self, *, type: str=None, value: int=None, **kwargs) -> None: + def __init__( + self, + *, + type: Optional[str] = None, + value: Optional[int] = None, + **kwargs + ): super(TagCount, self).__init__(**kwargs) self.type = type self.value = value -class TagDetails(Model): +class TagDetails(msrest.serialization.Model): """Tag details. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :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 created and has no associated resources, the value - is 0. + :param 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] + :type values: list[~azure.mgmt.resource.resources.v2018_05_01.models.TagValue] """ _validation = { @@ -1494,7 +1864,14 @@ class TagDetails(Model): 'values': {'key': 'values', 'type': '[TagValue]'}, } - def __init__(self, *, tag_name: str=None, count=None, values=None, **kwargs) -> None: + def __init__( + self, + *, + tag_name: Optional[str] = None, + count: Optional["TagCount"] = None, + values: Optional[List["TagValue"]] = None, + **kwargs + ): super(TagDetails, self).__init__(**kwargs) self.id = None self.tag_name = tag_name @@ -1502,11 +1879,41 @@ def __init__(self, *, tag_name: str=None, count=None, values=None, **kwargs) -> self.values = values -class TagValue(Model): +class TagsListResult(msrest.serialization.Model): + """List of subscription tags. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[TagDetails]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["TagDetails"]] = None, + **kwargs + ): + super(TagsListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class TagValue(msrest.serialization.Model): """Tag information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The tag ID. :vartype id: str @@ -1526,14 +1933,20 @@ class TagValue(Model): 'count': {'key': 'count', 'type': 'TagCount'}, } - def __init__(self, *, tag_value: str=None, count=None, **kwargs) -> None: + def __init__( + self, + *, + tag_value: Optional[str] = None, + count: Optional["TagCount"] = None, + **kwargs + ): super(TagValue, self).__init__(**kwargs) self.id = None self.tag_value = tag_value self.count = count -class TargetResource(Model): +class TargetResource(msrest.serialization.Model): """Target resource. :param id: The ID of the resource. @@ -1550,16 +1963,22 @@ class TargetResource(Model): 'resource_type': {'key': 'resourceType', 'type': 'str'}, } - def __init__(self, *, id: str=None, resource_name: str=None, resource_type: str=None, **kwargs) -> None: + def __init__( + self, + *, + id: Optional[str] = None, + resource_name: Optional[str] = None, + resource_type: Optional[str] = None, + **kwargs + ): super(TargetResource, self).__init__(**kwargs) self.id = id self.resource_name = resource_name self.resource_type = resource_type -class TemplateHashResult(Model): - """Result of the request to calculate template hash. It contains a string of - minified template and its hash. +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 @@ -1572,21 +1991,26 @@ class TemplateHashResult(Model): 'template_hash': {'key': 'templateHash', 'type': 'str'}, } - def __init__(self, *, minified_template: str=None, template_hash: str=None, **kwargs) -> None: + def __init__( + self, + *, + minified_template: Optional[str] = None, + template_hash: Optional[str] = None, + **kwargs + ): super(TemplateHashResult, self).__init__(**kwargs) self.minified_template = minified_template self.template_hash = template_hash -class TemplateLink(Model): +class TemplateLink(msrest.serialization.Model): """Entity representing the reference to the template. 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. + :param content_version: If included, must match the ContentVersion in the template. :type content_version: str """ @@ -1599,7 +2023,13 @@ class TemplateLink(Model): 'content_version': {'key': 'contentVersion', 'type': 'str'}, } - def __init__(self, *, uri: str, content_version: str=None, **kwargs) -> None: + def __init__( + self, + *, + uri: str, + content_version: Optional[str] = None, + **kwargs + ): 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/v2018_05_01/models/_paged_models.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/models/_paged_models.py deleted file mode 100644 index 4acf24aa6cab..000000000000 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/models/_paged_models.py +++ /dev/null @@ -1,105 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.paging import Paged - - -class OperationPaged(Paged): - """ - A paging container for iterating over a list of :class:`Operation ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[Operation]'} - } - - def __init__(self, *args, **kwargs): - - super(OperationPaged, self).__init__(*args, **kwargs) -class DeploymentExtendedPaged(Paged): - """ - A paging container for iterating over a list of :class:`DeploymentExtended ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[DeploymentExtended]'} - } - - def __init__(self, *args, **kwargs): - - super(DeploymentExtendedPaged, self).__init__(*args, **kwargs) -class ProviderPaged(Paged): - """ - A paging container for iterating over a list of :class:`Provider ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[Provider]'} - } - - def __init__(self, *args, **kwargs): - - super(ProviderPaged, self).__init__(*args, **kwargs) -class GenericResourceExpandedPaged(Paged): - """ - A paging container for iterating over a list of :class:`GenericResourceExpanded ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[GenericResourceExpanded]'} - } - - def __init__(self, *args, **kwargs): - - super(GenericResourceExpandedPaged, self).__init__(*args, **kwargs) -class ResourceGroupPaged(Paged): - """ - A paging container for iterating over a list of :class:`ResourceGroup ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[ResourceGroup]'} - } - - def __init__(self, *args, **kwargs): - - super(ResourceGroupPaged, self).__init__(*args, **kwargs) -class TagDetailsPaged(Paged): - """ - A paging container for iterating over a list of :class:`TagDetails ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[TagDetails]'} - } - - def __init__(self, *args, **kwargs): - - super(TagDetailsPaged, self).__init__(*args, **kwargs) -class DeploymentOperationPaged(Paged): - """ - A paging container for iterating over a list of :class:`DeploymentOperation ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[DeploymentOperation]'} - } - - def __init__(self, *args, **kwargs): - - super(DeploymentOperationPaged, self).__init__(*args, **kwargs) 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 9fd73ca1de47..fb982486e0e9 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 @@ -1,30 +1,35 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from enum import Enum - class DeploymentMode(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 + the resource group that are not included in the template are deleted. Be careful when using + Complete mode as you may unintentionally delete resources. + """ incremental = "Incremental" complete = "Complete" - class OnErrorDeploymentType(str, Enum): + """The deployment on error behavior type. Possible values are LastSuccessful and + SpecificDeployment. + """ last_successful = "LastSuccessful" specific_deployment = "SpecificDeployment" - class ResourceIdentityType(str, Enum): + """The identity type. + """ system_assigned = "SystemAssigned" user_assigned = "UserAssigned" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/operations/__init__.py index 41027cf11028..a6f5fa20e792 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/operations/__init__.py @@ -1,12 +1,9 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from ._operations import Operations @@ -15,7 +12,7 @@ from ._resources_operations import ResourcesOperations from ._resource_groups_operations import ResourceGroupsOperations from ._tags_operations import TagsOperations -from ._deployment_operations import DeploymentOperations +from ._deployment_operations_operations import DeploymentOperationsOperations __all__ = [ 'Operations', @@ -24,5 +21,5 @@ 'ResourcesOperations', 'ResourceGroupsOperations', 'TagsOperations', - 'DeploymentOperations', + 'DeploymentOperationsOperations', ] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/operations/_deployment_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/operations/_deployment_operations.py deleted file mode 100644 index 123030099d95..000000000000 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/operations/_deployment_operations.py +++ /dev/null @@ -1,320 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError - -from .. import models - - -class DeploymentOperations(object): - """DeploymentOperations operations. - - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. - - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for this operation. Constant value: "2018-05-01". - """ - - models = models - - def __init__(self, client, config, serializer, deserializer): - - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self.api_version = "2018-05-01" - - self.config = config - - def get_at_subscription_scope( - self, deployment_name, operation_id, custom_headers=None, raw=False, **operation_config): - """Gets a deployments operation. - - :param deployment_name: The name of the deployment. - :type deployment_name: str - :param operation_id: The ID of the operation to get. - :type operation_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentOperation or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentOperation - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` - """ - # Construct URL - url = self.get_at_subscription_scope.metadata['url'] - 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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) - - if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentOperation', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - - return deserialized - get_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} - - def list_at_subscription_scope( - self, deployment_name, top=None, custom_headers=None, raw=False, **operation_config): - """Gets all deployments operations for a deployment. - - :param deployment_name: The name of the deployment with the operation - to get. - :type deployment_name: str - :param top: The number of results to return. - :type top: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of DeploymentOperation - :rtype: - ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentOperationPaged[~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentOperation] - :raises: :class:`CloudError` - """ - def prepare_request(next_link=None): - if not next_link: - # Construct URL - url = self.list_at_subscription_scope.metadata['url'] - 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 = {} - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - else: - url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) - return request - - def internal_paging(next_link=None): - request = prepare_request(next_link) - - response = self._client.send(request, stream=False, **operation_config) - - if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response - - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.DeploymentOperationPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} - - def get( - self, resource_group_name, deployment_name, operation_id, custom_headers=None, raw=False, **operation_config): - """Gets a deployments operation. - - :param resource_group_name: The name of the resource group. The name - is case insensitive. - :type resource_group_name: str - :param deployment_name: The name of the deployment. - :type deployment_name: str - :param operation_id: The ID of the operation to get. - :type operation_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentOperation or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentOperation - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` - """ - # Construct URL - url = self.get.metadata['url'] - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, 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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) - - if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentOperation', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}'} - - def list( - self, resource_group_name, deployment_name, top=None, custom_headers=None, raw=False, **operation_config): - """Gets all deployments operations for a deployment. - - :param resource_group_name: The name of the resource group. The name - is case insensitive. - :type resource_group_name: str - :param deployment_name: The name of the deployment with the operation - to get. - :type deployment_name: str - :param top: The number of results to return. - :type top: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of DeploymentOperation - :rtype: - ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentOperationPaged[~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentOperation] - :raises: :class:`CloudError` - """ - def prepare_request(next_link=None): - if not next_link: - # Construct URL - url = self.list.metadata['url'] - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - else: - url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) - return request - - def internal_paging(next_link=None): - request = prepare_request(next_link) - - response = self._client.send(request, stream=False, **operation_config) - - if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response - - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.DeploymentOperationPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations'} 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 new file mode 100644 index 000000000000..aa6057d5f775 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/operations/_deployment_operations_operations.py @@ -0,0 +1,314 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class DeploymentOperationsOperations(object): + """DeploymentOperationsOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2018_05_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def get_at_subscription_scope( + self, + deployment_name, # type: str + operation_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentOperation" + """Gets a deployments operation. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param operation_id: The ID of the operation to get. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentOperation or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentOperation + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentOperation"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + + # 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'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentOperation', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + def list_at_subscription_scope( + self, + deployment_name, # type: str + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.DeploymentOperationsListResult"] + """Gets all deployments operations for a deployment. + + :param deployment_name: The name of the deployment with the operation to get. + :type deployment_name: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentOperationsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + 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 + + def get( + self, + resource_group_name, # type: str + deployment_name, # type: str + operation_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentOperation" + """Gets a deployments operation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param operation_id: The ID of the operation to get. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentOperation or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentOperation + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentOperation"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + + # Construct URL + url = self.get.metadata['url'] # type: 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'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentOperation', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + def list( + self, + resource_group_name, # type: str + deployment_name, # type: str + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.DeploymentOperationsListResult"] + """Gets all deployments operations for a deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment with the operation to get. + :type deployment_name: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentOperationsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations'} # type: ignore 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 b0ff0312c8f5..2c9decd11ab2 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 @@ -1,1274 +1,1243 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError -from msrest.polling import LROPoller, NoPolling -from msrestazure.polling.arm_polling import ARMPolling +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class DeploymentsOperations(object): """DeploymentsOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2018_05_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for this operation. Constant value: "2018-05-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2018-05-01" - - self.config = config - + self._config = config def _delete_at_subscription_scope_initial( - self, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + # Construct URL - url = self.delete_at_subscription_scope.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [202, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - - def delete_at_subscription_scope( - self, deployment_name, custom_headers=None, raw=False, polling=True, **operation_config): - """Deletes a deployment from the deployment history. - - A template deployment that is currently running cannot be deleted. - Deleting a template deployment removes the associated deployment - operations. This is an asynchronous operation that returns a status of - 202 until the template deployment is successfully deleted. The Location - response header contains the URI that is used to obtain the status of - the process. While the process is running, a call to the URI in the - Location header returns a status of 202. When the process finishes, the - URI in the Location header returns a status of 204 on success. If the - asynchronous request failed, the URI in the Location header returns an - error-level status code. + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + def begin_delete_at_subscription_scope( + self, + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """A template deployment that is currently running cannot be deleted. Deleting a template deployment removes the associated deployment operations. This is an asynchronous operation that returns a status of 202 until the template deployment is successfully deleted. The Location response header contains the URI that is used to obtain the status of the process. While the process is running, a call to the URI in the Location header returns a status of 202. When the process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. + + Deletes a deployment from the deployment history. :param deployment_name: The name of the deployment to delete. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns None or - ClientRawResponse if raw==True - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._delete_at_subscription_scope_initial( deployment_name=deployment_name, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - delete_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} + begin_delete_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore def check_existence_at_subscription_scope( - self, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Checks whether the deployment exists. :param deployment_name: The name of the deployment to check. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: bool or ClientRawResponse if raw=true - :rtype: bool or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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'] + 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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204, 404]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = (response.status_code == 204) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - return deserialized - check_existence_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + 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, properties, location=None, custom_headers=None, raw=False, **operation_config): - parameters = models.Deployment(location=location, properties=properties) + self, + deployment_name, # type: str + properties, # type: "models.DeploymentProperties" + location=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentExtended" + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.Deployment(location=location, properties=properties) + api_version = "2018-05-01" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.create_or_update_at_subscription_scope.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'Deployment') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 201]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', response) + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', response) + deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + 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 - def create_or_update_at_subscription_scope( - self, deployment_name, properties, location=None, custom_headers=None, raw=False, polling=True, **operation_config): - """Deploys resources at subscription scope. + def begin_create_or_update_at_subscription_scope( + self, + deployment_name, # type: str + properties, # type: "models.DeploymentProperties" + location=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """You can provide the template and parameters directly in the request or link to JSON files. - You can provide the template and parameters directly in the request or - link to JSON files. + Deploys resources at subscription scope. :param deployment_name: The name of the deployment. :type deployment_name: str :param properties: The deployment properties. - :type properties: - ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentProperties + :type properties: ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentProperties :param location: The location to store the deployment data. :type location: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns DeploymentExtended or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentExtended] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentExtended]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 DeploymentExtended + :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] + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._create_or_update_at_subscription_scope_initial( deployment_name=deployment_name, properties=properties, location=location, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - deserialized = self._deserialize('DeploymentExtended', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - create_or_update_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} + begin_create_or_update_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore def get_at_subscription_scope( - self, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentExtended" """Gets a deployment. :param deployment_name: The name of the deployment to get. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentExtended or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentExtended - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExtended or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentExtended + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + # Construct URL - url = self.get_at_subscription_scope.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', response) + deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} + get_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore def cancel_at_subscription_scope( - self, deployment_name, custom_headers=None, raw=False, **operation_config): - """Cancels a currently running template deployment. + self, + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """You can cancel a deployment only if the provisioningState is Accepted or Running. After the deployment is canceled, the provisioningState is set to Canceled. Canceling a template deployment stops the currently running template deployment and leaves the resources partially deployed. - You can cancel a deployment only if the provisioningState is Accepted - or Running. After the deployment is canceled, the provisioningState is - set to Canceled. Canceling a template deployment stops the currently - running template deployment and leaves the resources partially - deployed. + Cancels a currently running template deployment. :param deployment_name: The name of the deployment to cancel. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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'] + 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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - cancel_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} + cancel_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore def validate_at_subscription_scope( - self, deployment_name, properties, location=None, custom_headers=None, raw=False, **operation_config): - """Validates whether the specified template is syntactically correct and - will be accepted by Azure Resource Manager.. + self, + deployment_name, # type: str + properties, # type: "models.DeploymentProperties" + location=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentValidateResult" + """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. :param deployment_name: The name of the deployment. :type deployment_name: str :param properties: The deployment properties. - :type properties: - ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentProperties + :type properties: ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentProperties :param location: The location to store the deployment data. :type location: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentValidateResult or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentValidateResult - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentValidateResult + :raises: ~azure.core.exceptions.HttpResponseError """ - parameters = models.Deployment(location=location, properties=properties) + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentValidateResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.Deployment(location=location, properties=properties) + api_version = "2018-05-01" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.validate_at_subscription_scope.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'Deployment') # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 400]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', response) + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', response) + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - validate_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} + validate_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore def export_template_at_subscription_scope( - self, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentExportResult" """Exports the template used for specified deployment. - :param deployment_name: The name of the deployment from which to get - the template. + :param deployment_name: The name of the deployment from which to get the template. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentExportResult or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentExportResult - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentExportResult + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExportResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + # Construct URL - url = self.export_template_at_subscription_scope.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentExportResult', response) + deserialized = self._deserialize('DeploymentExportResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - export_template_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} + export_template_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore def list_at_subscription_scope( - self, filter=None, top=None, custom_headers=None, raw=False, **operation_config): + self, + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.DeploymentListResult"] """Get all the deployments for a subscription. - :param filter: The filter to apply on the operation. For example, you - can use $filter=provisioningState eq '{state}'. + :param filter: The filter to apply on the operation. For example, you can use + $filter=provisioningState eq '{state}'. :type filter: str - :param top: The number of results to get. If null is passed, returns - all deployments. + :param top: The number of results to get. If null is passed, returns all deployments. :type top: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of DeploymentExtended - :rtype: - ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentExtendedPaged[~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentExtended] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_at_subscription_scope.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response - - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.DeploymentExtendedPaged(internal_paging, self._deserialize.dependencies, header_dict) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return deserialized - list_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/'} + return pipeline_response + return ItemPaged( + get_next, extract_data + ) + list_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/'} # type: ignore def _delete_initial( - self, resource_group_name, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + # Construct URL - url = self.delete.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [202, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - - def delete( - self, resource_group_name, deployment_name, custom_headers=None, raw=False, polling=True, **operation_config): - """Deletes a deployment from the deployment history. - - A template deployment that is currently running cannot be deleted. - Deleting a template deployment removes the associated deployment - operations. Deleting a template deployment does not affect the state of - the resource group. This is an asynchronous operation that returns a - status of 202 until the template deployment is successfully deleted. - The Location response header contains the URI that is used to obtain - the status of the process. While the process is running, a call to the - URI in the Location header returns a status of 202. When the process - finishes, the URI in the Location header returns a status of 204 on - success. If the asynchronous request failed, the URI in the Location - header returns an error-level status code. - - :param resource_group_name: The name of the resource group with the - deployment to delete. The name is case insensitive. + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + def begin_delete( + self, + resource_group_name, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """A template deployment that is currently running cannot be deleted. Deleting a template deployment removes the associated deployment operations. Deleting a template deployment does not affect the state of the resource group. This is an asynchronous operation that returns a status of 202 until the template deployment is successfully deleted. The Location response header contains the URI that is used to obtain the status of the process. While the process is running, a call to the URI in the Location header returns a status of 202. When the process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. + + Deletes a deployment from the deployment history. + + :param resource_group_name: The name of the resource group with the deployment to delete. The + name is case insensitive. :type resource_group_name: str :param deployment_name: The name of the deployment to delete. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns None or - ClientRawResponse if raw==True - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._delete_initial( resource_group_name=resource_group_name, deployment_name=deployment_name, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore def check_existence( - self, resource_group_name, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Checks whether the deployment exists. - :param resource_group_name: The name of the resource group with the - deployment to check. The name is case insensitive. + :param resource_group_name: The name of the resource group with the deployment to check. The + name is case insensitive. :type resource_group_name: str :param deployment_name: The name of the deployment to check. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: bool or ClientRawResponse if raw=true - :rtype: bool or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + # Construct URL - url = self.check_existence.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204, 404]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = (response.status_code == 204) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - return deserialized - check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + if cls: + return cls(pipeline_response, None, {}) + + 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, deployment_name, properties, location=None, custom_headers=None, raw=False, **operation_config): - parameters = models.Deployment(location=location, properties=properties) + self, + resource_group_name, # type: str + deployment_name, # type: str + properties, # type: "models.DeploymentProperties" + location=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentExtended" + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.Deployment(location=location, properties=properties) + api_version = "2018-05-01" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.create_or_update.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'Deployment') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 201]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', response) + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', response) + deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - - def create_or_update( - self, resource_group_name, deployment_name, properties, location=None, custom_headers=None, raw=False, polling=True, **operation_config): - """Deploys resources to a resource group. - - You can provide the template and parameters directly in the request or - link to JSON files. - - :param resource_group_name: The name of the resource group to deploy - the resources to. The name is case insensitive. The resource group - must already exist. + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + def begin_create_or_update( + self, + resource_group_name, # type: str + deployment_name, # type: str + properties, # type: "models.DeploymentProperties" + location=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """You can provide the template and parameters directly in the request or link to JSON files. + + Deploys resources to a resource group. + + :param resource_group_name: The name of the resource group to deploy the resources to. The name + is case insensitive. The resource group must already exist. :type resource_group_name: str :param deployment_name: The name of the deployment. :type deployment_name: str :param properties: The deployment properties. - :type properties: - ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentProperties + :type properties: ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentProperties :param location: The location to store the deployment data. :type location: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns DeploymentExtended or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentExtended] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentExtended]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 DeploymentExtended + :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] + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._create_or_update_initial( resource_group_name=resource_group_name, deployment_name=deployment_name, properties=properties, location=location, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - deserialized = self._deserialize('DeploymentExtended', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore def get( - self, resource_group_name, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentExtended" """Gets a deployment. - :param resource_group_name: The name of the resource group. The name - is case insensitive. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param deployment_name: The name of the deployment to get. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentExtended or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentExtended - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExtended or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentExtended + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + # Construct URL - url = self.get.metadata['url'] + url = self.get.metadata['url'] # type: 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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', response) + deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore def cancel( - self, resource_group_name, deployment_name, custom_headers=None, raw=False, **operation_config): - """Cancels a currently running template deployment. + self, + resource_group_name, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """You can cancel a deployment only if the provisioningState is Accepted or Running. After the deployment is canceled, the provisioningState is set to Canceled. Canceling a template deployment stops the currently running template deployment and leaves the resource group partially deployed. - You can cancel a deployment only if the provisioningState is Accepted - or Running. After the deployment is canceled, the provisioningState is - set to Canceled. Canceling a template deployment stops the currently - running template deployment and leaves the resource group partially - deployed. + Cancels a currently running template deployment. - :param resource_group_name: The name of the resource group. The name - is case insensitive. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param deployment_name: The name of the deployment to cancel. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + # Construct URL - url = self.cancel.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - cancel.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} + if cls: + return cls(pipeline_response, None, {}) - def validate( - self, resource_group_name, deployment_name, properties, location=None, custom_headers=None, raw=False, **operation_config): - """Validates whether the specified template is syntactically correct and - will be accepted by Azure Resource Manager.. + cancel.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore - :param resource_group_name: The name of the resource group the - template will be deployed to. The name is case insensitive. + def validate( + self, + resource_group_name, # type: str + deployment_name, # type: str + properties, # type: "models.DeploymentProperties" + location=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentValidateResult" + """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. :type resource_group_name: str :param deployment_name: The name of the deployment. :type deployment_name: str :param properties: The deployment properties. - :type properties: - ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentProperties + :type properties: ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentProperties :param location: The location to store the deployment data. :type location: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentValidateResult or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentValidateResult - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentValidateResult + :raises: ~azure.core.exceptions.HttpResponseError """ - parameters = models.Deployment(location=location, properties=properties) + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentValidateResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.Deployment(location=location, properties=properties) + api_version = "2018-05-01" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.validate.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'Deployment') # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 400]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', response) + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', response) + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - validate.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} + validate.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore def export_template( - self, resource_group_name, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentExportResult" """Exports the template used for specified deployment. - :param resource_group_name: The name of the resource group. The name - is case insensitive. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str - :param deployment_name: The name of the deployment from which to get - the template. + :param deployment_name: The name of the deployment from which to get the template. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentExportResult or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentExportResult - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentExportResult + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExportResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + # Construct URL - url = self.export_template.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentExportResult', response) + deserialized = self._deserialize('DeploymentExportResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} + export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore def list_by_resource_group( - self, resource_group_name, filter=None, top=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.DeploymentListResult"] """Get all the deployments for a resource group. - :param resource_group_name: The name of the resource group with the - deployments to get. The name is case insensitive. + :param resource_group_name: The name of the resource group with the deployments to get. The + name is case insensitive. :type resource_group_name: str - :param filter: The filter to apply on the operation. For example, you - can use $filter=provisioningState eq '{state}'. + :param filter: The filter to apply on the operation. For example, you can use + $filter=provisioningState eq '{state}'. :type filter: str - :param top: The number of results to get. If null is passed, returns - all deployments. + :param top: The number of results to get. If null is passed, returns all deployments. :type top: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of DeploymentExtended - :rtype: - ~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentExtendedPaged[~azure.mgmt.resource.resources.v2018_05_01.models.DeploymentExtended] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_by_resource_group.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.DeploymentExtendedPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/'} + return ItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/'} # type: ignore def calculate_template_hash( - self, template, custom_headers=None, raw=False, **operation_config): + self, + template, # type: object + **kwargs # type: Any + ): + # type: (...) -> "models.TemplateHashResult" """Calculate the hash of the given template. :param template: The template provided to calculate hash. :type template: object - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: TemplateHashResult or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2018_05_01.models.TemplateHashResult - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateHashResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.TemplateHashResult + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TemplateHashResult"] + error_map = {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.calculate_template_hash.metadata['url'] + url = self.calculate_template_hash.metadata['url'] # type: ignore # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(template, 'object') # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('TemplateHashResult', response) + deserialized = self._deserialize('TemplateHashResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - calculate_template_hash.metadata = {'url': '/providers/Microsoft.Resources/calculateTemplateHash'} + 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 8cade6551b72..e554e9be6464 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 @@ -1,102 +1,106 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class Operations(object): """Operations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2018_05_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for this operation. Constant value: "2018-05-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2018-05-01" - - self.config = config + self._config = config def list( - self, custom_headers=None, raw=False, **operation_config): + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.OperationListResult"] """Lists all of the available Microsoft.Resources REST API operations. - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of Operation - :rtype: - ~azure.mgmt.resource.resources.v2018_05_01.models.OperationPaged[~azure.mgmt.resource.resources.v2018_05_01.models.Operation] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of OperationListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['url'] - + url = self.list.metadata['url'] # type: ignore # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('OperationListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.OperationPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list.metadata = {'url': '/providers/Microsoft.Resources/operations'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.Resources/operations'} # type: ignore 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 5e9519eff351..1790edec003e 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 @@ -1,300 +1,287 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class ProvidersOperations(object): """ProvidersOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2018_05_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for this operation. Constant value: "2018-05-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2018-05-01" - - self.config = config + self._config = config def unregister( - self, resource_provider_namespace, custom_headers=None, raw=False, **operation_config): + self, + resource_provider_namespace, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.Provider" """Unregisters a subscription from a resource provider. - :param resource_provider_namespace: The namespace of the resource - provider to unregister. + :param resource_provider_namespace: The namespace of the resource provider to unregister. :type resource_provider_namespace: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: Provider or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.Provider or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Provider or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.Provider + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Provider"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + # Construct URL - url = self.unregister.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('Provider', response) + deserialized = self._deserialize('Provider', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - unregister.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister'} + unregister.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister'} # type: ignore def register( - self, resource_provider_namespace, custom_headers=None, raw=False, **operation_config): + self, + resource_provider_namespace, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.Provider" """Registers a subscription with a resource provider. - :param resource_provider_namespace: The namespace of the resource - provider to register. + :param resource_provider_namespace: The namespace of the resource provider to register. :type resource_provider_namespace: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: Provider or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.Provider or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Provider or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.Provider + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Provider"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + # Construct URL - url = self.register.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('Provider', response) + deserialized = self._deserialize('Provider', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - register.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register'} + register.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register'} # type: ignore def list( - self, top=None, expand=None, custom_headers=None, raw=False, **operation_config): + self, + top=None, # type: Optional[int] + expand=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.ProviderListResult"] """Gets all resource providers for a subscription. - :param top: The number of results to return. If null is passed returns - all deployments. + :param top: The number of results to return. If null is passed returns all deployments. :type top: int - :param expand: The properties to include in the results. For example, - use &$expand=metadata in the query string to retrieve resource - provider metadata. To include property aliases in response, use - $expand=resourceTypes/aliases. + :param expand: The properties to include in the results. For example, use &$expand=metadata in + the query string to retrieve resource provider metadata. To include property aliases in + response, use $expand=resourceTypes/aliases. :type expand: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of Provider - :rtype: - ~azure.mgmt.resource.resources.v2018_05_01.models.ProviderPaged[~azure.mgmt.resource.resources.v2018_05_01.models.Provider] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of ProviderListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['url'] + url = self.list.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_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 = {} + 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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('ProviderListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.ProviderPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers'} # type: ignore def get( - self, resource_provider_namespace, expand=None, custom_headers=None, raw=False, **operation_config): + self, + resource_provider_namespace, # type: str + expand=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.Provider" """Gets the specified resource provider. - :param resource_provider_namespace: The namespace of the resource - provider. + :param resource_provider_namespace: The namespace of the resource provider. :type resource_provider_namespace: str - :param expand: The $expand query parameter. For example, to include - property aliases in response, use $expand=resourceTypes/aliases. + :param expand: The $expand query parameter. For example, to include property aliases in + response, use $expand=resourceTypes/aliases. :type expand: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: Provider or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.Provider or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Provider or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.Provider + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Provider"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + # Construct URL - url = self.get.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('Provider', response) + deserialized = self._deserialize('Provider', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}'} + 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 acd291a21793..b3d338653582 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 @@ -1,530 +1,517 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError -from msrest.polling import LROPoller, NoPolling -from msrestazure.polling.arm_polling import ARMPolling +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, List, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class ResourceGroupsOperations(object): """ResourceGroupsOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2018_05_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for this operation. Constant value: "2018-05-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2018-05-01" - - self.config = config + self._config = config def check_existence( - self, resource_group_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Checks whether a resource group exists. - :param resource_group_name: The name of the resource group to check. - The name is case insensitive. + :param resource_group_name: The name of the resource group to check. The name is case + insensitive. :type resource_group_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: bool or ClientRawResponse if raw=true - :rtype: bool or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + # Construct URL - url = self.check_existence.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204, 404]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = (response.status_code == 204) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - return deserialized - check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore def create_or_update( - self, resource_group_name, parameters, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + parameters, # type: "models.ResourceGroup" + **kwargs # type: Any + ): + # type: (...) -> "models.ResourceGroup" """Creates or updates a resource group. - :param resource_group_name: The name of the resource group to create - or update. Can include alphanumeric, underscore, parentheses, hyphen, - period (except at end), and Unicode characters that match the allowed - characters. + :param resource_group_name: The name of the resource group to create or update. Can include + alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters + that match the allowed characters. :type resource_group_name: str - :param parameters: Parameters supplied to the create or update a - resource group. - :type parameters: - ~azure.mgmt.resource.resources.v2018_05_01.models.ResourceGroup - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: ResourceGroup or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2018_05_01.models.ResourceGroup or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :param parameters: Parameters supplied to the create or update a resource group. + :type parameters: ~azure.mgmt.resource.resources.v2018_05_01.models.ResourceGroup + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.ResourceGroup + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceGroup"] + error_map = {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.create_or_update.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'ResourceGroup') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 201]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ResourceGroup', response) + deserialized = self._deserialize('ResourceGroup', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('ResourceGroup', response) + deserialized = self._deserialize('ResourceGroup', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} - + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore def _delete_initial( - self, resource_group_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + # Construct URL - url = self.delete.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 202]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore - def delete( - self, resource_group_name, custom_headers=None, raw=False, polling=True, **operation_config): - """Deletes a resource group. + def begin_delete( + self, + resource_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """When you delete a resource group, all of its resources are also deleted. Deleting a resource group deletes all of its template deployments and currently stored operations. - When you delete a resource group, all of its resources are also - deleted. Deleting a resource group deletes all of its template - deployments and currently stored operations. + Deletes a resource group. - :param resource_group_name: The name of the resource group to delete. - The name is case insensitive. + :param resource_group_name: The name of the resource group to delete. The name is case + insensitive. :type resource_group_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns None or - ClientRawResponse if raw==True - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._delete_initial( resource_group_name=resource_group_name, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore def get( - self, resource_group_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.ResourceGroup" """Gets a resource group. - :param resource_group_name: The name of the resource group to get. The - name is case insensitive. + :param resource_group_name: The name of the resource group to get. The name is case + insensitive. :type resource_group_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: ResourceGroup or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2018_05_01.models.ResourceGroup or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.ResourceGroup + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceGroup"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + # Construct URL - url = self.get.metadata['url'] + url = self.get.metadata['url'] # type: 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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('ResourceGroup', response) + deserialized = self._deserialize('ResourceGroup', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore def update( - self, resource_group_name, parameters, custom_headers=None, raw=False, **operation_config): - """Updates a resource group. - - Resource groups can be updated through a simple PATCH operation to a - group address. The format of the request is the same as that for - creating a resource group. If a field is unspecified, the current value - is retained. - - :param resource_group_name: The name of the resource group to update. - The name is case insensitive. + self, + resource_group_name, # type: str + parameters, # type: "models.ResourceGroupPatchable" + **kwargs # type: Any + ): + # type: (...) -> "models.ResourceGroup" + """Resource groups can be updated through a simple PATCH operation to a group address. The format of the request is the same as that for creating a resource group. If a field is unspecified, the current value is retained. + + Updates a resource group. + + :param resource_group_name: The name of the resource group to update. The name is case + insensitive. :type resource_group_name: str :param parameters: Parameters supplied to update a resource group. - :type parameters: - ~azure.mgmt.resource.resources.v2018_05_01.models.ResourceGroupPatchable - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: ResourceGroup or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2018_05_01.models.ResourceGroup or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :type parameters: ~azure.mgmt.resource.resources.v2018_05_01.models.ResourceGroupPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.ResourceGroup + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceGroup"] + error_map = {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.update.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'ResourceGroupPatchable') # Construct and send request - request = self._client.patch(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('ResourceGroup', response) + deserialized = self._deserialize('ResourceGroup', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore def export_template( - self, resource_group_name, resources=None, options=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + resources=None, # type: Optional[List[str]] + options=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.ResourceGroupExportResult" """Captures the specified resource group as a template. - :param resource_group_name: The name of the resource group to export - as a template. + :param resource_group_name: The name of the resource group to export as a template. :type resource_group_name: str - :param resources: The IDs of the resources to filter the export by. To - export all resources, supply an array with single entry '*'. + :param 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', - 'SkipResourceNameParameterization', 'SkipAllParameterization' + :param options: The export template options. A CSV-formatted list containing zero or more of + the following: 'IncludeParameterDefaultValue', 'IncludeComments', + 'SkipResourceNameParameterization', 'SkipAllParameterization'. :type options: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: ResourceGroupExportResult or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2018_05_01.models.ResourceGroupExportResult - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroupExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.ResourceGroupExportResult + :raises: ~azure.core.exceptions.HttpResponseError """ - parameters = models.ExportTemplateRequest(resources=resources, options=options) + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceGroupExportResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.ExportTemplateRequest(resources=resources, options=options) + api_version = "2018-05-01" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.export_template.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'ExportTemplateRequest') # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('ResourceGroupExportResult', response) + deserialized = self._deserialize('ResourceGroupExportResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate'} + export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate'} # type: ignore def list( - self, filter=None, top=None, custom_headers=None, raw=False, **operation_config): + self, + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.ResourceGroupListResult"] """Gets all the resource groups for a subscription. - :param filter: The filter to apply on the operation.

You can - filter by tag names and values. For example, to filter for a tag name - and value, use $filter=tagName eq 'tag1' and tagValue eq 'Value1' + :param filter: The filter to apply on the operation.:code:`
`:code:`
`You can filter by + tag names and values. For example, to filter for a tag name and value, use $filter=tagName eq + 'tag1' and tagValue eq 'Value1'. :type filter: str - :param top: The number of results to return. If null is passed, - returns all resource groups. + :param top: The number of results to return. If null is passed, returns all resource groups. :type top: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of ResourceGroup - :rtype: - ~azure.mgmt.resource.resources.v2018_05_01.models.ResourceGroupPaged[~azure.mgmt.resource.resources.v2018_05_01.models.ResourceGroup] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['url'] + url = self.list.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_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 = {} + 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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('ResourceGroupListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.ResourceGroupPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups'} # type: ignore 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 edd55c270374..fed834e5a06c 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 @@ -1,558 +1,577 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError -from msrest.polling import LROPoller, NoPolling -from msrestazure.polling.arm_polling import ARMPolling +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, List, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class ResourcesOperations(object): """ResourcesOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2018_05_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for this operation. Constant value: "2018-05-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2018-05-01" - - self.config = config + self._config = config def list_by_resource_group( - self, resource_group_name, filter=None, expand=None, top=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + filter=None, # type: Optional[str] + expand=None, # type: Optional[str] + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.ResourceListResult"] """Get all the resources for a resource group. - :param resource_group_name: The resource group with the resources to - get. + :param resource_group_name: The resource group with the resources to get. :type resource_group_name: str - :param filter: The filter to apply on the operation.

The - properties you can use for eq (equals) or ne (not equals) are: - location, resourceType, name, resourceGroup, identity, - identity/principalId, plan, plan/publisher, plan/product, plan/name, - plan/version, and plan/promotionCode.

For example, to filter by - a resource type, use: $filter=resourceType eq - 'Microsoft.Network/virtualNetworks'

You can use - substringof(value, property) in the filter. The properties you can use - for substring are: name and resourceGroup.

For example, to get - all resources with 'demo' anywhere in the name, use: - $filter=substringof('demo', name)

You can link more than one - substringof together by adding and/or operators.

You can filter - by tag names and values. For example, to filter for a tag name and - value, use $filter=tagName eq 'tag1' and tagValue eq - 'Value1'

You can use some properties together when filtering. - The combinations you can use are: substringof and/or resourceType, - plan and plan/publisher and plan/name, identity and - identity/principalId. + :param filter: The filter to apply on the operation.:code:`
`:code:`
`The properties you + can use for eq (equals) or ne (not equals) are: location, resourceType, name, resourceGroup, + identity, identity/principalId, plan, plan/publisher, plan/product, plan/name, plan/version, + and plan/promotionCode.:code:`
`:code:`
`For example, to filter by a resource type, use: + $filter=resourceType eq 'Microsoft.Network/virtualNetworks':code:`
`:code:`
`You can use + substringof(value, property) in the filter. The properties you can use for substring are: name + and resourceGroup.:code:`
`:code:`
`For example, to get all resources with 'demo' + anywhere in the name, use: $filter=substringof('demo', name):code:`
`:code:`
`You can + link more than one substringof together by adding and/or operators.:code:`
`:code:`
`You + can filter by tag names and values. For example, to filter for a tag name and value, use + $filter=tagName eq 'tag1' and tagValue eq 'Value1':code:`
`:code:`
`You can use some + properties together when filtering. The combinations you can use are: substringof and/or + resourceType, plan and plan/publisher and plan/name, identity and identity/principalId. :type filter: str - :param expand: Comma-separated list of additional properties to be - included in the response. Valid values include `createdTime`, - `changedTime` and `provisioningState`. For example, - `$expand=createdTime,changedTime`. + :param expand: Comma-separated list of additional properties to be included in the response. + Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, + ``$expand=createdTime,changedTime``. :type expand: str - :param top: The 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 - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of GenericResourceExpanded - :rtype: - ~azure.mgmt.resource.resources.v2018_05_01.models.GenericResourceExpandedPaged[~azure.mgmt.resource.resources.v2018_05_01.models.GenericResourceExpanded] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of ResourceListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_by_resource_group.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('ResourceListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response - - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.GenericResourceExpandedPaged(internal_paging, self._deserialize.dependencies, header_dict) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return deserialized - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources'} + return pipeline_response + return ItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources'} # type: ignore def _move_resources_initial( - self, source_resource_group_name, resources=None, target_resource_group=None, custom_headers=None, raw=False, **operation_config): - parameters = models.ResourcesMoveInfo(resources=resources, target_resource_group=target_resource_group) + self, + source_resource_group_name, # type: str + resources=None, # type: Optional[List[str]] + target_resource_group=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.ResourcesMoveInfo(resources=resources, target_resource_group=target_resource_group) + api_version = "2018-05-01" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.move_resources.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'ResourcesMoveInfo') + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [202, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - - def move_resources( - self, source_resource_group_name, resources=None, target_resource_group=None, custom_headers=None, raw=False, polling=True, **operation_config): - """Moves resources from one resource group to another resource group. - - The resources to move must be in the same source resource group. The - target resource group may be in a different subscription. When moving - resources, both the source group and the target group are locked for - the duration of the operation. Write and delete operations are blocked - on the groups until the move completes. . - - :param source_resource_group_name: The name of the resource group - containing the resources to move. + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore + + def begin_move_resources( + self, + source_resource_group_name, # type: str + resources=None, # type: Optional[List[str]] + target_resource_group=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """The resources to move must be in the same source resource group. The target resource group may be in a different subscription. When moving resources, both the source group and the target group are locked for the duration of the operation. Write and delete operations are blocked on the groups until the move completes. + + Moves resources from one resource group to another resource group. + + :param source_resource_group_name: The name of the resource group containing the resources to + move. :type source_resource_group_name: str :param resources: The IDs of the resources. :type resources: list[str] :param target_resource_group: The target resource group. :type target_resource_group: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns None or - ClientRawResponse if raw==True - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._move_resources_initial( source_resource_group_name=source_resource_group_name, resources=resources, target_resource_group=target_resource_group, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} - + begin_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore def _validate_move_resources_initial( - self, source_resource_group_name, resources=None, target_resource_group=None, custom_headers=None, raw=False, **operation_config): - parameters = models.ResourcesMoveInfo(resources=resources, target_resource_group=target_resource_group) + self, + source_resource_group_name, # type: str + resources=None, # type: Optional[List[str]] + target_resource_group=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.ResourcesMoveInfo(resources=resources, target_resource_group=target_resource_group) + api_version = "2018-05-01" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.validate_move_resources.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'ResourcesMoveInfo') + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [202, 204, 409]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - - def validate_move_resources( - self, source_resource_group_name, resources=None, target_resource_group=None, custom_headers=None, raw=False, polling=True, **operation_config): - """Validates whether resources can be moved from one resource group to - another resource group. - - This operation checks whether the specified resources can be moved to - the target. The resources to move must be in the same source resource - group. The target resource group may be in a different subscription. If - validation succeeds, it returns HTTP response code 204 (no content). If - validation fails, it returns HTTP response code 409 (Conflict) with an - error message. Retrieve the URL in the Location header value to check - the result of the long-running operation. - - :param source_resource_group_name: The name of the resource group - containing the resources to validate for move. + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _validate_move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} # type: ignore + + def begin_validate_move_resources( + self, + source_resource_group_name, # type: str + resources=None, # type: Optional[List[str]] + target_resource_group=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """This operation checks whether the specified resources can be moved to the target. The resources to move must be in the same source resource group. The target resource group may be in a different subscription. If validation succeeds, it returns HTTP response code 204 (no content). If validation fails, it returns HTTP response code 409 (Conflict) with an error message. Retrieve the URL in the Location header value to check the result of the long-running operation. + + Validates whether resources can be moved from one resource group to another resource group. + + :param source_resource_group_name: The name of the resource group containing the resources to + validate for move. :type source_resource_group_name: str :param resources: The IDs of the resources. :type resources: list[str] :param target_resource_group: The target resource group. :type target_resource_group: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns None or - ClientRawResponse if raw==True - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._validate_move_resources_initial( source_resource_group_name=source_resource_group_name, resources=resources, target_resource_group=target_resource_group, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - validate_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} + begin_validate_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} # type: ignore def list( - self, filter=None, expand=None, top=None, custom_headers=None, raw=False, **operation_config): + self, + filter=None, # type: Optional[str] + expand=None, # type: Optional[str] + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.ResourceListResult"] """Get all the resources in a subscription. - :param filter: The filter to apply on the operation.

The - properties you can use for eq (equals) or ne (not equals) are: - location, resourceType, name, resourceGroup, identity, - identity/principalId, plan, plan/publisher, plan/product, plan/name, - plan/version, and plan/promotionCode.

For example, to filter by - a resource type, use: $filter=resourceType eq - 'Microsoft.Network/virtualNetworks'

You can use - substringof(value, property) in the filter. The properties you can use - for substring are: name and resourceGroup.

For example, to get - all resources with 'demo' anywhere in the name, use: - $filter=substringof('demo', name)

You can link more than one - substringof together by adding and/or operators.

You can filter - by tag names and values. For example, to filter for a tag name and - value, use $filter=tagName eq 'tag1' and tagValue eq - 'Value1'

You can use some properties together when filtering. - The combinations you can use are: substringof and/or resourceType, - plan and plan/publisher and plan/name, identity and - identity/principalId. + :param filter: The filter to apply on the operation.:code:`
`:code:`
`The properties you + can use for eq (equals) or ne (not equals) are: location, resourceType, name, resourceGroup, + identity, identity/principalId, plan, plan/publisher, plan/product, plan/name, plan/version, + and plan/promotionCode.:code:`
`:code:`
`For example, to filter by a resource type, use: + $filter=resourceType eq 'Microsoft.Network/virtualNetworks':code:`
`:code:`
`You can use + substringof(value, property) in the filter. The properties you can use for substring are: name + and resourceGroup.:code:`
`:code:`
`For example, to get all resources with 'demo' + anywhere in the name, use: $filter=substringof('demo', name):code:`
`:code:`
`You can + link more than one substringof together by adding and/or operators.:code:`
`:code:`
`You + can filter by tag names and values. For example, to filter for a tag name and value, use + $filter=tagName eq 'tag1' and tagValue eq 'Value1':code:`
`:code:`
`You can use some + properties together when filtering. The combinations you can use are: substringof and/or + resourceType, plan and plan/publisher and plan/name, identity and identity/principalId. :type filter: str - :param expand: Comma-separated list of additional properties to be - included in the response. Valid values include `createdTime`, - `changedTime` and `provisioningState`. For example, - `$expand=createdTime,changedTime`. + :param expand: Comma-separated list of additional properties to be included in the response. + Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, + ``$expand=createdTime,changedTime``. :type expand: str - :param top: The number of results to return. If null is passed, - returns all resource groups. + :param top: The number of results to return. If null is passed, returns all resource groups. :type top: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of GenericResourceExpanded - :rtype: - ~azure.mgmt.resource.resources.v2018_05_01.models.GenericResourceExpandedPaged[~azure.mgmt.resource.resources.v2018_05_01.models.GenericResourceExpanded] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of ResourceListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['url'] + url = self.list.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_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 = {} + 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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('ResourceListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.GenericResourceExpandedPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resources'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resources'} # type: ignore def check_existence( - self, resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, api_version, custom_headers=None, raw=False, **operation_config): + self, + 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: (...) -> None """Checks whether a resource exists. - :param resource_group_name: The name of the resource group containing - the resource to check. The name is case insensitive. + :param resource_group_name: The name of the resource group containing the resource to check. + The name is case insensitive. :type resource_group_name: str - :param resource_provider_namespace: The resource provider of the - resource to check. + :param resource_provider_namespace: The resource provider of the resource to check. :type resource_provider_namespace: str :param parent_resource_path: The parent resource identity. :type parent_resource_path: str :param resource_type: The resource type. :type resource_type: str - :param resource_name: The name of the resource to check whether it - exists. + :param resource_name: The name of the resource to check whether it exists. :type resource_name: str - :param api_version: The API version to use for the operation. - :type api_version: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: bool or ClientRawResponse if raw=true - :rtype: bool or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + # Construct URL - url = self.check_existence.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204, 404]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = (response.status_code == 204) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - return deserialized - check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + 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, resource_provider_namespace, parent_resource_path, resource_type, resource_name, api_version, custom_headers=None, raw=False, **operation_config): + self, + 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: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + # Construct URL - url = self.delete.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - - def delete( - self, resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, api_version, custom_headers=None, raw=False, polling=True, **operation_config): + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + def begin_delete( + self, + 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: (...) -> LROPoller """Deletes a resource. - :param resource_group_name: The name of the resource group that - contains the resource to delete. The name is case insensitive. + :param resource_group_name: The name of the resource group that contains the resource to + delete. The name is case insensitive. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource - provider. + :param resource_provider_namespace: The namespace of the resource provider. :type resource_provider_namespace: str :param parent_resource_path: The parent resource identity. :type parent_resource_path: str @@ -560,109 +579,122 @@ def delete( :type resource_type: str :param resource_name: The name of the resource to delete. :type resource_name: str - :param api_version: The API version to use for the operation. - :type api_version: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns None or - ClientRawResponse if raw==True - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._delete_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, - api_version=api_version, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} - + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore def _create_or_update_initial( - self, resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, api_version, parameters, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + parameters, # type: "models.GenericResource" + **kwargs # type: Any + ): + # type: (...) -> "models.GenericResource" + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {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.create_or_update.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'GenericResource') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 201, 202]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('GenericResource', response) + deserialized = self._deserialize('GenericResource', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('GenericResource', response) + deserialized = self._deserialize('GenericResource', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - - def create_or_update( - self, resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, api_version, parameters, custom_headers=None, raw=False, polling=True, **operation_config): + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + def begin_create_or_update( + self, + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + parameters, # type: "models.GenericResource" + **kwargs # type: Any + ): + # type: (...) -> LROPoller """Creates a resource. - :param resource_group_name: The name of the resource group for the - resource. The name is case insensitive. + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource - provider. + :param resource_provider_namespace: The namespace of the resource provider. :type resource_provider_namespace: str :param parent_resource_path: The parent resource identity. :type parent_resource_path: str @@ -670,117 +702,125 @@ def create_or_update( :type resource_type: str :param resource_name: The name of the resource to create. :type resource_name: str - :param api_version: The API version to use for the operation. - :type api_version: str :param parameters: Parameters for creating or updating the resource. - :type parameters: - ~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :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 polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns GenericResource or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 GenericResource + :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] + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._create_or_update_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, - api_version=api_version, parameters=parameters, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - deserialized = self._deserialize('GenericResource', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('GenericResource', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} - + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore def _update_initial( - self, resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, api_version, parameters, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + parameters, # type: "models.GenericResource" + **kwargs # type: Any + ): + # type: (...) -> "models.GenericResource" + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {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.update.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'GenericResource') # Construct and send request - request = self._client.patch(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 202]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('GenericResource', response) + deserialized = self._deserialize('GenericResource', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - - def update( - self, resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, api_version, parameters, custom_headers=None, raw=False, polling=True, **operation_config): + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + def begin_update( + self, + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + parameters, # type: "models.GenericResource" + **kwargs # type: Any + ): + # type: (...) -> LROPoller """Updates a resource. - :param resource_group_name: The name of the resource group for the - resource. The name is case insensitive. + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource - provider. + :param resource_provider_namespace: The namespace of the resource provider. :type resource_provider_namespace: str :param parent_resource_path: The parent resource identity. :type parent_resource_path: str @@ -788,64 +828,63 @@ def update( :type resource_type: str :param resource_name: The name of the resource to update. :type resource_name: str - :param api_version: The API version to use for the operation. - :type api_version: str :param parameters: Parameters for updating the resource. - :type parameters: - ~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :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 polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns GenericResource or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 GenericResource + :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] + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._update_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, - api_version=api_version, parameters=parameters, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - deserialized = self._deserialize('GenericResource', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('GenericResource', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore def get( - self, resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, api_version, custom_headers=None, raw=False, **operation_config): + self, + 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: (...) -> "models.GenericResource" """Gets a resource. - :param resource_group_name: The name of the resource group containing - the resource to get. The name is case insensitive. + :param resource_group_name: The name of the resource group containing the resource to get. The + name is case insensitive. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource - provider. + :param resource_provider_namespace: The namespace of the resource provider. :type resource_provider_namespace: str :param parent_resource_path: The parent resource identity. :type parent_resource_path: str @@ -853,461 +892,443 @@ def get( :type resource_type: str :param resource_name: The name of the resource to get. :type resource_name: str - :param api_version: The API version to use for the operation. - :type api_version: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: GenericResource or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GenericResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + # Construct URL - url = self.get.metadata['url'] + url = self.get.metadata['url'] # type: 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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('GenericResource', response) + deserialized = self._deserialize('GenericResource', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore def check_existence_by_id( - self, resource_id, api_version, custom_headers=None, raw=False, **operation_config): + self, + resource_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Checks by ID whether a resource exists. - :param resource_id: The fully qualified ID of the resource, including - the resource name and resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. :type resource_id: str - :param api_version: The API version to use for the operation. - :type api_version: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: bool or ClientRawResponse if raw=true - :rtype: bool or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + # Construct URL - url = self.check_existence_by_id.metadata['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) + '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 = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204, 404]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = (response.status_code == 204) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - return deserialized - check_existence_by_id.metadata = {'url': '/{resourceId}'} + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + return 200 <= response.status_code <= 299 + check_existence_by_id.metadata = {'url': '/{resourceId}'} # type: ignore def _delete_by_id_initial( - self, resource_id, api_version, custom_headers=None, raw=False, **operation_config): + self, + resource_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + # Construct URL - url = self.delete_by_id.metadata['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) + '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 = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + _delete_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore - def delete_by_id( - self, resource_id, api_version, custom_headers=None, raw=False, polling=True, **operation_config): + def begin_delete_by_id( + self, + resource_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> LROPoller """Deletes a resource by ID. - :param resource_id: The fully qualified ID of the resource, including - the resource name and resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. :type resource_id: str - :param api_version: The API version to use for the operation. - :type api_version: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns None or - ClientRawResponse if raw==True - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._delete_by_id_initial( resource_id=resource_id, - api_version=api_version, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - delete_by_id.metadata = {'url': '/{resourceId}'} - + begin_delete_by_id.metadata = {'url': '/{resourceId}'} # type: ignore def _create_or_update_by_id_initial( - self, resource_id, api_version, parameters, custom_headers=None, raw=False, **operation_config): + self, + resource_id, # type: str + parameters, # type: "models.GenericResource" + **kwargs # type: Any + ): + # type: (...) -> "models.GenericResource" + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {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.create_or_update_by_id.metadata['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) + '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 = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'GenericResource') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 201, 202]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('GenericResource', response) + deserialized = self._deserialize('GenericResource', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('GenericResource', response) + deserialized = self._deserialize('GenericResource', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - - def create_or_update_by_id( - self, resource_id, api_version, parameters, custom_headers=None, raw=False, polling=True, **operation_config): + _create_or_update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + def begin_create_or_update_by_id( + self, + resource_id, # type: str + parameters, # type: "models.GenericResource" + **kwargs # type: Any + ): + # type: (...) -> LROPoller """Create a resource by ID. - :param resource_id: The fully qualified ID of the resource, including - the resource name and resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. :type resource_id: str - :param api_version: The API version to use for the operation. - :type api_version: str :param parameters: Create or update resource parameters. - :type parameters: - ~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :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 polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns GenericResource or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 GenericResource + :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] + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._create_or_update_by_id_initial( resource_id=resource_id, - api_version=api_version, parameters=parameters, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - deserialized = self._deserialize('GenericResource', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('GenericResource', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - create_or_update_by_id.metadata = {'url': '/{resourceId}'} - + begin_create_or_update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore def _update_by_id_initial( - self, resource_id, api_version, parameters, custom_headers=None, raw=False, **operation_config): + self, + resource_id, # type: str + parameters, # type: "models.GenericResource" + **kwargs # type: Any + ): + # type: (...) -> "models.GenericResource" + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {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.update_by_id.metadata['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) + '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 = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'GenericResource') # Construct and send request - request = self._client.patch(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 202]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('GenericResource', response) + deserialized = self._deserialize('GenericResource', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - - def update_by_id( - self, resource_id, api_version, parameters, custom_headers=None, raw=False, polling=True, **operation_config): + _update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + def begin_update_by_id( + self, + resource_id, # type: str + parameters, # type: "models.GenericResource" + **kwargs # type: Any + ): + # type: (...) -> LROPoller """Updates a resource by ID. - :param resource_id: The fully qualified ID of the resource, including - the resource name and resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. :type resource_id: str - :param api_version: The API version to use for the operation. - :type api_version: str :param parameters: Update resource parameters. - :type parameters: - ~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :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 polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns GenericResource or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 GenericResource + :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] + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._update_by_id_initial( resource_id=resource_id, - api_version=api_version, parameters=parameters, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - deserialized = self._deserialize('GenericResource', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('GenericResource', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - update_by_id.metadata = {'url': '/{resourceId}'} + begin_update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore def get_by_id( - self, resource_id, api_version, custom_headers=None, raw=False, **operation_config): + self, + resource_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.GenericResource" """Gets a resource by ID. - :param resource_id: The fully qualified ID of the resource, including - the resource name and resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. :type resource_id: str - :param api_version: The API version to use for the operation. - :type api_version: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: GenericResource or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GenericResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.GenericResource + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + # Construct URL - url = self.get_by_id.metadata['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) + '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 = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('GenericResource', response) + deserialized = self._deserialize('GenericResource', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/{resourceId}'} + 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 3dc2b1b0b9d6..cb517d0f5616 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 @@ -1,340 +1,336 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class TagsOperations(object): """TagsOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2018_05_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for this operation. Constant value: "2018-05-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2018-05-01" - - self.config = config + self._config = config def delete_value( - self, tag_name, tag_value, custom_headers=None, raw=False, **operation_config): + self, + tag_name, # type: str + tag_value, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Deletes a tag value. :param tag_name: The name of the tag. :type tag_name: str :param tag_value: The value of the tag to delete. :type tag_value: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + # Construct URL - url = self.delete_value.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} + delete_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore def create_or_update_value( - self, tag_name, tag_value, custom_headers=None, raw=False, **operation_config): + self, + tag_name, # type: str + tag_value, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.TagValue" """Creates a tag value. The name of the tag must already exist. :param tag_name: The name of the tag. :type tag_name: str :param tag_value: The value of the tag to create. :type tag_value: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: TagValue or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.TagValue or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagValue or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.TagValue + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TagValue"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + # Construct URL - url = self.create_or_update_value.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.put(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 201]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('TagValue', response) + deserialized = self._deserialize('TagValue', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('TagValue', response) + deserialized = self._deserialize('TagValue', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} + create_or_update_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore def create_or_update( - self, tag_name, custom_headers=None, raw=False, **operation_config): - """Creates a tag in the subscription. + self, + tag_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.TagDetails" + """The tag name can have a maximum of 512 characters and is case insensitive. Tag names created by Azure have prefixes of microsoft, azure, or windows. You cannot create tags with one of these prefixes. - The tag name can have a maximum of 512 characters and is case - insensitive. Tag names created by Azure have prefixes of microsoft, - azure, or windows. You cannot create tags with one of these prefixes. + Creates a tag in the subscription. :param tag_name: The name of the tag to create. :type tag_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: TagDetails or ClientRawResponse if raw=true + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagDetails or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2018_05_01.models.TagDetails - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TagDetails"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + # Construct URL - url = self.create_or_update.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.put(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 201]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('TagDetails', response) + deserialized = self._deserialize('TagDetails', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('TagDetails', response) + deserialized = self._deserialize('TagDetails', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore def delete( - self, tag_name, custom_headers=None, raw=False, **operation_config): - """Deletes a tag from the subscription. + self, + tag_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """You must remove all values from a resource tag before you can delete it. - You must remove all values from a resource tag before you can delete - it. + Deletes a tag from the subscription. :param tag_name: The name of the tag. :type tag_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + # Construct URL - url = self.delete.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} + delete.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore def list( - self, custom_headers=None, raw=False, **operation_config): - """Gets the names and values of all resource tags that are defined in a - subscription. - - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of TagDetails - :rtype: - ~azure.mgmt.resource.resources.v2018_05_01.models.TagDetailsPaged[~azure.mgmt.resource.resources.v2018_05_01.models.TagDetails] - :raises: :class:`CloudError` + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.TagsListResult"] + """Gets the names and values of all resource tags that are defined in a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of TagsListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['url'] + url = self.list.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('TagsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.TagDetailsPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/py.typed b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file 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 deleted file mode 100644 index 5bfc801ce220..000000000000 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2018_05_01/version.py +++ /dev/null @@ -1,13 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -VERSION = "2018-05-01" - 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 68bc897193ac..fde2ed4c3b83 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 @@ -1,19 +1,16 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._configuration import ResourceManagementClientConfiguration from ._resource_management_client import ResourceManagementClient -__all__ = ['ResourceManagementClient', 'ResourceManagementClientConfiguration'] - -from .version import VERSION - -__version__ = VERSION +__all__ = ['ResourceManagementClient'] +try: + from ._patch import patch_sdk + patch_sdk() +except ImportError: + pass 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 3b326f792363..fd5a3f5b14ae 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 @@ -1,48 +1,69 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrestazure import AzureConfiguration -from .version import VERSION +from typing import TYPE_CHECKING +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + + from azure.core.credentials import TokenCredential + +VERSION = "unknown" + +class ResourceManagementClientConfiguration(Configuration): + """Configuration for ResourceManagementClient. -class ResourceManagementClientConfiguration(AzureConfiguration): - """Configuration for ResourceManagementClient Note that all parameters used to create this instance are saved as instance attributes. - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` + :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 """ def __init__( - self, credentials, subscription_id, base_url=None): - - if credentials is None: - raise ValueError("Parameter 'credentials' must not be None.") + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + 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.") - if not base_url: - base_url = 'https://management.azure.com' + super(ResourceManagementClientConfiguration, self).__init__(**kwargs) - super(ResourceManagementClientConfiguration, self).__init__(base_url) - - # Starting Autorest.Python 4.0.64, make connection pool activated by default - self.keep_alive = True - - self.add_user_agent('azure-mgmt-resource/{}'.format(VERSION)) - self.add_user_agent('Azure-SDK-For-Python') - - self.credentials = credentials + self.credential = credential self.subscription_id = subscription_id + self.api_version = "2019-05-01" + self.credential_scopes = ['https://management.azure.com/.default'] + self.credential_scopes.extend(kwargs.pop('credential_scopes', [])) + kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + 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) 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 new file mode 100644 index 000000000000..0ae1c1322a4f --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/_metadata.json @@ -0,0 +1,59 @@ +{ + "chosen_version": "2019-05-01", + "total_api_version_list": ["2019-05-01"], + "client": { + "name": "ResourceManagementClient", + "filename": "_resource_management_client", + "description": "Provides operations for working with resources and resource groups." + }, + "global_parameters": { + "sync_method": { + "credential": { + "method_signature": "credential, # type: \"TokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials.TokenCredential", + "required": true + }, + "subscription_id": { + "method_signature": "subscription_id, # type: str", + "description": "The ID of the target subscription.", + "docstring_type": "str", + "required": true + } + }, + "async_method": { + "credential": { + "method_signature": "credential, # type: \"AsyncTokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + }, + "subscription_id": { + "method_signature": "subscription_id, # type: str", + "description": "The ID of the target subscription.", + "docstring_type": "str", + "required": true + } + }, + "constant": { + }, + "call": "credential, subscription_id" + }, + "config": { + "credential": true, + "credential_scopes": ["https://management.azure.com/.default"] + }, + "operation_groups": { + "operations": "Operations", + "deployments": "DeploymentsOperations", + "providers": "ProvidersOperations", + "resources": "ResourcesOperations", + "resource_groups": "ResourceGroupsOperations", + "tags": "TagsOperations", + "deployment_operations": "DeploymentOperationsOperations" + }, + "operation_mixins": { + }, + "sync_imports": "None", + "async_imports": "None" +} \ 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 17733bac95da..84a3752dd4c4 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 @@ -1,16 +1,19 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.service_client import SDKClient -from msrest import Serializer, Deserializer +from typing import TYPE_CHECKING + +from azure.mgmt.core import ARMPipelineClient +from msrest import Deserializer, Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional from ._configuration import ResourceManagementClientConfiguration from .operations import Operations @@ -19,61 +22,76 @@ from .operations import ResourcesOperations from .operations import ResourceGroupsOperations from .operations import TagsOperations -from .operations import DeploymentOperations +from .operations import DeploymentOperationsOperations from . import models -class ResourceManagementClient(SDKClient): +class ResourceManagementClient(object): """Provides operations for working with resources and resource groups. - :ivar config: Configuration for client. - :vartype config: ResourceManagementClientConfiguration - :ivar operations: Operations operations :vartype operations: azure.mgmt.resource.resources.v2019_05_01.operations.Operations - :ivar deployments: Deployments operations + :ivar deployments: DeploymentsOperations operations :vartype deployments: azure.mgmt.resource.resources.v2019_05_01.operations.DeploymentsOperations - :ivar providers: Providers operations + :ivar providers: ProvidersOperations operations :vartype providers: azure.mgmt.resource.resources.v2019_05_01.operations.ProvidersOperations - :ivar resources: Resources operations + :ivar resources: ResourcesOperations operations :vartype resources: azure.mgmt.resource.resources.v2019_05_01.operations.ResourcesOperations - :ivar resource_groups: ResourceGroups operations + :ivar resource_groups: ResourceGroupsOperations operations :vartype resource_groups: azure.mgmt.resource.resources.v2019_05_01.operations.ResourceGroupsOperations - :ivar tags: Tags operations + :ivar tags: TagsOperations operations :vartype tags: azure.mgmt.resource.resources.v2019_05_01.operations.TagsOperations - :ivar deployment_operations: DeploymentOperations operations - :vartype deployment_operations: azure.mgmt.resource.resources.v2019_05_01.operations.DeploymentOperations - - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` + :ivar deployment_operations: DeploymentOperationsOperations operations + :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. """ def __init__( - self, credentials, subscription_id, base_url=None): - - self.config = ResourceManagementClientConfiguration(credentials, subscription_id, base_url) - super(ResourceManagementClient, self).__init__(self.config.credentials, self.config) + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = 'https://management.azure.com' + self._config = ResourceManagementClientConfiguration(credential, 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.api_version = '2019-05-01' self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self.operations = Operations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.deployments = DeploymentsOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.providers = ProvidersOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.resources = ResourcesOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.resource_groups = ResourceGroupsOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.tags = TagsOperations( - self._client, self.config, self._serialize, self._deserialize) - self.deployment_operations = DeploymentOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) + self.deployment_operations = DeploymentOperationsOperations( + self._client, self._config, self._serialize, self._deserialize) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> ResourceManagementClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) 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 new file mode 100644 index 000000000000..7f9b1bac71c5 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/__init__.py @@ -0,0 +1,10 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._resource_management_client_async import ResourceManagementClient +__all__ = ['ResourceManagementClient'] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/_configuration_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/_configuration_async.py new file mode 100644 index 000000000000..9c862bc95a5e --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/_configuration_async.py @@ -0,0 +1,65 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + +VERSION = "unknown" + +class ResourceManagementClientConfiguration(Configuration): + """Configuration for ResourceManagementClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :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 + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + 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 + self.api_version = "2019-05-01" + self.credential_scopes = ['https://management.azure.com/.default'] + self.credential_scopes.extend(kwargs.pop('credential_scopes', [])) + kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs: Any + ) -> None: + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + 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) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/_resource_management_client_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/_resource_management_client_async.py new file mode 100644 index 000000000000..69a3d42611aa --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/_resource_management_client_async.py @@ -0,0 +1,89 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, Optional + +from azure.mgmt.core import AsyncARMPipelineClient +from msrest import Deserializer, Serializer + +from ._configuration_async import ResourceManagementClientConfiguration +from .operations_async import Operations +from .operations_async import DeploymentsOperations +from .operations_async import ProvidersOperations +from .operations_async import ResourcesOperations +from .operations_async import ResourceGroupsOperations +from .operations_async import TagsOperations +from .operations_async import DeploymentOperationsOperations +from .. import models + + +class ResourceManagementClient(object): + """Provides operations for working with resources and resource groups. + + :ivar operations: Operations operations + :vartype operations: azure.mgmt.resource.resources.v2019_05_01.aio.operations_async.Operations + :ivar deployments: DeploymentsOperations operations + :vartype deployments: azure.mgmt.resource.resources.v2019_05_01.aio.operations_async.DeploymentsOperations + :ivar providers: ProvidersOperations operations + :vartype providers: azure.mgmt.resource.resources.v2019_05_01.aio.operations_async.ProvidersOperations + :ivar resources: ResourcesOperations operations + :vartype resources: azure.mgmt.resource.resources.v2019_05_01.aio.operations_async.ResourcesOperations + :ivar resource_groups: ResourceGroupsOperations operations + :vartype resource_groups: azure.mgmt.resource.resources.v2019_05_01.aio.operations_async.ResourceGroupsOperations + :ivar tags: TagsOperations operations + :vartype tags: azure.mgmt.resource.resources.v2019_05_01.aio.operations_async.TagsOperations + :ivar deployment_operations: DeploymentOperationsOperations operations + :vartype deployment_operations: azure.mgmt.resource.resources.v2019_05_01.aio.operations_async.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. + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: Optional[str] = None, + **kwargs: 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) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + + self.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 close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "ResourceManagementClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/operations_async/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/operations_async/__init__.py new file mode 100644 index 000000000000..f1fd8637fa69 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/operations_async/__init__.py @@ -0,0 +1,25 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._operations_async import Operations +from ._deployments_operations_async import DeploymentsOperations +from ._providers_operations_async import ProvidersOperations +from ._resources_operations_async import ResourcesOperations +from ._resource_groups_operations_async import ResourceGroupsOperations +from ._tags_operations_async import TagsOperations +from ._deployment_operations_operations_async import DeploymentOperationsOperations + +__all__ = [ + 'Operations', + 'DeploymentsOperations', + 'ProvidersOperations', + 'ResourcesOperations', + 'ResourceGroupsOperations', + 'TagsOperations', + 'DeploymentOperationsOperations', +] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/operations_async/_deployment_operations_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/operations_async/_deployment_operations_operations_async.py new file mode 100644 index 000000000000..54704c904b95 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/operations_async/_deployment_operations_operations_async.py @@ -0,0 +1,440 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import 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 ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class DeploymentOperationsOperations: + """DeploymentOperationsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2019_05_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def get_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + operation_id: str, + **kwargs + ) -> "models.DeploymentOperation": + """Gets a deployments operation. + + :param group_id: The management group ID. + :type group_id: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param operation_id: The ID of the operation to get. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentOperation or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentOperation + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentOperation"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentOperation', pipeline_response) + + if cls: + 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 + + def list_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.DeploymentOperationsListResult"]: + """Gets all deployments operations for a deployment. + + :param group_id: The management group ID. + :type group_id: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentOperationsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + 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 + + async def get_at_subscription_scope( + self, + deployment_name: str, + operation_id: str, + **kwargs + ) -> "models.DeploymentOperation": + """Gets a deployments operation. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param operation_id: The ID of the operation to get. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentOperation or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentOperation + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentOperation"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentOperation', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + def list_at_subscription_scope( + self, + deployment_name: str, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.DeploymentOperationsListResult"]: + """Gets all deployments operations for a deployment. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentOperationsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + 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 + + async def get( + self, + resource_group_name: str, + deployment_name: str, + operation_id: str, + **kwargs + ) -> "models.DeploymentOperation": + """Gets a deployments operation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param operation_id: The ID of the operation to get. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentOperation or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentOperation + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentOperation"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-01" + + # Construct URL + url = self.get.metadata['url'] # type: 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentOperation', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + def list( + self, + resource_group_name: str, + deployment_name: str, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.DeploymentOperationsListResult"]: + """Gets all deployments operations for a deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentOperationsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/operations_async/_deployments_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/operations_async/_deployments_operations_async.py new file mode 100644 index 000000000000..ea0aeaeeef1d --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/operations_async/_deployments_operations_async.py @@ -0,0 +1,1786 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.polling import AsyncNoPolling, AsyncPollingMethod, async_poller +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class DeploymentsOperations: + """DeploymentsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2019_05_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def _delete_at_management_group_scope_initial( + self, + group_id: str, + deployment_name: str, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_at_management_group_scope_initial.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def delete_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + **kwargs + ) -> None: + """A template deployment that is currently running cannot be deleted. Deleting a template deployment removes the associated deployment operations. This is an asynchronous operation that returns a status of 202 until the template deployment is successfully deleted. The Location response header contains the URI that is used to obtain the status of the process. While the process is running, a call to the URI in the Location header returns a status of 202. When the process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. + + Deletes a deployment from the deployment history. + + :param group_id: The management group ID. + :type group_id: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._delete_at_management_group_scope_initial( + group_id=group_id, + deployment_name=deployment_name, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + delete_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def check_existence_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + **kwargs + ) -> None: + """Checks whether the deployment exists. + + :param group_id: The management group ID. + :type group_id: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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] + + # Construct and send request + 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 + + if response.status_code not in [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + 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, + deployment_name: str, + properties: "models.DeploymentProperties", + location: Optional[str] = None, + **kwargs + ) -> "models.DeploymentExtended": + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.Deployment(location=location, properties=properties) + api_version = "2019-05-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + 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 + + async def create_or_update_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + properties: "models.DeploymentProperties", + location: Optional[str] = None, + **kwargs + ) -> "models.DeploymentExtended": + """You can provide the template and parameters directly in the request or link to JSON files. + + Deploys resources at management group scope. + + :param group_id: The management group ID. + :type group_id: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param properties: The deployment properties. + :type properties: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentProperties + :param location: The location to store the deployment data. + :type location: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: DeploymentExtended + :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentExtended + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._create_or_update_at_management_group_scope_initial( + group_id=group_id, + deployment_name=deployment_name, + properties=properties, + location=location, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + create_or_update_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def get_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + **kwargs + ) -> "models.DeploymentExtended": + """Gets a deployment. + + :param group_id: The management group ID. + :type group_id: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExtended or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentExtended + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + 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 + + async def cancel_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + **kwargs + ) -> None: + """You can cancel a deployment only if the provisioningState is Accepted or Running. After the deployment is canceled, the provisioningState is set to Canceled. Canceling a template deployment stops the currently running template deployment and leaves the resources partially deployed. + + Cancels a currently running template deployment. + + :param group_id: The management group ID. + :type group_id: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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] + + # Construct and send request + 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 [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + 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( + self, + group_id: str, + deployment_name: str, + properties: "models.DeploymentProperties", + location: Optional[str] = None, + **kwargs + ) -> "models.DeploymentValidateResult": + """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. + + :param group_id: The management group ID. + :type group_id: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param properties: The deployment properties. + :type properties: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentProperties + :param location: The location to store the deployment data. + :type location: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentValidateResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentValidateResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.Deployment(location=location, properties=properties) + api_version = "2019-05-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 400]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + + if response.status_code == 400: + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + + if cls: + 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 + + async def export_template_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + **kwargs + ) -> "models.DeploymentExportResult": + """Exports the template used for specified deployment. + + :param group_id: The management group ID. + :type group_id: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentExportResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExportResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-01" + + # 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'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + + if cls: + 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 + + def list_at_management_group_scope( + self, + group_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.DeploymentListResult"]: + """Get all the deployments for a management group. + + :param group_id: The management group ID. + :type group_id: str + :param filter: The filter to apply on the operation. For example, you can use + $filter=provisioningState eq '{state}'. + :type filter: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + 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/'} # type: ignore + + async def _delete_at_subscription_scope_initial( + self, + deployment_name: str, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def delete_at_subscription_scope( + self, + deployment_name: str, + **kwargs + ) -> None: + """A template deployment that is currently running cannot be deleted. Deleting a template deployment removes the associated deployment operations. This is an asynchronous operation that returns a status of 202 until the template deployment is successfully deleted. The Location response header contains the URI that is used to obtain the status of the process. While the process is running, a call to the URI in the Location header returns a status of 202. When the process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. + + Deletes a deployment from the deployment history. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._delete_at_subscription_scope_initial( + deployment_name=deployment_name, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + delete_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def check_existence_at_subscription_scope( + self, + deployment_name: str, + **kwargs + ) -> None: + """Checks whether the deployment exists. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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] + + # Construct and send request + 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 + + if response.status_code not in [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + 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, + properties: "models.DeploymentProperties", + location: Optional[str] = None, + **kwargs + ) -> "models.DeploymentExtended": + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.Deployment(location=location, properties=properties) + api_version = "2019-05-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + 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 + + async def create_or_update_at_subscription_scope( + self, + deployment_name: str, + properties: "models.DeploymentProperties", + location: Optional[str] = None, + **kwargs + ) -> "models.DeploymentExtended": + """You can provide the template and parameters directly in the request or link to JSON files. + + Deploys resources at subscription scope. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param properties: The deployment properties. + :type properties: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentProperties + :param location: The location to store the deployment data. + :type location: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: DeploymentExtended + :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentExtended + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._create_or_update_at_subscription_scope_initial( + deployment_name=deployment_name, + properties=properties, + location=location, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + create_or_update_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def get_at_subscription_scope( + self, + deployment_name: str, + **kwargs + ) -> "models.DeploymentExtended": + """Gets a deployment. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExtended or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentExtended + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def cancel_at_subscription_scope( + self, + deployment_name: str, + **kwargs + ) -> None: + """You can cancel a deployment only if the provisioningState is Accepted or Running. After the deployment is canceled, the provisioningState is set to Canceled. Canceling a template deployment stops the currently running template deployment and leaves the resources partially deployed. + + Cancels a currently running template deployment. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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] + + # Construct and send request + 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 [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + cancel_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + + async def validate_at_subscription_scope( + self, + deployment_name: str, + properties: "models.DeploymentProperties", + location: Optional[str] = None, + **kwargs + ) -> "models.DeploymentValidateResult": + """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param properties: The deployment properties. + :type properties: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentProperties + :param location: The location to store the deployment data. + :type location: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentValidateResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentValidateResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.Deployment(location=location, properties=properties) + api_version = "2019-05-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 400]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + + if response.status_code == 400: + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + + if cls: + 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 export_template_at_subscription_scope( + self, + deployment_name: str, + **kwargs + ) -> "models.DeploymentExportResult": + """Exports the template used for specified deployment. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentExportResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExportResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-01" + + # 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'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + export_template_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + def list_at_subscription_scope( + self, + filter: Optional[str] = None, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.DeploymentListResult"]: + """Get all the deployments for a subscription. + + :param filter: The filter to apply on the operation. For example, you can use + $filter=provisioningState eq '{state}'. + :type filter: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/'} # type: ignore + + async def _delete_initial( + self, + resource_group_name: str, + deployment_name: str, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def delete( + self, + resource_group_name: str, + deployment_name: str, + **kwargs + ) -> None: + """A template deployment that is currently running cannot be deleted. Deleting a template deployment removes the associated deployment operations. Deleting a template deployment does not affect the state of the resource group. This is an asynchronous operation that returns a status of 202 until the template deployment is successfully deleted. The Location response header contains the URI that is used to obtain the status of the process. While the process is running, a call to the URI in the Location header returns a status of 202. When the process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. + + Deletes a deployment from the deployment history. + + :param resource_group_name: The name of the resource group with the deployment to delete. The + name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def check_existence( + self, + resource_group_name: str, + deployment_name: str, + **kwargs + ) -> None: + """Checks whether the deployment exists. + + :param resource_group_name: The name of the resource group with the deployment to check. The + name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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] + + # Construct and send request + 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 + + if response.status_code not in [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + 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, + deployment_name: str, + properties: "models.DeploymentProperties", + location: Optional[str] = None, + **kwargs + ) -> "models.DeploymentExtended": + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.Deployment(location=location, properties=properties) + api_version = "2019-05-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def create_or_update( + self, + resource_group_name: str, + deployment_name: str, + properties: "models.DeploymentProperties", + location: Optional[str] = None, + **kwargs + ) -> "models.DeploymentExtended": + """You can provide the template and parameters directly in the request or link to JSON files. + + Deploys resources to a resource group. + + :param resource_group_name: The name of the resource group to deploy the resources to. The name + is case insensitive. The resource group must already exist. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param properties: The deployment properties. + :type properties: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentProperties + :param location: The location to store the deployment data. + :type location: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: DeploymentExtended + :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentExtended + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + properties=properties, + location=location, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def get( + self, + resource_group_name: str, + deployment_name: str, + **kwargs + ) -> "models.DeploymentExtended": + """Gets a deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExtended or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentExtended + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-01" + + # Construct URL + url = self.get.metadata['url'] # type: 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def cancel( + self, + resource_group_name: str, + deployment_name: str, + **kwargs + ) -> None: + """You can cancel a deployment only if the provisioningState is Accepted or Running. After the deployment is canceled, the provisioningState is set to Canceled. Canceling a template deployment stops the currently running template deployment and leaves the resource group partially deployed. + + Cancels a currently running template deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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] + + # Construct and send request + 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 [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + cancel.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + + async def validate( + self, + resource_group_name: str, + deployment_name: str, + properties: "models.DeploymentProperties", + location: Optional[str] = None, + **kwargs + ) -> "models.DeploymentValidateResult": + """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param properties: The deployment properties. + :type properties: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentProperties + :param location: The location to store the deployment data. + :type location: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentValidateResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentValidateResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.Deployment(location=location, properties=properties) + api_version = "2019-05-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 400]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + + if response.status_code == 400: + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + validate.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + async def export_template( + self, + resource_group_name: str, + deployment_name: str, + **kwargs + ) -> "models.DeploymentExportResult": + """Exports the template used for specified deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentExportResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExportResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-01" + + # 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'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + def list_by_resource_group( + self, + resource_group_name: str, + filter: Optional[str] = None, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.DeploymentListResult"]: + """Get all the deployments for a resource group. + + :param resource_group_name: The name of the resource group with the deployments to get. The + name is case insensitive. + :type resource_group_name: str + :param filter: The filter to apply on the operation. For example, you can use + $filter=provisioningState eq '{state}'. + :type filter: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + 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 + + async def calculate_template_hash( + self, + template: object, + **kwargs + ) -> "models.TemplateHashResult": + """Calculate the hash of the given template. + + :param template: The template provided to calculate hash. + :type template: object + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateHashResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.TemplateHashResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TemplateHashResult"] + error_map = {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.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'] = 'application/json' + + # Construct and send request + 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) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('TemplateHashResult', pipeline_response) + + if cls: + 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_async/_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/operations_async/_operations_async.py new file mode 100644 index 000000000000..18b5cc2c8ff7 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/operations_async/_operations_async.py @@ -0,0 +1,101 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import 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 ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class Operations: + """Operations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2019_05_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + **kwargs + ) -> AsyncIterable["models.OperationListResult"]: + """Lists all of the available Microsoft.Resources REST API operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of OperationListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('OperationListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.Resources/operations'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/operations_async/_providers_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/operations_async/_providers_operations_async.py new file mode 100644 index 000000000000..4b2ac4c52b88 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/operations_async/_providers_operations_async.py @@ -0,0 +1,279 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import 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 ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ProvidersOperations: + """ProvidersOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2019_05_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def unregister( + self, + resource_provider_namespace: str, + **kwargs + ) -> "models.Provider": + """Unregisters a subscription from a resource provider. + + :param resource_provider_namespace: The namespace of the resource provider to unregister. + :type resource_provider_namespace: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Provider or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.Provider + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Provider"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-01" + + # 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'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Provider', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + unregister.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister'} # type: ignore + + async def register( + self, + resource_provider_namespace: str, + **kwargs + ) -> "models.Provider": + """Registers a subscription with a resource provider. + + :param resource_provider_namespace: The namespace of the resource provider to register. + :type resource_provider_namespace: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Provider or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.Provider + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Provider"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-01" + + # 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'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Provider', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + register.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register'} # type: ignore + + def list( + self, + top: Optional[int] = None, + expand: Optional[str] = None, + **kwargs + ) -> AsyncIterable["models.ProviderListResult"]: + """Gets all resource providers for a subscription. + + :param top: The number of results to return. If null is passed returns all deployments. + :type top: int + :param expand: The properties to include in the results. For example, use &$expand=metadata in + the query string to retrieve resource provider metadata. To include property aliases in + response, use $expand=resourceTypes/aliases. + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of ProviderListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ProviderListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers'} # type: ignore + + async def get( + self, + resource_provider_namespace: str, + expand: Optional[str] = None, + **kwargs + ) -> "models.Provider": + """Gets the specified resource provider. + + :param resource_provider_namespace: The namespace of the resource provider. + :type resource_provider_namespace: str + :param expand: The $expand query parameter. For example, to include property aliases in + response, use $expand=resourceTypes/aliases. + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Provider or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.Provider + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Provider"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Provider', pipeline_response) + + if cls: + 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_async/_resource_groups_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/operations_async/_resource_groups_operations_async.py new file mode 100644 index 000000000000..c5db2b88a5d7 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/operations_async/_resource_groups_operations_async.py @@ -0,0 +1,505 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, List, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.polling import AsyncNoPolling, AsyncPollingMethod, async_poller +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ResourceGroupsOperations: + """ResourceGroupsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2019_05_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def check_existence( + self, + resource_group_name: str, + **kwargs + ) -> None: + """Checks whether a resource group exists. + + :param resource_group_name: The name of the resource group to check. 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: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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] + + # Construct and send request + 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 + + if response.status_code not in [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + async def create_or_update( + self, + resource_group_name: str, + parameters: "models.ResourceGroup", + **kwargs + ) -> "models.ResourceGroup": + """Creates or updates a resource group. + + :param resource_group_name: The name of the resource group to create or update. Can include + alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters + that match the allowed characters. + :type resource_group_name: str + :param parameters: Parameters supplied to the create or update a resource group. + :type parameters: ~azure.mgmt.resource.resources.v2019_05_01.models.ResourceGroup + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.ResourceGroup + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceGroup"] + error_map = {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.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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ResourceGroup', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ResourceGroup', pipeline_response) + + if cls: + 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, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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] + + # Construct and send request + 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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + async def delete( + self, + resource_group_name: str, + **kwargs + ) -> None: + """When you delete a resource group, all of its resources are also deleted. Deleting a resource group deletes all of its template deployments and currently stored operations. + + Deletes a resource group. + + :param resource_group_name: The name of the resource group to delete. 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 + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + async def get( + self, + resource_group_name: str, + **kwargs + ) -> "models.ResourceGroup": + """Gets a resource group. + + :param resource_group_name: The name of the resource group to get. 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: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.ResourceGroup + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceGroup"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-01" + + # Construct URL + url = self.get.metadata['url'] # type: 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ResourceGroup', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + async def update( + self, + resource_group_name: str, + parameters: "models.ResourceGroupPatchable", + **kwargs + ) -> "models.ResourceGroup": + """Resource groups can be updated through a simple PATCH operation to a group address. The format of the request is the same as that for creating a resource group. If a field is unspecified, the current value is retained. + + Updates a resource group. + + :param resource_group_name: The name of the resource group to update. The name is case + insensitive. + :type resource_group_name: str + :param parameters: Parameters supplied to update a resource group. + :type parameters: ~azure.mgmt.resource.resources.v2019_05_01.models.ResourceGroupPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.ResourceGroup + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceGroup"] + error_map = {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.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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ResourceGroup', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + async def export_template( + self, + resource_group_name: str, + resources: Optional[List[str]] = None, + options: Optional[str] = None, + **kwargs + ) -> "models.ResourceGroupExportResult": + """Captures the specified resource group as a template. + + :param resource_group_name: The name of the resource group to export as a template. + :type resource_group_name: str + :param 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', + 'SkipResourceNameParameterization', 'SkipAllParameterization'. + :type options: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroupExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.ResourceGroupExportResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceGroupExportResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.ExportTemplateRequest(resources=resources, options=options) + api_version = "2019-05-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ResourceGroupExportResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate'} # type: ignore + + def list( + self, + filter: Optional[str] = None, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.ResourceGroupListResult"]: + """Gets all the resource groups for a subscription. + + :param filter: The filter to apply on the operation.:code:`
`:code:`
`You can filter by + tag names and values. For example, to filter for a tag name and value, use $filter=tagName eq + 'tag1' and tagValue eq 'Value1'. + :type filter: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ResourceGroupListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/operations_async/_resources_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/operations_async/_resources_operations_async.py new file mode 100644 index 000000000000..02d78f4ba452 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/operations_async/_resources_operations_async.py @@ -0,0 +1,1308 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, List, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.polling import AsyncNoPolling, AsyncPollingMethod, async_poller +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ResourcesOperations: + """ResourcesOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2019_05_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list_by_resource_group( + self, + resource_group_name: str, + filter: Optional[str] = None, + expand: Optional[str] = None, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.ResourceListResult"]: + """Get all the resources for a resource group. + + :param resource_group_name: The resource group with the resources to get. + :type resource_group_name: str + :param filter: The filter to apply on the operation.:code:`
`:code:`
`The properties you + can use for eq (equals) or ne (not equals) are: location, resourceType, name, resourceGroup, + identity, identity/principalId, plan, plan/publisher, plan/product, plan/name, plan/version, + and plan/promotionCode.:code:`
`:code:`
`For example, to filter by a resource type, use: + $filter=resourceType eq 'Microsoft.Network/virtualNetworks':code:`
`:code:`
`You can use + substringof(value, property) in the filter. The properties you can use for substring are: name + and resourceGroup.:code:`
`:code:`
`For example, to get all resources with 'demo' + anywhere in the name, use: $filter=substringof('demo', name):code:`
`:code:`
`You can + link more than one substringof together by adding and/or operators.:code:`
`:code:`
`You + can filter by tag names and values. For example, to filter for a tag name and value, use + $filter=tagName eq 'tag1' and tagValue eq 'Value1':code:`
`:code:`
`You can use some + properties together when filtering. The combinations you can use are: substringof and/or + resourceType, plan and plan/publisher and plan/name, identity and identity/principalId. + :type filter: str + :param expand: Comma-separated list of additional properties to be included in the response. + Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, + ``$expand=createdTime,changedTime``. + :type expand: str + :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 ResourceListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ResourceListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources'} # type: ignore + + async def _move_resources_initial( + self, + source_resource_group_name: str, + resources: Optional[List[str]] = None, + target_resource_group: Optional[str] = None, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.ResourcesMoveInfo(resources=resources, target_resource_group=target_resource_group) + 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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + + # Construct and send request + 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 + + if response.status_code not in [202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore + + async def move_resources( + self, + source_resource_group_name: str, + resources: Optional[List[str]] = None, + target_resource_group: Optional[str] = None, + **kwargs + ) -> None: + """The resources to move must be in the same source resource group. The target resource group may be in a different subscription. When moving resources, both the source group and the target group are locked for the duration of the operation. Write and delete operations are blocked on the groups until the move completes. + + Moves resources from one resource group to another resource group. + + :param source_resource_group_name: The name of the resource group containing the resources to + move. + :type source_resource_group_name: str + :param resources: The IDs of the resources. + :type resources: list[str] + :param target_resource_group: The target resource group. + :type target_resource_group: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._move_resources_initial( + source_resource_group_name=source_resource_group_name, + resources=resources, + target_resource_group=target_resource_group, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore + + async def _validate_move_resources_initial( + self, + source_resource_group_name: str, + resources: Optional[List[str]] = None, + target_resource_group: Optional[str] = None, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.ResourcesMoveInfo(resources=resources, target_resource_group=target_resource_group) + 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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + + # Construct and send request + 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 + + if response.status_code not in [202, 204, 409]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _validate_move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} # type: ignore + + async def validate_move_resources( + self, + source_resource_group_name: str, + resources: Optional[List[str]] = None, + target_resource_group: Optional[str] = None, + **kwargs + ) -> None: + """This operation checks whether the specified resources can be moved to the target. The resources to move must be in the same source resource group. The target resource group may be in a different subscription. If validation succeeds, it returns HTTP response code 204 (no content). If validation fails, it returns HTTP response code 409 (Conflict) with an error message. Retrieve the URL in the Location header value to check the result of the long-running operation. + + Validates whether resources can be moved from one resource group to another resource group. + + :param source_resource_group_name: The name of the resource group containing the resources to + validate for move. + :type source_resource_group_name: str + :param resources: The IDs of the resources. + :type resources: list[str] + :param target_resource_group: The target resource group. + :type target_resource_group: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._validate_move_resources_initial( + source_resource_group_name=source_resource_group_name, + resources=resources, + target_resource_group=target_resource_group, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + validate_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} # type: ignore + + def list( + self, + filter: Optional[str] = None, + expand: Optional[str] = None, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.ResourceListResult"]: + """Get all the resources in a subscription. + + :param filter: The filter to apply on the operation.:code:`
`:code:`
`The properties you + can use for eq (equals) or ne (not equals) are: location, resourceType, name, resourceGroup, + identity, identity/principalId, plan, plan/publisher, plan/product, plan/name, plan/version, + and plan/promotionCode.:code:`
`:code:`
`For example, to filter by a resource type, use: + $filter=resourceType eq 'Microsoft.Network/virtualNetworks':code:`
`:code:`
`You can use + substringof(value, property) in the filter. The properties you can use for substring are: name + and resourceGroup.:code:`
`:code:`
`For example, to get all resources with 'demo' + anywhere in the name, use: $filter=substringof('demo', name):code:`
`:code:`
`You can + link more than one substringof together by adding and/or operators.:code:`
`:code:`
`You + can filter by tag names and values. For example, to filter for a tag name and value, use + $filter=tagName eq 'tag1' and tagValue eq 'Value1':code:`
`:code:`
`You can use some + properties together when filtering. The combinations you can use are: substringof and/or + resourceType, plan and plan/publisher and plan/name, identity and identity/principalId. + :type filter: str + :param expand: Comma-separated list of additional properties to be included in the response. + Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, + ``$expand=createdTime,changedTime``. + :type expand: str + :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 ResourceListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ResourceListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resources'} # type: ignore + + async def check_existence( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + **kwargs + ) -> None: + """Checks whether a resource exists. + + :param resource_group_name: The name of the resource group containing the resource to check. + The name is case insensitive. + :type resource_group_name: str + :param resource_provider_namespace: The resource provider of the resource to check. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. + :type parent_resource_path: str + :param resource_type: The resource type. + :type resource_type: str + :param resource_name: The name of the resource to check whether it exists. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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\._\(\)]+$'), + 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), + 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_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] + + # Construct and send request + 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 + + if response.status_code not in [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + 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, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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\._\(\)]+$'), + 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), + 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + async def delete( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + **kwargs + ) -> None: + """Deletes a resource. + + :param resource_group_name: The name of the resource group that contains the resource to + delete. The name is case insensitive. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. + :type parent_resource_path: str + :param resource_type: The resource type. + :type resource_type: str + :param resource_name: The name of the resource to delete. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._delete_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, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + parameters: "models.GenericResource", + **kwargs + ) -> "models.GenericResource": + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {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._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'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 201, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('GenericResource', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + async def create_or_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + parameters: "models.GenericResource", + **kwargs + ) -> "models.GenericResource": + """Creates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to create. + :type resource_type: str + :param resource_name: The name of the resource to create. + :type resource_name: str + :param parameters: Parameters for creating or updating the resource. + :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 polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: GenericResource + :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._create_or_update_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, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + 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, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + parameters: "models.GenericResource", + **kwargs + ) -> "models.GenericResource": + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {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._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'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + async def update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + parameters: "models.GenericResource", + **kwargs + ) -> "models.GenericResource": + """Updates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to update. + :type resource_type: str + :param resource_name: The name of the resource to update. + :type resource_name: str + :param parameters: Parameters for updating the resource. + :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 polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: GenericResource + :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._update_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, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + async def get( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + **kwargs + ) -> "models.GenericResource": + """Gets a resource. + + :param resource_group_name: The name of the resource group containing the resource to get. The + name is case insensitive. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. + :type parent_resource_path: str + :param resource_type: The resource type of the resource. + :type resource_type: str + :param resource_name: The name of the resource to get. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GenericResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-01" + + # Construct URL + url = self.get.metadata['url'] # type: 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + async def check_existence_by_id( + self, + resource_id: str, + **kwargs + ) -> None: + """Checks by ID whether a resource exists. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + :type resource_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-01" + + # 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] + + # Construct and send request + 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 + + if response.status_code not in [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + 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, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-01" + + # 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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + async def delete_by_id( + self, + resource_id: str, + **kwargs + ) -> None: + """Deletes a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + :type resource_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._delete_by_id_initial( + resource_id=resource_id, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + delete_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + + async def _create_or_update_by_id_initial( + self, + resource_id: str, + parameters: "models.GenericResource", + **kwargs + ) -> "models.GenericResource": + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {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._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) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 201, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('GenericResource', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + async def create_or_update_by_id( + self, + resource_id: str, + parameters: "models.GenericResource", + **kwargs + ) -> "models.GenericResource": + """Create a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + :type resource_id: str + :param parameters: Create or update resource parameters. + :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 polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: GenericResource + :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._create_or_update_by_id_initial( + resource_id=resource_id, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + create_or_update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + + async def _update_by_id_initial( + self, + resource_id: str, + parameters: "models.GenericResource", + **kwargs + ) -> "models.GenericResource": + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {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._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) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + async def update_by_id( + self, + resource_id: str, + parameters: "models.GenericResource", + **kwargs + ) -> "models.GenericResource": + """Updates a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + :type resource_id: str + :param parameters: Update resource parameters. + :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 polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: GenericResource + :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._update_by_id_initial( + resource_id=resource_id, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + + async def get_by_id( + self, + resource_id: str, + **kwargs + ) -> "models.GenericResource": + """Gets a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + :type resource_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GenericResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + 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_async/_tags_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/operations_async/_tags_operations_async.py new file mode 100644 index 000000000000..7be7889de498 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/aio/operations_async/_tags_operations_async.py @@ -0,0 +1,327 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import 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 ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class TagsOperations: + """TagsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2019_05_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def delete_value( + self, + tag_name: str, + tag_value: str, + **kwargs + ) -> None: + """Deletes a tag value. + + :param tag_name: The name of the tag. + :type tag_name: str + :param tag_value: The value of the tag to delete. + :type tag_value: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore + + async def create_or_update_value( + self, + tag_name: str, + tag_value: str, + **kwargs + ) -> "models.TagValue": + """Creates a tag value. The name of the tag must already exist. + + :param tag_name: The name of the tag. + :type tag_name: str + :param tag_value: The value of the tag to create. + :type tag_value: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagValue or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.TagValue + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TagValue"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-01" + + # 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'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('TagValue', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('TagValue', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore + + async def create_or_update( + self, + tag_name: str, + **kwargs + ) -> "models.TagDetails": + """The tag name can have a maximum of 512 characters and is case insensitive. Tag names created by Azure have prefixes of microsoft, azure, or windows. You cannot create tags with one of these prefixes. + + Creates a tag in the subscription. + + :param tag_name: The name of the tag to create. + :type tag_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagDetails or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.TagDetails + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TagDetails"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-01" + + # 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'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('TagDetails', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('TagDetails', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore + + async def delete( + self, + tag_name: str, + **kwargs + ) -> None: + """You must remove all values from a resource tag before you can delete it. + + Deletes a tag from the subscription. + + :param tag_name: The name of the tag. + :type tag_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore + + def list( + self, + **kwargs + ) -> AsyncIterable["models.TagsListResult"]: + """Gets the names and values of all resource tags that are defined in a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of TagsListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('TagsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/models/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/models/__init__.py index a4e62c5bf265..b94776ab3cce 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/models/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/models/__init__.py @@ -1,26 +1,26 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- try: from ._models_py3 import AliasPathType from ._models_py3 import AliasType from ._models_py3 import BasicDependency + from ._models_py3 import ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties from ._models_py3 import DebugSetting from ._models_py3 import Dependency from ._models_py3 import Deployment from ._models_py3 import DeploymentExportResult from ._models_py3 import DeploymentExtended from ._models_py3 import DeploymentExtendedFilter + from ._models_py3 import DeploymentListResult from ._models_py3 import DeploymentOperation from ._models_py3 import DeploymentOperationProperties + from ._models_py3 import DeploymentOperationsListResult from ._models_py3 import DeploymentProperties from ._models_py3 import DeploymentPropertiesExtended from ._models_py3 import DeploymentValidateResult @@ -32,21 +32,24 @@ from ._models_py3 import GenericResourceFilter from ._models_py3 import HttpMessage from ._models_py3 import Identity - from ._models_py3 import IdentityUserAssignedIdentitiesValue from ._models_py3 import OnErrorDeployment from ._models_py3 import OnErrorDeploymentExtended from ._models_py3 import Operation from ._models_py3 import OperationDisplay + from ._models_py3 import OperationListResult from ._models_py3 import ParametersLink from ._models_py3 import Plan from ._models_py3 import Provider + from ._models_py3 import ProviderListResult from ._models_py3 import ProviderResourceType from ._models_py3 import Resource from ._models_py3 import ResourceGroup from ._models_py3 import ResourceGroupExportResult from ._models_py3 import ResourceGroupFilter + from ._models_py3 import ResourceGroupListResult from ._models_py3 import ResourceGroupPatchable from ._models_py3 import ResourceGroupProperties + from ._models_py3 import ResourceListResult from ._models_py3 import ResourceManagementErrorWithDetails from ._models_py3 import ResourceProviderOperationDisplayProperties from ._models_py3 import ResourcesMoveInfo @@ -55,65 +58,67 @@ from ._models_py3 import TagCount from ._models_py3 import TagDetails from ._models_py3 import TagValue + from ._models_py3 import TagsListResult from ._models_py3 import TargetResource from ._models_py3 import TemplateHashResult from ._models_py3 import TemplateLink except (SyntaxError, ImportError): - from ._models import AliasPathType - from ._models import AliasType - from ._models import BasicDependency - from ._models import DebugSetting - from ._models import Dependency - from ._models import Deployment - from ._models import DeploymentExportResult - from ._models import DeploymentExtended - from ._models import DeploymentExtendedFilter - from ._models import DeploymentOperation - from ._models import DeploymentOperationProperties - from ._models import DeploymentProperties - from ._models import DeploymentPropertiesExtended - from ._models import DeploymentValidateResult - from ._models import ErrorAdditionalInfo - from ._models import ErrorResponse - from ._models import ExportTemplateRequest - from ._models import GenericResource - from ._models import GenericResourceExpanded - from ._models import GenericResourceFilter - from ._models import HttpMessage - from ._models import Identity - from ._models import IdentityUserAssignedIdentitiesValue - from ._models import OnErrorDeployment - from ._models import OnErrorDeploymentExtended - from ._models import Operation - from ._models import OperationDisplay - from ._models import ParametersLink - from ._models import Plan - from ._models import Provider - from ._models import ProviderResourceType - from ._models import Resource - from ._models import ResourceGroup - from ._models import ResourceGroupExportResult - from ._models import ResourceGroupFilter - from ._models import ResourceGroupPatchable - from ._models import ResourceGroupProperties - from ._models import ResourceManagementErrorWithDetails - from ._models import ResourceProviderOperationDisplayProperties - from ._models import ResourcesMoveInfo - from ._models import Sku - from ._models import SubResource - from ._models import TagCount - from ._models import TagDetails - from ._models import TagValue - from ._models import TargetResource - from ._models import TemplateHashResult - from ._models import TemplateLink -from ._paged_models import DeploymentExtendedPaged -from ._paged_models import DeploymentOperationPaged -from ._paged_models import GenericResourceExpandedPaged -from ._paged_models import OperationPaged -from ._paged_models import ProviderPaged -from ._paged_models import ResourceGroupPaged -from ._paged_models import TagDetailsPaged + from ._models import AliasPathType # type: ignore + from ._models import AliasType # type: ignore + from ._models import BasicDependency # type: ignore + from ._models import ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties # type: ignore + from ._models import DebugSetting # type: ignore + from ._models import Dependency # type: ignore + from ._models import Deployment # type: ignore + from ._models import DeploymentExportResult # type: ignore + from ._models import DeploymentExtended # type: ignore + from ._models import DeploymentExtendedFilter # type: ignore + from ._models import DeploymentListResult # type: ignore + from ._models import DeploymentOperation # type: ignore + from ._models import DeploymentOperationProperties # type: ignore + from ._models import DeploymentOperationsListResult # type: ignore + from ._models import DeploymentProperties # type: ignore + from ._models import DeploymentPropertiesExtended # type: ignore + from ._models import DeploymentValidateResult # type: ignore + from ._models import ErrorAdditionalInfo # type: ignore + from ._models import ErrorResponse # type: ignore + from ._models import ExportTemplateRequest # type: ignore + from ._models import GenericResource # type: ignore + from ._models import GenericResourceExpanded # type: ignore + from ._models import GenericResourceFilter # type: ignore + from ._models import HttpMessage # type: ignore + from ._models import Identity # type: ignore + from ._models import OnErrorDeployment # type: ignore + from ._models import OnErrorDeploymentExtended # type: ignore + from ._models import Operation # type: ignore + from ._models import OperationDisplay # type: ignore + from ._models import OperationListResult # type: ignore + from ._models import ParametersLink # type: ignore + from ._models import Plan # type: ignore + from ._models import Provider # type: ignore + from ._models import ProviderListResult # type: ignore + from ._models import ProviderResourceType # type: ignore + from ._models import Resource # type: ignore + from ._models import ResourceGroup # type: ignore + from ._models import ResourceGroupExportResult # type: ignore + from ._models import ResourceGroupFilter # type: ignore + from ._models import ResourceGroupListResult # type: ignore + from ._models import ResourceGroupPatchable # type: ignore + from ._models import ResourceGroupProperties # type: ignore + from ._models import ResourceListResult # type: ignore + from ._models import ResourceManagementErrorWithDetails # type: ignore + from ._models import ResourceProviderOperationDisplayProperties # type: ignore + from ._models import ResourcesMoveInfo # type: ignore + from ._models import Sku # type: ignore + from ._models import SubResource # type: ignore + from ._models import TagCount # type: ignore + from ._models import TagDetails # type: ignore + from ._models import TagValue # type: ignore + from ._models import TagsListResult # type: ignore + from ._models import TargetResource # type: ignore + from ._models import TemplateHashResult # type: ignore + from ._models import TemplateLink # type: ignore + from ._resource_management_client_enums import ( DeploymentMode, OnErrorDeploymentType, @@ -124,14 +129,17 @@ 'AliasPathType', 'AliasType', 'BasicDependency', + 'ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties', 'DebugSetting', 'Dependency', 'Deployment', 'DeploymentExportResult', 'DeploymentExtended', 'DeploymentExtendedFilter', + 'DeploymentListResult', 'DeploymentOperation', 'DeploymentOperationProperties', + 'DeploymentOperationsListResult', 'DeploymentProperties', 'DeploymentPropertiesExtended', 'DeploymentValidateResult', @@ -143,21 +151,24 @@ 'GenericResourceFilter', 'HttpMessage', 'Identity', - 'IdentityUserAssignedIdentitiesValue', 'OnErrorDeployment', 'OnErrorDeploymentExtended', 'Operation', 'OperationDisplay', + 'OperationListResult', 'ParametersLink', 'Plan', 'Provider', + 'ProviderListResult', 'ProviderResourceType', 'Resource', 'ResourceGroup', 'ResourceGroupExportResult', 'ResourceGroupFilter', + 'ResourceGroupListResult', 'ResourceGroupPatchable', 'ResourceGroupProperties', + 'ResourceListResult', 'ResourceManagementErrorWithDetails', 'ResourceProviderOperationDisplayProperties', 'ResourcesMoveInfo', @@ -166,16 +177,10 @@ 'TagCount', 'TagDetails', 'TagValue', + 'TagsListResult', 'TargetResource', 'TemplateHashResult', 'TemplateLink', - 'OperationPaged', - 'DeploymentExtendedPaged', - 'ProviderPaged', - 'GenericResourceExpandedPaged', - 'ResourceGroupPaged', - 'TagDetailsPaged', - 'DeploymentOperationPaged', 'DeploymentMode', 'OnErrorDeploymentType', 'ResourceIdentityType', 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 95c097dda8dd..19a599456635 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 @@ -1,20 +1,16 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.serialization import Model -from msrest.exceptions import HttpOperationError +import msrest.serialization -class AliasPathType(Model): - """The type of the paths for alias. . +class AliasPathType(msrest.serialization.Model): + """The type of the paths for alias. :param path: The path of an alias. :type path: str @@ -27,20 +23,22 @@ class AliasPathType(Model): 'api_versions': {'key': 'apiVersions', 'type': '[str]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(AliasPathType, self).__init__(**kwargs) self.path = kwargs.get('path', None) self.api_versions = kwargs.get('api_versions', None) -class AliasType(Model): - """The alias type. . +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] + :type paths: list[~azure.mgmt.resource.resources.v2019_05_01.models.AliasPathType] """ _attribute_map = { @@ -48,13 +46,16 @@ class AliasType(Model): 'paths': {'key': 'paths', 'type': '[AliasPathType]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(AliasType, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.paths = kwargs.get('paths', None) -class BasicDependency(Model): +class BasicDependency(msrest.serialization.Model): """Deployment dependency information. :param id: The ID of the dependency. @@ -71,52 +72,55 @@ class BasicDependency(Model): 'resource_name': {'key': 'resourceName', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(BasicDependency, self).__init__(**kwargs) self.id = kwargs.get('id', None) self.resource_type = kwargs.get('resource_type', None) self.resource_name = kwargs.get('resource_name', None) -class CloudError(Model): - """An error response for a resource management request. +class ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties(msrest.serialization.Model): + """ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties. - :param error: - :type error: - ~azure.mgmt.resource.resources.v2019_05_01.models.ErrorResponse + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar principal_id: The principal id of user assigned identity. + :vartype principal_id: str + :ivar client_id: The client id of user assigned identity. + :vartype client_id: str """ - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorResponse'}, + _validation = { + 'principal_id': {'readonly': True}, + 'client_id': {'readonly': True}, } - def __init__(self, **kwargs): - super(CloudError, self).__init__(**kwargs) - self.error = kwargs.get('error', None) - - -class CloudErrorException(HttpOperationError): - """Server responsed with exception of type: 'CloudError'. - - :param deserialize: A deserializer - :param response: Server response to be deserialized. - """ - - def __init__(self, deserialize, response, *args): + _attribute_map = { + 'principal_id': {'key': 'principalId', 'type': 'str'}, + 'client_id': {'key': 'clientId', 'type': 'str'}, + } - super(CloudErrorException, self).__init__(deserialize, response, 'CloudError', *args) + def __init__( + self, + **kwargs + ): + super(ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties, self).__init__(**kwargs) + self.principal_id = None + self.client_id = None -class DebugSetting(Model): +class DebugSetting(msrest.serialization.Model): """The debug setting. - :param 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. + :param 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 """ @@ -124,17 +128,19 @@ class DebugSetting(Model): 'detail_level': {'key': 'detailLevel', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DebugSetting, self).__init__(**kwargs) self.detail_level = kwargs.get('detail_level', None) -class Dependency(Model): +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] + :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. @@ -150,7 +156,10 @@ class Dependency(Model): 'resource_name': {'key': 'resourceName', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Dependency, self).__init__(**kwargs) self.depends_on = kwargs.get('depends_on', None) self.id = kwargs.get('id', None) @@ -158,7 +167,7 @@ def __init__(self, **kwargs): self.resource_name = kwargs.get('resource_name', None) -class Deployment(Model): +class Deployment(msrest.serialization.Model): """Deployment operation parameters. All required parameters must be populated in order to send to Azure. @@ -166,8 +175,7 @@ class Deployment(Model): :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 + :type properties: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentProperties """ _validation = { @@ -179,14 +187,17 @@ class Deployment(Model): 'properties': {'key': 'properties', 'type': 'DeploymentProperties'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Deployment, self).__init__(**kwargs) self.location = kwargs.get('location', None) - self.properties = kwargs.get('properties', None) + self.properties = kwargs['properties'] -class DeploymentExportResult(Model): - """The deployment export result. . +class DeploymentExportResult(msrest.serialization.Model): + """The deployment export result. :param template: The template content. :type template: object @@ -196,16 +207,18 @@ class DeploymentExportResult(Model): 'template': {'key': 'template', 'type': 'object'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentExportResult, self).__init__(**kwargs) self.template = kwargs.get('template', None) -class DeploymentExtended(Model): +class DeploymentExtended(msrest.serialization.Model): """Deployment information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The ID of the deployment. :vartype id: str @@ -234,7 +247,10 @@ class DeploymentExtended(Model): 'properties': {'key': 'properties', 'type': 'DeploymentPropertiesExtended'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentExtended, self).__init__(**kwargs) self.id = None self.name = None @@ -243,7 +259,7 @@ def __init__(self, **kwargs): self.properties = kwargs.get('properties', None) -class DeploymentExtendedFilter(Model): +class DeploymentExtendedFilter(msrest.serialization.Model): """Deployment filter. :param provisioning_state: The provisioning state. @@ -254,16 +270,47 @@ class DeploymentExtendedFilter(Model): 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentExtendedFilter, self).__init__(**kwargs) self.provisioning_state = kwargs.get('provisioning_state', None) -class DeploymentOperation(Model): +class DeploymentListResult(msrest.serialization.Model): + """List of deployments. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[DeploymentExtended]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(DeploymentListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = None + + +class DeploymentOperation(msrest.serialization.Model): """Deployment operation information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Full deployment operation ID. :vartype id: str @@ -285,23 +332,25 @@ class DeploymentOperation(Model): 'properties': {'key': 'properties', 'type': 'DeploymentOperationProperties'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentOperation, self).__init__(**kwargs) self.id = None self.operation_id = None self.properties = kwargs.get('properties', None) -class DeploymentOperationProperties(Model): +class DeploymentOperationProperties(msrest.serialization.Model): """Deployment operation properties. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar provisioning_state: The state of the provisioning. :vartype provisioning_state: str :ivar timestamp: The date and time of the operation. - :vartype timestamp: datetime + :vartype timestamp: ~datetime.datetime :ivar duration: The duration of the operation. :vartype duration: str :ivar service_request_id: Deployment operation service request id. @@ -311,14 +360,11 @@ class DeploymentOperationProperties(Model): :ivar status_message: Operation status message. :vartype status_message: object :ivar target_resource: The target resource. - :vartype target_resource: - ~azure.mgmt.resource.resources.v2019_05_01.models.TargetResource + :vartype target_resource: ~azure.mgmt.resource.resources.v2019_05_01.models.TargetResource :ivar request: The HTTP request message. - :vartype request: - ~azure.mgmt.resource.resources.v2019_05_01.models.HttpMessage + :vartype request: ~azure.mgmt.resource.resources.v2019_05_01.models.HttpMessage :ivar response: The HTTP response message. - :vartype response: - ~azure.mgmt.resource.resources.v2019_05_01.models.HttpMessage + :vartype response: ~azure.mgmt.resource.resources.v2019_05_01.models.HttpMessage """ _validation = { @@ -345,7 +391,10 @@ class DeploymentOperationProperties(Model): 'response': {'key': 'response', 'type': 'HttpMessage'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentOperationProperties, self).__init__(**kwargs) self.provisioning_state = None self.timestamp = None @@ -358,48 +407,68 @@ def __init__(self, **kwargs): self.response = None -class DeploymentProperties(Model): +class DeploymentOperationsListResult(msrest.serialization.Model): + """List of deployment operations. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[DeploymentOperation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(DeploymentOperationsListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = None + + +class DeploymentProperties(msrest.serialization.Model): """Deployment properties. 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 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. + :param 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: object - :param 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. 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. + :param 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. + 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: object - :param 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 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 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 + 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 + :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 + :type on_error_deployment: ~azure.mgmt.resource.resources.v2019_05_01.models.OnErrorDeployment """ _validation = { @@ -411,66 +480,59 @@ class DeploymentProperties(Model): 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, 'parameters': {'key': 'parameters', 'type': 'object'}, 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, - 'mode': {'key': 'mode', 'type': 'DeploymentMode'}, + 'mode': {'key': 'mode', 'type': 'str'}, 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, 'on_error_deployment': {'key': 'onErrorDeployment', 'type': 'OnErrorDeployment'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentProperties, self).__init__(**kwargs) self.template = kwargs.get('template', None) self.template_link = kwargs.get('template_link', None) self.parameters = kwargs.get('parameters', None) self.parameters_link = kwargs.get('parameters_link', None) - self.mode = kwargs.get('mode', None) + self.mode = kwargs['mode'] self.debug_setting = kwargs.get('debug_setting', None) self.on_error_deployment = kwargs.get('on_error_deployment', None) -class DeploymentPropertiesExtended(Model): +class DeploymentPropertiesExtended(msrest.serialization.Model): """Deployment properties with additional details. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :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 + :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: object - :param providers: The list of resource providers needed for the - deployment. - :type providers: - list[~azure.mgmt.resource.resources.v2019_05_01.models.Provider] + :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 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: object - :param 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. + :param 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: object - :param 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 include: 'Incremental', 'Complete' - :type mode: str or - ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentMode + :param 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 + 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 + :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.OnErrorDeploymentExtended @@ -495,12 +557,15 @@ class DeploymentPropertiesExtended(Model): 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, 'parameters': {'key': 'parameters', 'type': 'object'}, 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, - 'mode': {'key': 'mode', 'type': 'DeploymentMode'}, + 'mode': {'key': 'mode', 'type': 'str'}, 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, 'on_error_deployment': {'key': 'onErrorDeployment', 'type': 'OnErrorDeploymentExtended'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentPropertiesExtended, self).__init__(**kwargs) self.provisioning_state = None self.correlation_id = None @@ -518,7 +583,7 @@ def __init__(self, **kwargs): self.on_error_deployment = kwargs.get('on_error_deployment', None) -class DeploymentValidateResult(Model): +class DeploymentValidateResult(msrest.serialization.Model): """Information from validate template deployment response. :param error: Validation error. @@ -534,17 +599,19 @@ class DeploymentValidateResult(Model): 'properties': {'key': 'properties', 'type': 'DeploymentPropertiesExtended'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentValidateResult, self).__init__(**kwargs) self.error = kwargs.get('error', None) self.properties = kwargs.get('properties', None) -class ErrorAdditionalInfo(Model): +class ErrorAdditionalInfo(msrest.serialization.Model): """The resource management error additional info. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar type: The additional info type. :vartype type: str @@ -562,17 +629,19 @@ class ErrorAdditionalInfo(Model): 'info': {'key': 'info', 'type': 'object'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None -class ErrorResponse(Model): +class ErrorResponse(msrest.serialization.Model): """The resource management error response. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar code: The error code. :vartype code: str @@ -581,8 +650,7 @@ class ErrorResponse(Model): :ivar target: The error target. :vartype target: str :ivar details: The error details. - :vartype details: - list[~azure.mgmt.resource.resources.v2019_05_01.models.ErrorResponse] + :vartype details: list[~azure.mgmt.resource.resources.v2019_05_01.models.ErrorResponse] :ivar additional_info: The error additional info. :vartype additional_info: list[~azure.mgmt.resource.resources.v2019_05_01.models.ErrorAdditionalInfo] @@ -604,7 +672,10 @@ class ErrorResponse(Model): 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ErrorResponse, self).__init__(**kwargs) self.code = None self.message = None @@ -613,16 +684,15 @@ def __init__(self, **kwargs): self.additional_info = None -class ExportTemplateRequest(Model): +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, supply an array with single entry '*'. + :param 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', 'SkipResourceNameParameterization', - 'SkipAllParameterization' + :param options: The export template options. A CSV-formatted list containing zero or more of + the following: 'IncludeParameterDefaultValue', 'IncludeComments', + 'SkipResourceNameParameterization', 'SkipAllParameterization'. :type options: str """ @@ -631,27 +701,29 @@ class ExportTemplateRequest(Model): 'options': {'key': 'options', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ExportTemplateRequest, self).__init__(**kwargs) self.resources = kwargs.get('resources', None) self.options = kwargs.get('options', None) -class Resource(Model): +class Resource(msrest.serialization.Model): """Specified resource. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID + :ivar id: Resource ID. :vartype id: str - :ivar name: Resource name + :ivar name: Resource name. :vartype name: str - :ivar type: Resource type + :ivar type: Resource type. :vartype type: str - :param location: Resource location + :param location: Resource location. :type location: str - :param tags: Resource tags + :param tags: A set of tags. Resource tags. :type tags: dict[str, str] """ @@ -669,7 +741,10 @@ class Resource(Model): 'tags': {'key': 'tags', 'type': '{str}'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -681,18 +756,17 @@ def __init__(self, **kwargs): class GenericResource(Resource): """Resource information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID + :ivar id: Resource ID. :vartype id: str - :ivar name: Resource name + :ivar name: Resource name. :vartype name: str - :ivar type: Resource type + :ivar type: Resource type. :vartype type: str - :param location: Resource location + :param location: Resource location. :type location: str - :param tags: Resource tags + :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 @@ -729,7 +803,10 @@ class GenericResource(Resource): 'identity': {'key': 'identity', 'type': 'Identity'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(GenericResource, self).__init__(**kwargs) self.plan = kwargs.get('plan', None) self.properties = kwargs.get('properties', None) @@ -742,18 +819,17 @@ def __init__(self, **kwargs): class GenericResourceExpanded(GenericResource): """Resource information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID + :ivar id: Resource ID. :vartype id: str - :ivar name: Resource name + :ivar name: Resource name. :vartype name: str - :ivar type: Resource type + :ivar type: Resource type. :vartype type: str - :param location: Resource location + :param location: Resource location. :type location: str - :param tags: Resource tags + :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 @@ -767,14 +843,14 @@ class GenericResourceExpanded(GenericResource): :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 created_time: The created time of the resource. This is only present - if requested via the $expand query parameter. - :vartype created_time: datetime - :ivar changed_time: The changed time of the resource. This is only present - if requested via the $expand query parameter. - :vartype changed_time: datetime - :ivar provisioning_state: The provisioning state of the resource. This is - only present if requested via the $expand query parameter. + :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 + :ivar changed_time: The changed time of the resource. This is only present if requested via the + $expand query parameter. + :vartype changed_time: ~datetime.datetime + :ivar provisioning_state: The provisioning state of the resource. This is only present if + requested via the $expand query parameter. :vartype provisioning_state: str """ @@ -805,14 +881,17 @@ class GenericResourceExpanded(GenericResource): 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(GenericResourceExpanded, self).__init__(**kwargs) self.created_time = None self.changed_time = None self.provisioning_state = None -class GenericResourceFilter(Model): +class GenericResourceFilter(msrest.serialization.Model): """Resource filter. :param resource_type: The resource type. @@ -829,14 +908,17 @@ class GenericResourceFilter(Model): 'tagvalue': {'key': 'tagvalue', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(GenericResourceFilter, self).__init__(**kwargs) self.resource_type = kwargs.get('resource_type', None) self.tagname = kwargs.get('tagname', None) self.tagvalue = kwargs.get('tagvalue', None) -class HttpMessage(Model): +class HttpMessage(msrest.serialization.Model): """HTTP message. :param content: HTTP message content. @@ -847,31 +929,31 @@ class HttpMessage(Model): 'content': {'key': 'content', 'type': 'object'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(HttpMessage, self).__init__(**kwargs) self.content = kwargs.get('content', None) -class Identity(Model): +class Identity(msrest.serialization.Model): """Identity for the resource. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar principal_id: The principal ID of resource identity. :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :param 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 user identity dictionary key references will be ARM - resource ids in the form: + :param 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 + 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, - ~azure.mgmt.resource.resources.v2019_05_01.models.IdentityUserAssignedIdentitiesValue] + ~azure.mgmt.resource.resources.v2019_05_01.models.ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties] """ _validation = { @@ -882,11 +964,14 @@ class Identity(Model): _attribute_map = { 'principal_id': {'key': 'principalId', 'type': 'str'}, 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'ResourceIdentityType'}, - 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{IdentityUserAssignedIdentitiesValue}'}, + 'type': {'key': 'type', 'type': 'str'}, + 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties}'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Identity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None @@ -894,71 +979,40 @@ def __init__(self, **kwargs): self.user_assigned_identities = kwargs.get('user_assigned_identities', None) -class IdentityUserAssignedIdentitiesValue(Model): - """IdentityUserAssignedIdentitiesValue. - - Variables are only populated by the server, and will be ignored when - sending a request. - - :ivar principal_id: The principal id of user assigned identity. - :vartype principal_id: str - :ivar client_id: The client id of user assigned identity. - :vartype client_id: str - """ - - _validation = { - 'principal_id': {'readonly': True}, - 'client_id': {'readonly': True}, - } - - _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'client_id': {'key': 'clientId', 'type': 'str'}, - } - - def __init__(self, **kwargs): - super(IdentityUserAssignedIdentitiesValue, self).__init__(**kwargs) - self.principal_id = None - self.client_id = None - - -class OnErrorDeployment(Model): +class OnErrorDeployment(msrest.serialization.Model): """Deployment on error behavior. - :param 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 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 """ _attribute_map = { - 'type': {'key': 'type', 'type': 'OnErrorDeploymentType'}, + 'type': {'key': 'type', 'type': 'str'}, 'deployment_name': {'key': 'deploymentName', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(OnErrorDeployment, self).__init__(**kwargs) self.type = kwargs.get('type', None) self.deployment_name = kwargs.get('deployment_name', None) -class OnErrorDeploymentExtended(Model): +class OnErrorDeploymentExtended(msrest.serialization.Model): """Deployment on error behavior with additional details. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar provisioning_state: The state of the provisioning for the on error - deployment. + :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 SpecificDeployment. Possible values include: - 'LastSuccessful', 'SpecificDeployment' - :type type: str or - ~azure.mgmt.resource.resources.v2019_05_01.models.OnErrorDeploymentType + :param 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 """ @@ -969,25 +1023,27 @@ class OnErrorDeploymentExtended(Model): _attribute_map = { 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'OnErrorDeploymentType'}, + 'type': {'key': 'type', 'type': 'str'}, 'deployment_name': {'key': 'deploymentName', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(OnErrorDeploymentExtended, self).__init__(**kwargs) self.provisioning_state = None self.type = kwargs.get('type', None) self.deployment_name = kwargs.get('deployment_name', None) -class Operation(Model): +class Operation(msrest.serialization.Model): """Microsoft.Resources operation. - :param name: Operation name: {provider}/{resource}/{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 + :type display: ~azure.mgmt.resource.resources.v2019_05_01.models.OperationDisplay """ _attribute_map = { @@ -995,19 +1051,21 @@ class Operation(Model): 'display': {'key': 'display', 'type': 'OperationDisplay'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Operation, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.display = kwargs.get('display', None) -class OperationDisplay(Model): +class OperationDisplay(msrest.serialization.Model): """The object that represents the operation. - :param provider: Service provider: Microsoft.Resources + :param provider: Service provider: Microsoft.Resources. :type provider: str - :param resource: Resource on which the operation is performed: Profile, - endpoint, etc. + :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 @@ -1022,7 +1080,10 @@ class OperationDisplay(Model): 'description': {'key': 'description', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(OperationDisplay, self).__init__(**kwargs) self.provider = kwargs.get('provider', None) self.resource = kwargs.get('resource', None) @@ -1030,15 +1091,37 @@ def __init__(self, **kwargs): self.description = kwargs.get('description', None) -class ParametersLink(Model): +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 + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Operation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(OperationListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class ParametersLink(msrest.serialization.Model): """Entity representing the reference to the deployment parameters. 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. + :param content_version: If included, must match the ContentVersion in the template. :type content_version: str """ @@ -1051,13 +1134,16 @@ class ParametersLink(Model): 'content_version': {'key': 'contentVersion', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ParametersLink, self).__init__(**kwargs) - self.uri = kwargs.get('uri', None) + self.uri = kwargs['uri'] self.content_version = kwargs.get('content_version', None) -class Plan(Model): +class Plan(msrest.serialization.Model): """Plan for the resource. :param name: The plan ID. @@ -1080,7 +1166,10 @@ class Plan(Model): 'version': {'key': 'version', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Plan, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.publisher = kwargs.get('publisher', None) @@ -1089,11 +1178,10 @@ def __init__(self, **kwargs): self.version = kwargs.get('version', None) -class Provider(Model): +class Provider(msrest.serialization.Model): """Resource provider information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The provider ID. :vartype id: str @@ -1101,8 +1189,7 @@ class Provider(Model): :type 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. + :ivar registration_policy: The registration policy of the resource provider. :vartype registration_policy: str :ivar resource_types: The collection of provider resource types. :vartype resource_types: @@ -1124,7 +1211,10 @@ class Provider(Model): 'resource_types': {'key': 'resourceTypes', 'type': '[ProviderResourceType]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Provider, self).__init__(**kwargs) self.id = None self.namespace = kwargs.get('namespace', None) @@ -1133,21 +1223,47 @@ def __init__(self, **kwargs): self.resource_types = None -class ProviderResourceType(Model): +class ProviderListResult(msrest.serialization.Model): + """List of resource providers. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Provider]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ProviderListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = None + + +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. + :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] + :type aliases: list[~azure.mgmt.resource.resources.v2019_05_01.models.AliasType] :param api_versions: The API version. :type api_versions: list[str] - :param capabilities: The additional capabilities offered by this resource - type. + :param capabilities: The additional capabilities offered by this resource type. :type capabilities: str :param properties: The properties. :type properties: dict[str, str] @@ -1162,7 +1278,10 @@ class ProviderResourceType(Model): 'properties': {'key': 'properties', 'type': '{str}'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ProviderResourceType, self).__init__(**kwargs) self.resource_type = kwargs.get('resource_type', None) self.locations = kwargs.get('locations', None) @@ -1172,11 +1291,10 @@ def __init__(self, **kwargs): self.properties = kwargs.get('properties', None) -class ResourceGroup(Model): +class ResourceGroup(msrest.serialization.Model): """Resource group information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. @@ -1187,16 +1305,13 @@ class ResourceGroup(Model): :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 resource group has been created. It must be one of - the supported Azure locations. + :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 + 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. + :param managed_by: The ID of the resource that manages this resource group. :type managed_by: str - :param tags: The tags attached to the resource group. + :param tags: A set of tags. The tags attached to the resource group. :type tags: dict[str, str] """ @@ -1217,18 +1332,21 @@ class ResourceGroup(Model): 'tags': {'key': 'tags', 'type': '{str}'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ResourceGroup, self).__init__(**kwargs) self.id = None self.name = None self.type = None self.properties = kwargs.get('properties', None) - self.location = kwargs.get('location', None) + self.location = kwargs['location'] self.managed_by = kwargs.get('managed_by', None) self.tags = kwargs.get('tags', None) -class ResourceGroupExportResult(Model): +class ResourceGroupExportResult(msrest.serialization.Model): """Resource group export result. :param template: The template content. @@ -1243,13 +1361,16 @@ class ResourceGroupExportResult(Model): 'error': {'key': 'error', 'type': 'ResourceManagementErrorWithDetails'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ResourceGroupExportResult, self).__init__(**kwargs) self.template = kwargs.get('template', None) self.error = kwargs.get('error', None) -class ResourceGroupFilter(Model): +class ResourceGroupFilter(msrest.serialization.Model): """Resource group filter. :param tag_name: The tag name. @@ -1263,24 +1384,54 @@ class ResourceGroupFilter(Model): 'tag_value': {'key': 'tagValue', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ResourceGroupFilter, self).__init__(**kwargs) self.tag_name = kwargs.get('tag_name', None) self.tag_value = kwargs.get('tag_value', None) -class ResourceGroupPatchable(Model): +class ResourceGroupListResult(msrest.serialization.Model): + """List of resource groups. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ResourceGroup]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ResourceGroupListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = None + + +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 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: The tags attached to the resource group. + :param tags: A set of tags. The tags attached to the resource group. :type tags: dict[str, str] """ @@ -1291,7 +1442,10 @@ class ResourceGroupPatchable(Model): 'tags': {'key': 'tags', 'type': '{str}'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ResourceGroupPatchable, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.properties = kwargs.get('properties', None) @@ -1299,11 +1453,10 @@ def __init__(self, **kwargs): self.tags = kwargs.get('tags', None) -class ResourceGroupProperties(Model): +class ResourceGroupProperties(msrest.serialization.Model): """The resource group properties. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar provisioning_state: The provisioning state. :vartype provisioning_state: str @@ -1317,16 +1470,47 @@ class ResourceGroupProperties(Model): 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ResourceGroupProperties, self).__init__(**kwargs) self.provisioning_state = None -class ResourceManagementErrorWithDetails(Model): +class ResourceListResult(msrest.serialization.Model): + """List of resource groups. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[GenericResourceExpanded]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ResourceListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = None + + +class ResourceManagementErrorWithDetails(msrest.serialization.Model): """The detailed error message of resource management. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar code: The error code returned when exporting the template. :vartype code: str @@ -1353,7 +1537,10 @@ class ResourceManagementErrorWithDetails(Model): 'details': {'key': 'details', 'type': '[ResourceManagementErrorWithDetails]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ResourceManagementErrorWithDetails, self).__init__(**kwargs) self.code = None self.message = None @@ -1361,7 +1548,7 @@ def __init__(self, **kwargs): self.details = None -class ResourceProviderOperationDisplayProperties(Model): +class ResourceProviderOperationDisplayProperties(msrest.serialization.Model): """Resource provider operation's display properties. :param publisher: Operation description. @@ -1384,7 +1571,10 @@ class ResourceProviderOperationDisplayProperties(Model): 'description': {'key': 'description', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ResourceProviderOperationDisplayProperties, self).__init__(**kwargs) self.publisher = kwargs.get('publisher', None) self.provider = kwargs.get('provider', None) @@ -1393,7 +1583,7 @@ def __init__(self, **kwargs): self.description = kwargs.get('description', None) -class ResourcesMoveInfo(Model): +class ResourcesMoveInfo(msrest.serialization.Model): """Parameters of move resources. :param resources: The IDs of the resources. @@ -1407,13 +1597,16 @@ class ResourcesMoveInfo(Model): 'target_resource_group': {'key': 'targetResourceGroup', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ResourcesMoveInfo, self).__init__(**kwargs) self.resources = kwargs.get('resources', None) self.target_resource_group = kwargs.get('target_resource_group', None) -class Sku(Model): +class Sku(msrest.serialization.Model): """SKU for the resource. :param name: The SKU name. @@ -1439,7 +1632,10 @@ class Sku(Model): 'capacity': {'key': 'capacity', 'type': 'int'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Sku, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.tier = kwargs.get('tier', None) @@ -1449,10 +1645,10 @@ def __init__(self, **kwargs): self.capacity = kwargs.get('capacity', None) -class SubResource(Model): +class SubResource(msrest.serialization.Model): """Sub-resource. - :param id: Resource ID + :param id: Resource ID. :type id: str """ @@ -1460,12 +1656,15 @@ class SubResource(Model): 'id': {'key': 'id', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(SubResource, self).__init__(**kwargs) self.id = kwargs.get('id', None) -class TagCount(Model): +class TagCount(msrest.serialization.Model): """Tag count. :param type: Type of count. @@ -1479,29 +1678,29 @@ class TagCount(Model): 'value': {'key': 'value', 'type': 'int'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(TagCount, self).__init__(**kwargs) self.type = kwargs.get('type', None) self.value = kwargs.get('value', None) -class TagDetails(Model): +class TagDetails(msrest.serialization.Model): """Tag details. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :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 created and has no associated resources, the value - is 0. + :param 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] + :type values: list[~azure.mgmt.resource.resources.v2019_05_01.models.TagValue] """ _validation = { @@ -1515,7 +1714,10 @@ class TagDetails(Model): 'values': {'key': 'values', 'type': '[TagValue]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(TagDetails, self).__init__(**kwargs) self.id = None self.tag_name = kwargs.get('tag_name', None) @@ -1523,11 +1725,39 @@ def __init__(self, **kwargs): self.values = kwargs.get('values', None) -class TagValue(Model): +class TagsListResult(msrest.serialization.Model): + """List of subscription tags. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[TagDetails]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(TagsListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = None + + +class TagValue(msrest.serialization.Model): """Tag information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The tag ID. :vartype id: str @@ -1547,14 +1777,17 @@ class TagValue(Model): 'count': {'key': 'count', 'type': 'TagCount'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(TagValue, self).__init__(**kwargs) self.id = None self.tag_value = kwargs.get('tag_value', None) self.count = kwargs.get('count', None) -class TargetResource(Model): +class TargetResource(msrest.serialization.Model): """Target resource. :param id: The ID of the resource. @@ -1571,16 +1804,18 @@ class TargetResource(Model): 'resource_type': {'key': 'resourceType', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(TargetResource, self).__init__(**kwargs) self.id = kwargs.get('id', None) self.resource_name = kwargs.get('resource_name', None) self.resource_type = kwargs.get('resource_type', None) -class TemplateHashResult(Model): - """Result of the request to calculate template hash. It contains a string of - minified template and its hash. +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 @@ -1593,21 +1828,23 @@ class TemplateHashResult(Model): 'template_hash': {'key': 'templateHash', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(TemplateHashResult, self).__init__(**kwargs) self.minified_template = kwargs.get('minified_template', None) self.template_hash = kwargs.get('template_hash', None) -class TemplateLink(Model): +class TemplateLink(msrest.serialization.Model): """Entity representing the reference to the template. 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. + :param content_version: If included, must match the ContentVersion in the template. :type content_version: str """ @@ -1620,7 +1857,10 @@ class TemplateLink(Model): 'content_version': {'key': 'contentVersion', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(TemplateLink, self).__init__(**kwargs) - self.uri = kwargs.get('uri', None) + self.uri = kwargs['uri'] self.content_version = kwargs.get('content_version', 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 242c8e9a858d..546422b9c18f 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 @@ -1,20 +1,20 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.serialization import Model -from msrest.exceptions import HttpOperationError +from typing import Dict, List, Optional, Union +import msrest.serialization -class AliasPathType(Model): - """The type of the paths for alias. . +from ._resource_management_client_enums import * + + +class AliasPathType(msrest.serialization.Model): + """The type of the paths for alias. :param path: The path of an alias. :type path: str @@ -27,20 +27,25 @@ class AliasPathType(Model): 'api_versions': {'key': 'apiVersions', 'type': '[str]'}, } - def __init__(self, *, path: str=None, api_versions=None, **kwargs) -> None: + def __init__( + self, + *, + path: Optional[str] = None, + api_versions: Optional[List[str]] = None, + **kwargs + ): super(AliasPathType, self).__init__(**kwargs) self.path = path self.api_versions = api_versions -class AliasType(Model): - """The alias type. . +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] + :type paths: list[~azure.mgmt.resource.resources.v2019_05_01.models.AliasPathType] """ _attribute_map = { @@ -48,13 +53,19 @@ class AliasType(Model): 'paths': {'key': 'paths', 'type': '[AliasPathType]'}, } - def __init__(self, *, name: str=None, paths=None, **kwargs) -> None: + def __init__( + self, + *, + name: Optional[str] = None, + paths: Optional[List["AliasPathType"]] = None, + **kwargs + ): super(AliasType, self).__init__(**kwargs) self.name = name self.paths = paths -class BasicDependency(Model): +class BasicDependency(msrest.serialization.Model): """Deployment dependency information. :param id: The ID of the dependency. @@ -71,52 +82,59 @@ class BasicDependency(Model): 'resource_name': {'key': 'resourceName', 'type': 'str'}, } - def __init__(self, *, id: str=None, resource_type: str=None, resource_name: str=None, **kwargs) -> None: + def __init__( + self, + *, + id: Optional[str] = None, + resource_type: Optional[str] = None, + resource_name: Optional[str] = None, + **kwargs + ): super(BasicDependency, self).__init__(**kwargs) self.id = id self.resource_type = resource_type self.resource_name = resource_name -class CloudError(Model): - """An error response for a resource management request. +class ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties(msrest.serialization.Model): + """ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties. - :param error: - :type error: - ~azure.mgmt.resource.resources.v2019_05_01.models.ErrorResponse + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar principal_id: The principal id of user assigned identity. + :vartype principal_id: str + :ivar client_id: The client id of user assigned identity. + :vartype client_id: str """ - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorResponse'}, + _validation = { + 'principal_id': {'readonly': True}, + 'client_id': {'readonly': True}, } - def __init__(self, *, error=None, **kwargs) -> None: - super(CloudError, self).__init__(**kwargs) - self.error = error - - -class CloudErrorException(HttpOperationError): - """Server responsed with exception of type: 'CloudError'. - - :param deserialize: A deserializer - :param response: Server response to be deserialized. - """ - - def __init__(self, deserialize, response, *args): + _attribute_map = { + 'principal_id': {'key': 'principalId', 'type': 'str'}, + 'client_id': {'key': 'clientId', 'type': 'str'}, + } - super(CloudErrorException, self).__init__(deserialize, response, 'CloudError', *args) + def __init__( + self, + **kwargs + ): + super(ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties, self).__init__(**kwargs) + self.principal_id = None + self.client_id = None -class DebugSetting(Model): +class DebugSetting(msrest.serialization.Model): """The debug setting. - :param 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. + :param 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 """ @@ -124,17 +142,21 @@ class DebugSetting(Model): 'detail_level': {'key': 'detailLevel', 'type': 'str'}, } - def __init__(self, *, detail_level: str=None, **kwargs) -> None: + def __init__( + self, + *, + detail_level: Optional[str] = None, + **kwargs + ): super(DebugSetting, self).__init__(**kwargs) self.detail_level = detail_level -class Dependency(Model): +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] + :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. @@ -150,7 +172,15 @@ class Dependency(Model): 'resource_name': {'key': 'resourceName', 'type': 'str'}, } - def __init__(self, *, depends_on=None, id: str=None, resource_type: str=None, resource_name: str=None, **kwargs) -> None: + def __init__( + self, + *, + depends_on: Optional[List["BasicDependency"]] = None, + id: Optional[str] = None, + resource_type: Optional[str] = None, + resource_name: Optional[str] = None, + **kwargs + ): super(Dependency, self).__init__(**kwargs) self.depends_on = depends_on self.id = id @@ -158,7 +188,7 @@ def __init__(self, *, depends_on=None, id: str=None, resource_type: str=None, re self.resource_name = resource_name -class Deployment(Model): +class Deployment(msrest.serialization.Model): """Deployment operation parameters. All required parameters must be populated in order to send to Azure. @@ -166,8 +196,7 @@ class Deployment(Model): :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 + :type properties: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentProperties """ _validation = { @@ -179,14 +208,20 @@ class Deployment(Model): 'properties': {'key': 'properties', 'type': 'DeploymentProperties'}, } - def __init__(self, *, properties, location: str=None, **kwargs) -> None: + def __init__( + self, + *, + properties: "DeploymentProperties", + location: Optional[str] = None, + **kwargs + ): super(Deployment, self).__init__(**kwargs) self.location = location self.properties = properties -class DeploymentExportResult(Model): - """The deployment export result. . +class DeploymentExportResult(msrest.serialization.Model): + """The deployment export result. :param template: The template content. :type template: object @@ -196,16 +231,20 @@ class DeploymentExportResult(Model): 'template': {'key': 'template', 'type': 'object'}, } - def __init__(self, *, template=None, **kwargs) -> None: + def __init__( + self, + *, + template: Optional[object] = None, + **kwargs + ): super(DeploymentExportResult, self).__init__(**kwargs) self.template = template -class DeploymentExtended(Model): +class DeploymentExtended(msrest.serialization.Model): """Deployment information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The ID of the deployment. :vartype id: str @@ -234,7 +273,13 @@ class DeploymentExtended(Model): 'properties': {'key': 'properties', 'type': 'DeploymentPropertiesExtended'}, } - def __init__(self, *, location: str=None, properties=None, **kwargs) -> None: + def __init__( + self, + *, + location: Optional[str] = None, + properties: Optional["DeploymentPropertiesExtended"] = None, + **kwargs + ): super(DeploymentExtended, self).__init__(**kwargs) self.id = None self.name = None @@ -243,7 +288,7 @@ def __init__(self, *, location: str=None, properties=None, **kwargs) -> None: self.properties = properties -class DeploymentExtendedFilter(Model): +class DeploymentExtendedFilter(msrest.serialization.Model): """Deployment filter. :param provisioning_state: The provisioning state. @@ -254,16 +299,51 @@ class DeploymentExtendedFilter(Model): 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, } - def __init__(self, *, provisioning_state: str=None, **kwargs) -> None: + def __init__( + self, + *, + provisioning_state: Optional[str] = None, + **kwargs + ): super(DeploymentExtendedFilter, self).__init__(**kwargs) self.provisioning_state = provisioning_state -class DeploymentOperation(Model): +class DeploymentListResult(msrest.serialization.Model): + """List of deployments. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[DeploymentExtended]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["DeploymentExtended"]] = None, + **kwargs + ): + super(DeploymentListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class DeploymentOperation(msrest.serialization.Model): """Deployment operation information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Full deployment operation ID. :vartype id: str @@ -285,23 +365,27 @@ class DeploymentOperation(Model): 'properties': {'key': 'properties', 'type': 'DeploymentOperationProperties'}, } - def __init__(self, *, properties=None, **kwargs) -> None: + def __init__( + self, + *, + properties: Optional["DeploymentOperationProperties"] = None, + **kwargs + ): super(DeploymentOperation, self).__init__(**kwargs) self.id = None self.operation_id = None self.properties = properties -class DeploymentOperationProperties(Model): +class DeploymentOperationProperties(msrest.serialization.Model): """Deployment operation properties. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar provisioning_state: The state of the provisioning. :vartype provisioning_state: str :ivar timestamp: The date and time of the operation. - :vartype timestamp: datetime + :vartype timestamp: ~datetime.datetime :ivar duration: The duration of the operation. :vartype duration: str :ivar service_request_id: Deployment operation service request id. @@ -311,14 +395,11 @@ class DeploymentOperationProperties(Model): :ivar status_message: Operation status message. :vartype status_message: object :ivar target_resource: The target resource. - :vartype target_resource: - ~azure.mgmt.resource.resources.v2019_05_01.models.TargetResource + :vartype target_resource: ~azure.mgmt.resource.resources.v2019_05_01.models.TargetResource :ivar request: The HTTP request message. - :vartype request: - ~azure.mgmt.resource.resources.v2019_05_01.models.HttpMessage + :vartype request: ~azure.mgmt.resource.resources.v2019_05_01.models.HttpMessage :ivar response: The HTTP response message. - :vartype response: - ~azure.mgmt.resource.resources.v2019_05_01.models.HttpMessage + :vartype response: ~azure.mgmt.resource.resources.v2019_05_01.models.HttpMessage """ _validation = { @@ -345,7 +426,10 @@ class DeploymentOperationProperties(Model): 'response': {'key': 'response', 'type': 'HttpMessage'}, } - def __init__(self, **kwargs) -> None: + def __init__( + self, + **kwargs + ): super(DeploymentOperationProperties, self).__init__(**kwargs) self.provisioning_state = None self.timestamp = None @@ -358,48 +442,70 @@ def __init__(self, **kwargs) -> None: self.response = None -class DeploymentProperties(Model): +class DeploymentOperationsListResult(msrest.serialization.Model): + """List of deployment operations. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[DeploymentOperation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["DeploymentOperation"]] = None, + **kwargs + ): + super(DeploymentOperationsListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class DeploymentProperties(msrest.serialization.Model): """Deployment properties. 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 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. + :param 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: object - :param 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. 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. + :param 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. + 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: object - :param 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 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 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 + 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 + :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 + :type on_error_deployment: ~azure.mgmt.resource.resources.v2019_05_01.models.OnErrorDeployment """ _validation = { @@ -411,12 +517,23 @@ class DeploymentProperties(Model): 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, 'parameters': {'key': 'parameters', 'type': 'object'}, 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, - 'mode': {'key': 'mode', 'type': 'DeploymentMode'}, + 'mode': {'key': 'mode', 'type': 'str'}, 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, 'on_error_deployment': {'key': 'onErrorDeployment', 'type': 'OnErrorDeployment'}, } - def __init__(self, *, mode, template=None, template_link=None, parameters=None, parameters_link=None, debug_setting=None, on_error_deployment=None, **kwargs) -> None: + def __init__( + self, + *, + mode: Union[str, "DeploymentMode"], + template: Optional[object] = None, + template_link: Optional["TemplateLink"] = None, + parameters: Optional[object] = None, + parameters_link: Optional["ParametersLink"] = None, + debug_setting: Optional["DebugSetting"] = None, + on_error_deployment: Optional["OnErrorDeployment"] = None, + **kwargs + ): super(DeploymentProperties, self).__init__(**kwargs) self.template = template self.template_link = template_link @@ -427,50 +544,40 @@ def __init__(self, *, mode, template=None, template_link=None, parameters=None, self.on_error_deployment = on_error_deployment -class DeploymentPropertiesExtended(Model): +class DeploymentPropertiesExtended(msrest.serialization.Model): """Deployment properties with additional details. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :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 + :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: object - :param providers: The list of resource providers needed for the - deployment. - :type providers: - list[~azure.mgmt.resource.resources.v2019_05_01.models.Provider] + :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 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: object - :param 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. + :param 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: object - :param 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 include: 'Incremental', 'Complete' - :type mode: str or - ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentMode + :param 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 + 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 + :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.OnErrorDeploymentExtended @@ -495,12 +602,26 @@ class DeploymentPropertiesExtended(Model): 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, 'parameters': {'key': 'parameters', 'type': 'object'}, 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, - 'mode': {'key': 'mode', 'type': 'DeploymentMode'}, + 'mode': {'key': 'mode', 'type': 'str'}, 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, 'on_error_deployment': {'key': 'onErrorDeployment', 'type': 'OnErrorDeploymentExtended'}, } - def __init__(self, *, outputs=None, providers=None, dependencies=None, template=None, template_link=None, parameters=None, parameters_link=None, mode=None, debug_setting=None, on_error_deployment=None, **kwargs) -> None: + def __init__( + self, + *, + outputs: Optional[object] = None, + providers: Optional[List["Provider"]] = None, + dependencies: Optional[List["Dependency"]] = None, + template: Optional[object] = None, + template_link: Optional["TemplateLink"] = None, + parameters: Optional[object] = None, + parameters_link: Optional["ParametersLink"] = None, + mode: Optional[Union[str, "DeploymentMode"]] = None, + debug_setting: Optional["DebugSetting"] = None, + on_error_deployment: Optional["OnErrorDeploymentExtended"] = None, + **kwargs + ): super(DeploymentPropertiesExtended, self).__init__(**kwargs) self.provisioning_state = None self.correlation_id = None @@ -518,7 +639,7 @@ def __init__(self, *, outputs=None, providers=None, dependencies=None, template= self.on_error_deployment = on_error_deployment -class DeploymentValidateResult(Model): +class DeploymentValidateResult(msrest.serialization.Model): """Information from validate template deployment response. :param error: Validation error. @@ -534,17 +655,22 @@ class DeploymentValidateResult(Model): 'properties': {'key': 'properties', 'type': 'DeploymentPropertiesExtended'}, } - def __init__(self, *, error=None, properties=None, **kwargs) -> None: + def __init__( + self, + *, + error: Optional["ResourceManagementErrorWithDetails"] = None, + properties: Optional["DeploymentPropertiesExtended"] = None, + **kwargs + ): super(DeploymentValidateResult, self).__init__(**kwargs) self.error = error self.properties = properties -class ErrorAdditionalInfo(Model): +class ErrorAdditionalInfo(msrest.serialization.Model): """The resource management error additional info. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar type: The additional info type. :vartype type: str @@ -562,17 +688,19 @@ class ErrorAdditionalInfo(Model): 'info': {'key': 'info', 'type': 'object'}, } - def __init__(self, **kwargs) -> None: + def __init__( + self, + **kwargs + ): super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None -class ErrorResponse(Model): +class ErrorResponse(msrest.serialization.Model): """The resource management error response. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar code: The error code. :vartype code: str @@ -581,8 +709,7 @@ class ErrorResponse(Model): :ivar target: The error target. :vartype target: str :ivar details: The error details. - :vartype details: - list[~azure.mgmt.resource.resources.v2019_05_01.models.ErrorResponse] + :vartype details: list[~azure.mgmt.resource.resources.v2019_05_01.models.ErrorResponse] :ivar additional_info: The error additional info. :vartype additional_info: list[~azure.mgmt.resource.resources.v2019_05_01.models.ErrorAdditionalInfo] @@ -604,7 +731,10 @@ class ErrorResponse(Model): 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, } - def __init__(self, **kwargs) -> None: + def __init__( + self, + **kwargs + ): super(ErrorResponse, self).__init__(**kwargs) self.code = None self.message = None @@ -613,16 +743,15 @@ def __init__(self, **kwargs) -> None: self.additional_info = None -class ExportTemplateRequest(Model): +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, supply an array with single entry '*'. + :param 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', 'SkipResourceNameParameterization', - 'SkipAllParameterization' + :param options: The export template options. A CSV-formatted list containing zero or more of + the following: 'IncludeParameterDefaultValue', 'IncludeComments', + 'SkipResourceNameParameterization', 'SkipAllParameterization'. :type options: str """ @@ -631,27 +760,32 @@ class ExportTemplateRequest(Model): 'options': {'key': 'options', 'type': 'str'}, } - def __init__(self, *, resources=None, options: str=None, **kwargs) -> None: + def __init__( + self, + *, + resources: Optional[List[str]] = None, + options: Optional[str] = None, + **kwargs + ): super(ExportTemplateRequest, self).__init__(**kwargs) self.resources = resources self.options = options -class Resource(Model): +class Resource(msrest.serialization.Model): """Specified resource. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID + :ivar id: Resource ID. :vartype id: str - :ivar name: Resource name + :ivar name: Resource name. :vartype name: str - :ivar type: Resource type + :ivar type: Resource type. :vartype type: str - :param location: Resource location + :param location: Resource location. :type location: str - :param tags: Resource tags + :param tags: A set of tags. Resource tags. :type tags: dict[str, str] """ @@ -669,7 +803,13 @@ class Resource(Model): 'tags': {'key': 'tags', 'type': '{str}'}, } - def __init__(self, *, location: str=None, tags=None, **kwargs) -> None: + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -681,18 +821,17 @@ def __init__(self, *, location: str=None, tags=None, **kwargs) -> None: class GenericResource(Resource): """Resource information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID + :ivar id: Resource ID. :vartype id: str - :ivar name: Resource name + :ivar name: Resource name. :vartype name: str - :ivar type: Resource type + :ivar type: Resource type. :vartype type: str - :param location: Resource location + :param location: Resource location. :type location: str - :param tags: Resource tags + :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 @@ -729,7 +868,19 @@ class GenericResource(Resource): 'identity': {'key': 'identity', 'type': 'Identity'}, } - def __init__(self, *, location: str=None, tags=None, plan=None, properties=None, kind: str=None, managed_by: str=None, sku=None, identity=None, **kwargs) -> None: + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + plan: Optional["Plan"] = None, + properties: Optional[object] = None, + kind: Optional[str] = None, + managed_by: Optional[str] = None, + sku: Optional["Sku"] = None, + identity: Optional["Identity"] = None, + **kwargs + ): super(GenericResource, self).__init__(location=location, tags=tags, **kwargs) self.plan = plan self.properties = properties @@ -742,18 +893,17 @@ def __init__(self, *, location: str=None, tags=None, plan=None, properties=None, class GenericResourceExpanded(GenericResource): """Resource information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID + :ivar id: Resource ID. :vartype id: str - :ivar name: Resource name + :ivar name: Resource name. :vartype name: str - :ivar type: Resource type + :ivar type: Resource type. :vartype type: str - :param location: Resource location + :param location: Resource location. :type location: str - :param tags: Resource tags + :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 @@ -767,14 +917,14 @@ class GenericResourceExpanded(GenericResource): :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 created_time: The created time of the resource. This is only present - if requested via the $expand query parameter. - :vartype created_time: datetime - :ivar changed_time: The changed time of the resource. This is only present - if requested via the $expand query parameter. - :vartype changed_time: datetime - :ivar provisioning_state: The provisioning state of the resource. This is - only present if requested via the $expand query parameter. + :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 + :ivar changed_time: The changed time of the resource. This is only present if requested via the + $expand query parameter. + :vartype changed_time: ~datetime.datetime + :ivar provisioning_state: The provisioning state of the resource. This is only present if + requested via the $expand query parameter. :vartype provisioning_state: str """ @@ -805,14 +955,26 @@ class GenericResourceExpanded(GenericResource): 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, } - def __init__(self, *, location: str=None, tags=None, plan=None, properties=None, kind: str=None, managed_by: str=None, sku=None, identity=None, **kwargs) -> None: + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + plan: Optional["Plan"] = None, + properties: Optional[object] = None, + kind: Optional[str] = None, + managed_by: Optional[str] = None, + sku: Optional["Sku"] = None, + identity: Optional["Identity"] = None, + **kwargs + ): 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 self.provisioning_state = None -class GenericResourceFilter(Model): +class GenericResourceFilter(msrest.serialization.Model): """Resource filter. :param resource_type: The resource type. @@ -829,14 +991,21 @@ class GenericResourceFilter(Model): 'tagvalue': {'key': 'tagvalue', 'type': 'str'}, } - def __init__(self, *, resource_type: str=None, tagname: str=None, tagvalue: str=None, **kwargs) -> None: + def __init__( + self, + *, + resource_type: Optional[str] = None, + tagname: Optional[str] = None, + tagvalue: Optional[str] = None, + **kwargs + ): super(GenericResourceFilter, self).__init__(**kwargs) self.resource_type = resource_type self.tagname = tagname self.tagvalue = tagvalue -class HttpMessage(Model): +class HttpMessage(msrest.serialization.Model): """HTTP message. :param content: HTTP message content. @@ -847,31 +1016,33 @@ class HttpMessage(Model): 'content': {'key': 'content', 'type': 'object'}, } - def __init__(self, *, content=None, **kwargs) -> None: + def __init__( + self, + *, + content: Optional[object] = None, + **kwargs + ): super(HttpMessage, self).__init__(**kwargs) self.content = content -class Identity(Model): +class Identity(msrest.serialization.Model): """Identity for the resource. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar principal_id: The principal ID of resource identity. :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :param 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 user identity dictionary key references will be ARM - resource ids in the form: + :param 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 + 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, - ~azure.mgmt.resource.resources.v2019_05_01.models.IdentityUserAssignedIdentitiesValue] + ~azure.mgmt.resource.resources.v2019_05_01.models.ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties] """ _validation = { @@ -882,11 +1053,17 @@ class Identity(Model): _attribute_map = { 'principal_id': {'key': 'principalId', 'type': 'str'}, 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'ResourceIdentityType'}, - 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{IdentityUserAssignedIdentitiesValue}'}, + 'type': {'key': 'type', 'type': 'str'}, + 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties}'}, } - def __init__(self, *, type=None, user_assigned_identities=None, **kwargs) -> None: + def __init__( + self, + *, + type: Optional[Union[str, "ResourceIdentityType"]] = None, + user_assigned_identities: Optional[Dict[str, "ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties"]] = None, + **kwargs + ): super(Identity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None @@ -894,71 +1071,43 @@ def __init__(self, *, type=None, user_assigned_identities=None, **kwargs) -> Non self.user_assigned_identities = user_assigned_identities -class IdentityUserAssignedIdentitiesValue(Model): - """IdentityUserAssignedIdentitiesValue. - - Variables are only populated by the server, and will be ignored when - sending a request. - - :ivar principal_id: The principal id of user assigned identity. - :vartype principal_id: str - :ivar client_id: The client id of user assigned identity. - :vartype client_id: str - """ - - _validation = { - 'principal_id': {'readonly': True}, - 'client_id': {'readonly': True}, - } - - _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'client_id': {'key': 'clientId', 'type': 'str'}, - } - - def __init__(self, **kwargs) -> None: - super(IdentityUserAssignedIdentitiesValue, self).__init__(**kwargs) - self.principal_id = None - self.client_id = None - - -class OnErrorDeployment(Model): +class OnErrorDeployment(msrest.serialization.Model): """Deployment on error behavior. - :param 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 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 """ _attribute_map = { - 'type': {'key': 'type', 'type': 'OnErrorDeploymentType'}, + 'type': {'key': 'type', 'type': 'str'}, 'deployment_name': {'key': 'deploymentName', 'type': 'str'}, } - def __init__(self, *, type=None, deployment_name: str=None, **kwargs) -> None: + def __init__( + self, + *, + type: Optional[Union[str, "OnErrorDeploymentType"]] = None, + deployment_name: Optional[str] = None, + **kwargs + ): super(OnErrorDeployment, self).__init__(**kwargs) self.type = type self.deployment_name = deployment_name -class OnErrorDeploymentExtended(Model): +class OnErrorDeploymentExtended(msrest.serialization.Model): """Deployment on error behavior with additional details. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar provisioning_state: The state of the provisioning for the on error - deployment. + :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 SpecificDeployment. Possible values include: - 'LastSuccessful', 'SpecificDeployment' - :type type: str or - ~azure.mgmt.resource.resources.v2019_05_01.models.OnErrorDeploymentType + :param 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 """ @@ -969,25 +1118,30 @@ class OnErrorDeploymentExtended(Model): _attribute_map = { 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'OnErrorDeploymentType'}, + 'type': {'key': 'type', 'type': 'str'}, 'deployment_name': {'key': 'deploymentName', 'type': 'str'}, } - def __init__(self, *, type=None, deployment_name: str=None, **kwargs) -> None: + def __init__( + self, + *, + type: Optional[Union[str, "OnErrorDeploymentType"]] = None, + deployment_name: Optional[str] = None, + **kwargs + ): super(OnErrorDeploymentExtended, self).__init__(**kwargs) self.provisioning_state = None self.type = type self.deployment_name = deployment_name -class Operation(Model): +class Operation(msrest.serialization.Model): """Microsoft.Resources operation. - :param name: Operation name: {provider}/{resource}/{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 + :type display: ~azure.mgmt.resource.resources.v2019_05_01.models.OperationDisplay """ _attribute_map = { @@ -995,19 +1149,24 @@ class Operation(Model): 'display': {'key': 'display', 'type': 'OperationDisplay'}, } - def __init__(self, *, name: str=None, display=None, **kwargs) -> None: + def __init__( + self, + *, + name: Optional[str] = None, + display: Optional["OperationDisplay"] = None, + **kwargs + ): super(Operation, self).__init__(**kwargs) self.name = name self.display = display -class OperationDisplay(Model): +class OperationDisplay(msrest.serialization.Model): """The object that represents the operation. - :param provider: Service provider: Microsoft.Resources + :param provider: Service provider: Microsoft.Resources. :type provider: str - :param resource: Resource on which the operation is performed: Profile, - endpoint, etc. + :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 @@ -1022,7 +1181,15 @@ class OperationDisplay(Model): 'description': {'key': 'description', 'type': 'str'}, } - def __init__(self, *, provider: str=None, resource: str=None, operation: str=None, description: str=None, **kwargs) -> None: + def __init__( + self, + *, + provider: Optional[str] = None, + resource: Optional[str] = None, + operation: Optional[str] = None, + description: Optional[str] = None, + **kwargs + ): super(OperationDisplay, self).__init__(**kwargs) self.provider = provider self.resource = resource @@ -1030,15 +1197,40 @@ def __init__(self, *, provider: str=None, resource: str=None, operation: str=Non self.description = description -class ParametersLink(Model): +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 + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Operation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["Operation"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(OperationListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ParametersLink(msrest.serialization.Model): """Entity representing the reference to the deployment parameters. 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. + :param content_version: If included, must match the ContentVersion in the template. :type content_version: str """ @@ -1051,13 +1243,19 @@ class ParametersLink(Model): 'content_version': {'key': 'contentVersion', 'type': 'str'}, } - def __init__(self, *, uri: str, content_version: str=None, **kwargs) -> None: + def __init__( + self, + *, + uri: str, + content_version: Optional[str] = None, + **kwargs + ): super(ParametersLink, self).__init__(**kwargs) self.uri = uri self.content_version = content_version -class Plan(Model): +class Plan(msrest.serialization.Model): """Plan for the resource. :param name: The plan ID. @@ -1080,7 +1278,16 @@ class Plan(Model): 'version': {'key': 'version', 'type': 'str'}, } - def __init__(self, *, name: str=None, publisher: str=None, product: str=None, promotion_code: str=None, version: str=None, **kwargs) -> None: + def __init__( + self, + *, + name: Optional[str] = None, + publisher: Optional[str] = None, + product: Optional[str] = None, + promotion_code: Optional[str] = None, + version: Optional[str] = None, + **kwargs + ): super(Plan, self).__init__(**kwargs) self.name = name self.publisher = publisher @@ -1089,11 +1296,10 @@ def __init__(self, *, name: str=None, publisher: str=None, product: str=None, pr self.version = version -class Provider(Model): +class Provider(msrest.serialization.Model): """Resource provider information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The provider ID. :vartype id: str @@ -1101,8 +1307,7 @@ class Provider(Model): :type 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. + :ivar registration_policy: The registration policy of the resource provider. :vartype registration_policy: str :ivar resource_types: The collection of provider resource types. :vartype resource_types: @@ -1124,7 +1329,12 @@ class Provider(Model): 'resource_types': {'key': 'resourceTypes', 'type': '[ProviderResourceType]'}, } - def __init__(self, *, namespace: str=None, **kwargs) -> None: + def __init__( + self, + *, + namespace: Optional[str] = None, + **kwargs + ): super(Provider, self).__init__(**kwargs) self.id = None self.namespace = namespace @@ -1133,21 +1343,49 @@ def __init__(self, *, namespace: str=None, **kwargs) -> None: self.resource_types = None -class ProviderResourceType(Model): +class ProviderListResult(msrest.serialization.Model): + """List of resource providers. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Provider]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["Provider"]] = None, + **kwargs + ): + super(ProviderListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +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. + :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] + :type aliases: list[~azure.mgmt.resource.resources.v2019_05_01.models.AliasType] :param api_versions: The API version. :type api_versions: list[str] - :param capabilities: The additional capabilities offered by this resource - type. + :param capabilities: The additional capabilities offered by this resource type. :type capabilities: str :param properties: The properties. :type properties: dict[str, str] @@ -1162,7 +1400,17 @@ class ProviderResourceType(Model): 'properties': {'key': 'properties', 'type': '{str}'}, } - def __init__(self, *, resource_type: str=None, locations=None, aliases=None, api_versions=None, capabilities: str=None, properties=None, **kwargs) -> None: + def __init__( + self, + *, + resource_type: Optional[str] = None, + locations: Optional[List[str]] = None, + aliases: Optional[List["AliasType"]] = None, + api_versions: Optional[List[str]] = None, + capabilities: Optional[str] = None, + properties: Optional[Dict[str, str]] = None, + **kwargs + ): super(ProviderResourceType, self).__init__(**kwargs) self.resource_type = resource_type self.locations = locations @@ -1172,11 +1420,10 @@ def __init__(self, *, resource_type: str=None, locations=None, aliases=None, api self.properties = properties -class ResourceGroup(Model): +class ResourceGroup(msrest.serialization.Model): """Resource group information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. @@ -1187,16 +1434,13 @@ class ResourceGroup(Model): :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 resource group has been created. It must be one of - the supported Azure locations. + :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 + 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. + :param managed_by: The ID of the resource that manages this resource group. :type managed_by: str - :param tags: The tags attached to the resource group. + :param tags: A set of tags. The tags attached to the resource group. :type tags: dict[str, str] """ @@ -1217,7 +1461,15 @@ class ResourceGroup(Model): 'tags': {'key': 'tags', 'type': '{str}'}, } - def __init__(self, *, location: str, properties=None, managed_by: str=None, tags=None, **kwargs) -> None: + def __init__( + self, + *, + location: str, + properties: Optional["ResourceGroupProperties"] = None, + managed_by: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): super(ResourceGroup, self).__init__(**kwargs) self.id = None self.name = None @@ -1228,7 +1480,7 @@ def __init__(self, *, location: str, properties=None, managed_by: str=None, tags self.tags = tags -class ResourceGroupExportResult(Model): +class ResourceGroupExportResult(msrest.serialization.Model): """Resource group export result. :param template: The template content. @@ -1243,13 +1495,19 @@ class ResourceGroupExportResult(Model): 'error': {'key': 'error', 'type': 'ResourceManagementErrorWithDetails'}, } - def __init__(self, *, template=None, error=None, **kwargs) -> None: + def __init__( + self, + *, + template: Optional[object] = None, + error: Optional["ResourceManagementErrorWithDetails"] = None, + **kwargs + ): super(ResourceGroupExportResult, self).__init__(**kwargs) self.template = template self.error = error -class ResourceGroupFilter(Model): +class ResourceGroupFilter(msrest.serialization.Model): """Resource group filter. :param tag_name: The tag name. @@ -1263,24 +1521,59 @@ class ResourceGroupFilter(Model): 'tag_value': {'key': 'tagValue', 'type': 'str'}, } - def __init__(self, *, tag_name: str=None, tag_value: str=None, **kwargs) -> None: + def __init__( + self, + *, + tag_name: Optional[str] = None, + tag_value: Optional[str] = None, + **kwargs + ): super(ResourceGroupFilter, self).__init__(**kwargs) self.tag_name = tag_name self.tag_value = tag_value -class ResourceGroupPatchable(Model): +class ResourceGroupListResult(msrest.serialization.Model): + """List of resource groups. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ResourceGroup]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["ResourceGroup"]] = None, + **kwargs + ): + super(ResourceGroupListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +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 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: The tags attached to the resource group. + :param tags: A set of tags. The tags attached to the resource group. :type tags: dict[str, str] """ @@ -1291,7 +1584,15 @@ class ResourceGroupPatchable(Model): 'tags': {'key': 'tags', 'type': '{str}'}, } - def __init__(self, *, name: str=None, properties=None, managed_by: str=None, tags=None, **kwargs) -> None: + def __init__( + self, + *, + name: Optional[str] = None, + properties: Optional["ResourceGroupProperties"] = None, + managed_by: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): super(ResourceGroupPatchable, self).__init__(**kwargs) self.name = name self.properties = properties @@ -1299,11 +1600,10 @@ def __init__(self, *, name: str=None, properties=None, managed_by: str=None, tag self.tags = tags -class ResourceGroupProperties(Model): +class ResourceGroupProperties(msrest.serialization.Model): """The resource group properties. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar provisioning_state: The provisioning state. :vartype provisioning_state: str @@ -1317,16 +1617,49 @@ class ResourceGroupProperties(Model): 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, } - def __init__(self, **kwargs) -> None: + def __init__( + self, + **kwargs + ): super(ResourceGroupProperties, self).__init__(**kwargs) self.provisioning_state = None -class ResourceManagementErrorWithDetails(Model): +class ResourceListResult(msrest.serialization.Model): + """List of resource groups. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[GenericResourceExpanded]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["GenericResourceExpanded"]] = None, + **kwargs + ): + super(ResourceListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class ResourceManagementErrorWithDetails(msrest.serialization.Model): """The detailed error message of resource management. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar code: The error code returned when exporting the template. :vartype code: str @@ -1353,7 +1686,10 @@ class ResourceManagementErrorWithDetails(Model): 'details': {'key': 'details', 'type': '[ResourceManagementErrorWithDetails]'}, } - def __init__(self, **kwargs) -> None: + def __init__( + self, + **kwargs + ): super(ResourceManagementErrorWithDetails, self).__init__(**kwargs) self.code = None self.message = None @@ -1361,7 +1697,7 @@ def __init__(self, **kwargs) -> None: self.details = None -class ResourceProviderOperationDisplayProperties(Model): +class ResourceProviderOperationDisplayProperties(msrest.serialization.Model): """Resource provider operation's display properties. :param publisher: Operation description. @@ -1384,7 +1720,16 @@ class ResourceProviderOperationDisplayProperties(Model): 'description': {'key': 'description', 'type': 'str'}, } - def __init__(self, *, publisher: str=None, provider: str=None, resource: str=None, operation: str=None, description: str=None, **kwargs) -> None: + def __init__( + self, + *, + publisher: Optional[str] = None, + provider: Optional[str] = None, + resource: Optional[str] = None, + operation: Optional[str] = None, + description: Optional[str] = None, + **kwargs + ): super(ResourceProviderOperationDisplayProperties, self).__init__(**kwargs) self.publisher = publisher self.provider = provider @@ -1393,7 +1738,7 @@ def __init__(self, *, publisher: str=None, provider: str=None, resource: str=Non self.description = description -class ResourcesMoveInfo(Model): +class ResourcesMoveInfo(msrest.serialization.Model): """Parameters of move resources. :param resources: The IDs of the resources. @@ -1407,13 +1752,19 @@ class ResourcesMoveInfo(Model): 'target_resource_group': {'key': 'targetResourceGroup', 'type': 'str'}, } - def __init__(self, *, resources=None, target_resource_group: str=None, **kwargs) -> None: + def __init__( + self, + *, + resources: Optional[List[str]] = None, + target_resource_group: Optional[str] = None, + **kwargs + ): super(ResourcesMoveInfo, self).__init__(**kwargs) self.resources = resources self.target_resource_group = target_resource_group -class Sku(Model): +class Sku(msrest.serialization.Model): """SKU for the resource. :param name: The SKU name. @@ -1439,7 +1790,17 @@ class Sku(Model): 'capacity': {'key': 'capacity', 'type': 'int'}, } - def __init__(self, *, name: str=None, tier: str=None, size: str=None, family: str=None, model: str=None, capacity: int=None, **kwargs) -> None: + def __init__( + self, + *, + name: Optional[str] = None, + tier: Optional[str] = None, + size: Optional[str] = None, + family: Optional[str] = None, + model: Optional[str] = None, + capacity: Optional[int] = None, + **kwargs + ): super(Sku, self).__init__(**kwargs) self.name = name self.tier = tier @@ -1449,10 +1810,10 @@ def __init__(self, *, name: str=None, tier: str=None, size: str=None, family: st self.capacity = capacity -class SubResource(Model): +class SubResource(msrest.serialization.Model): """Sub-resource. - :param id: Resource ID + :param id: Resource ID. :type id: str """ @@ -1460,12 +1821,17 @@ class SubResource(Model): 'id': {'key': 'id', 'type': 'str'}, } - def __init__(self, *, id: str=None, **kwargs) -> None: + def __init__( + self, + *, + id: Optional[str] = None, + **kwargs + ): super(SubResource, self).__init__(**kwargs) self.id = id -class TagCount(Model): +class TagCount(msrest.serialization.Model): """Tag count. :param type: Type of count. @@ -1479,29 +1845,32 @@ class TagCount(Model): 'value': {'key': 'value', 'type': 'int'}, } - def __init__(self, *, type: str=None, value: int=None, **kwargs) -> None: + def __init__( + self, + *, + type: Optional[str] = None, + value: Optional[int] = None, + **kwargs + ): super(TagCount, self).__init__(**kwargs) self.type = type self.value = value -class TagDetails(Model): +class TagDetails(msrest.serialization.Model): """Tag details. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :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 created and has no associated resources, the value - is 0. + :param 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] + :type values: list[~azure.mgmt.resource.resources.v2019_05_01.models.TagValue] """ _validation = { @@ -1515,7 +1884,14 @@ class TagDetails(Model): 'values': {'key': 'values', 'type': '[TagValue]'}, } - def __init__(self, *, tag_name: str=None, count=None, values=None, **kwargs) -> None: + def __init__( + self, + *, + tag_name: Optional[str] = None, + count: Optional["TagCount"] = None, + values: Optional[List["TagValue"]] = None, + **kwargs + ): super(TagDetails, self).__init__(**kwargs) self.id = None self.tag_name = tag_name @@ -1523,11 +1899,41 @@ def __init__(self, *, tag_name: str=None, count=None, values=None, **kwargs) -> self.values = values -class TagValue(Model): +class TagsListResult(msrest.serialization.Model): + """List of subscription tags. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[TagDetails]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["TagDetails"]] = None, + **kwargs + ): + super(TagsListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class TagValue(msrest.serialization.Model): """Tag information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The tag ID. :vartype id: str @@ -1547,14 +1953,20 @@ class TagValue(Model): 'count': {'key': 'count', 'type': 'TagCount'}, } - def __init__(self, *, tag_value: str=None, count=None, **kwargs) -> None: + def __init__( + self, + *, + tag_value: Optional[str] = None, + count: Optional["TagCount"] = None, + **kwargs + ): super(TagValue, self).__init__(**kwargs) self.id = None self.tag_value = tag_value self.count = count -class TargetResource(Model): +class TargetResource(msrest.serialization.Model): """Target resource. :param id: The ID of the resource. @@ -1571,16 +1983,22 @@ class TargetResource(Model): 'resource_type': {'key': 'resourceType', 'type': 'str'}, } - def __init__(self, *, id: str=None, resource_name: str=None, resource_type: str=None, **kwargs) -> None: + def __init__( + self, + *, + id: Optional[str] = None, + resource_name: Optional[str] = None, + resource_type: Optional[str] = None, + **kwargs + ): super(TargetResource, self).__init__(**kwargs) self.id = id self.resource_name = resource_name self.resource_type = resource_type -class TemplateHashResult(Model): - """Result of the request to calculate template hash. It contains a string of - minified template and its hash. +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 @@ -1593,21 +2011,26 @@ class TemplateHashResult(Model): 'template_hash': {'key': 'templateHash', 'type': 'str'}, } - def __init__(self, *, minified_template: str=None, template_hash: str=None, **kwargs) -> None: + def __init__( + self, + *, + minified_template: Optional[str] = None, + template_hash: Optional[str] = None, + **kwargs + ): super(TemplateHashResult, self).__init__(**kwargs) self.minified_template = minified_template self.template_hash = template_hash -class TemplateLink(Model): +class TemplateLink(msrest.serialization.Model): """Entity representing the reference to the template. 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. + :param content_version: If included, must match the ContentVersion in the template. :type content_version: str """ @@ -1620,7 +2043,13 @@ class TemplateLink(Model): 'content_version': {'key': 'contentVersion', 'type': 'str'}, } - def __init__(self, *, uri: str, content_version: str=None, **kwargs) -> None: + def __init__( + self, + *, + uri: str, + content_version: Optional[str] = None, + **kwargs + ): 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/v2019_05_01/models/_paged_models.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/models/_paged_models.py deleted file mode 100644 index 1a6e6a84b46c..000000000000 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/models/_paged_models.py +++ /dev/null @@ -1,105 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.paging import Paged - - -class OperationPaged(Paged): - """ - A paging container for iterating over a list of :class:`Operation ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[Operation]'} - } - - def __init__(self, *args, **kwargs): - - super(OperationPaged, self).__init__(*args, **kwargs) -class DeploymentExtendedPaged(Paged): - """ - A paging container for iterating over a list of :class:`DeploymentExtended ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[DeploymentExtended]'} - } - - def __init__(self, *args, **kwargs): - - super(DeploymentExtendedPaged, self).__init__(*args, **kwargs) -class ProviderPaged(Paged): - """ - A paging container for iterating over a list of :class:`Provider ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[Provider]'} - } - - def __init__(self, *args, **kwargs): - - super(ProviderPaged, self).__init__(*args, **kwargs) -class GenericResourceExpandedPaged(Paged): - """ - A paging container for iterating over a list of :class:`GenericResourceExpanded ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[GenericResourceExpanded]'} - } - - def __init__(self, *args, **kwargs): - - super(GenericResourceExpandedPaged, self).__init__(*args, **kwargs) -class ResourceGroupPaged(Paged): - """ - A paging container for iterating over a list of :class:`ResourceGroup ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[ResourceGroup]'} - } - - def __init__(self, *args, **kwargs): - - super(ResourceGroupPaged, self).__init__(*args, **kwargs) -class TagDetailsPaged(Paged): - """ - A paging container for iterating over a list of :class:`TagDetails ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[TagDetails]'} - } - - def __init__(self, *args, **kwargs): - - super(TagDetailsPaged, self).__init__(*args, **kwargs) -class DeploymentOperationPaged(Paged): - """ - A paging container for iterating over a list of :class:`DeploymentOperation ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[DeploymentOperation]'} - } - - def __init__(self, *args, **kwargs): - - super(DeploymentOperationPaged, self).__init__(*args, **kwargs) 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 9fd73ca1de47..fb982486e0e9 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 @@ -1,30 +1,35 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from enum import Enum - class DeploymentMode(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 + the resource group that are not included in the template are deleted. Be careful when using + Complete mode as you may unintentionally delete resources. + """ incremental = "Incremental" complete = "Complete" - class OnErrorDeploymentType(str, Enum): + """The deployment on error behavior type. Possible values are LastSuccessful and + SpecificDeployment. + """ last_successful = "LastSuccessful" specific_deployment = "SpecificDeployment" - class ResourceIdentityType(str, Enum): + """The identity type. + """ system_assigned = "SystemAssigned" user_assigned = "UserAssigned" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/operations/__init__.py index 41027cf11028..a6f5fa20e792 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/operations/__init__.py @@ -1,12 +1,9 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from ._operations import Operations @@ -15,7 +12,7 @@ from ._resources_operations import ResourcesOperations from ._resource_groups_operations import ResourceGroupsOperations from ._tags_operations import TagsOperations -from ._deployment_operations import DeploymentOperations +from ._deployment_operations_operations import DeploymentOperationsOperations __all__ = [ 'Operations', @@ -24,5 +21,5 @@ 'ResourcesOperations', 'ResourceGroupsOperations', 'TagsOperations', - 'DeploymentOperations', + 'DeploymentOperationsOperations', ] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/operations/_deployment_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/operations/_deployment_operations.py deleted file mode 100644 index f3041278894f..000000000000 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/operations/_deployment_operations.py +++ /dev/null @@ -1,457 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError - -from .. import models - - -class DeploymentOperations(object): - """DeploymentOperations operations. - - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. - - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for this operation. Constant value: "2019-05-01". - """ - - models = models - - def __init__(self, client, config, serializer, deserializer): - - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self.api_version = "2019-05-01" - - self.config = config - - def get_at_management_group_scope( - self, group_id, deployment_name, operation_id, custom_headers=None, raw=False, **operation_config): - """Gets a deployments operation. - - :param group_id: The management group ID. - :type group_id: str - :param deployment_name: The name of the deployment. - :type deployment_name: str - :param operation_id: The ID of the operation to get. - :type operation_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentOperation or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentOperation - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` - """ - # Construct URL - url = self.get_at_management_group_scope.metadata['url'] - 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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) - - if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentOperation', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - - return deserialized - get_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} - - def list_at_management_group_scope( - self, group_id, deployment_name, top=None, custom_headers=None, raw=False, **operation_config): - """Gets all deployments operations for a deployment. - - :param group_id: The management group ID. - :type group_id: str - :param deployment_name: The name of the deployment. - :type deployment_name: str - :param top: The number of results to return. - :type top: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of DeploymentOperation - :rtype: - ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentOperationPaged[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentOperation] - :raises: :class:`CloudError` - """ - def prepare_request(next_link=None): - if not next_link: - # Construct URL - url = self.list_at_management_group_scope.metadata['url'] - 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 = {} - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - else: - url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) - return request - - def internal_paging(next_link=None): - request = prepare_request(next_link) - - response = self._client.send(request, stream=False, **operation_config) - - if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response - - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.DeploymentOperationPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} - - def get_at_subscription_scope( - self, deployment_name, operation_id, custom_headers=None, raw=False, **operation_config): - """Gets a deployments operation. - - :param deployment_name: The name of the deployment. - :type deployment_name: str - :param operation_id: The ID of the operation to get. - :type operation_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentOperation or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentOperation - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` - """ - # Construct URL - url = self.get_at_subscription_scope.metadata['url'] - 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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) - - if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentOperation', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - - return deserialized - get_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} - - def list_at_subscription_scope( - self, deployment_name, top=None, custom_headers=None, raw=False, **operation_config): - """Gets all deployments operations for a deployment. - - :param deployment_name: The name of the deployment. - :type deployment_name: str - :param top: The number of results to return. - :type top: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of DeploymentOperation - :rtype: - ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentOperationPaged[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentOperation] - :raises: :class:`CloudError` - """ - def prepare_request(next_link=None): - if not next_link: - # Construct URL - url = self.list_at_subscription_scope.metadata['url'] - 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 = {} - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - else: - url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) - return request - - def internal_paging(next_link=None): - request = prepare_request(next_link) - - response = self._client.send(request, stream=False, **operation_config) - - if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response - - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.DeploymentOperationPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} - - def get( - self, resource_group_name, deployment_name, operation_id, custom_headers=None, raw=False, **operation_config): - """Gets a deployments operation. - - :param resource_group_name: The name of the resource group. The name - is case insensitive. - :type resource_group_name: str - :param deployment_name: The name of the deployment. - :type deployment_name: str - :param operation_id: The ID of the operation to get. - :type operation_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentOperation or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentOperation - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` - """ - # Construct URL - url = self.get.metadata['url'] - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, 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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) - - if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentOperation', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}'} - - def list( - self, resource_group_name, deployment_name, top=None, custom_headers=None, raw=False, **operation_config): - """Gets all deployments operations for a deployment. - - :param resource_group_name: The name of the resource group. The name - is case insensitive. - :type resource_group_name: str - :param deployment_name: The name of the deployment. - :type deployment_name: str - :param top: The number of results to return. - :type top: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of DeploymentOperation - :rtype: - ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentOperationPaged[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentOperation] - :raises: :class:`CloudError` - """ - def prepare_request(next_link=None): - if not next_link: - # Construct URL - url = self.list.metadata['url'] - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - else: - url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) - return request - - def internal_paging(next_link=None): - request = prepare_request(next_link) - - response = self._client.send(request, stream=False, **operation_config) - - if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response - - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.DeploymentOperationPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations'} 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 new file mode 100644 index 000000000000..bae665d79051 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/operations/_deployment_operations_operations.py @@ -0,0 +1,450 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class DeploymentOperationsOperations(object): + """DeploymentOperationsOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2019_05_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def get_at_management_group_scope( + self, + group_id, # type: str + deployment_name, # type: str + operation_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentOperation" + """Gets a deployments operation. + + :param group_id: The management group ID. + :type group_id: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param operation_id: The ID of the operation to get. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentOperation or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentOperation + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentOperation"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-01" + + # 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'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentOperation', pipeline_response) + + if cls: + 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 + + def list_at_management_group_scope( + self, + group_id, # type: str + deployment_name, # type: str + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.DeploymentOperationsListResult"] + """Gets all deployments operations for a deployment. + + :param group_id: The management group ID. + :type group_id: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentOperationsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + 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 + + def get_at_subscription_scope( + self, + deployment_name, # type: str + operation_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentOperation" + """Gets a deployments operation. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param operation_id: The ID of the operation to get. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentOperation or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentOperation + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentOperation"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-01" + + # 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'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentOperation', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + def list_at_subscription_scope( + self, + deployment_name, # type: str + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.DeploymentOperationsListResult"] + """Gets all deployments operations for a deployment. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentOperationsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + 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 + + def get( + self, + resource_group_name, # type: str + deployment_name, # type: str + operation_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentOperation" + """Gets a deployments operation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param operation_id: The ID of the operation to get. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentOperation or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentOperation + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentOperation"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-01" + + # Construct URL + url = self.get.metadata['url'] # type: 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'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentOperation', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + def list( + self, + resource_group_name, # type: str + deployment_name, # type: str + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.DeploymentOperationsListResult"] + """Gets all deployments operations for a deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentOperationsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations'} # type: ignore 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 a8b644649526..e99c6cf00206 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 @@ -1,1858 +1,1821 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError -from msrest.polling import LROPoller, NoPolling -from msrestazure.polling.arm_polling import ARMPolling +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class DeploymentsOperations(object): """DeploymentsOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2019_05_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for this operation. Constant value: "2019-05-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-05-01" - - self.config = config - + self._config = config def _delete_at_management_group_scope_initial( - self, group_id, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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.metadata['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\._\(\)]+$') + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [202, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - - def delete_at_management_group_scope( - self, group_id, deployment_name, custom_headers=None, raw=False, polling=True, **operation_config): - """Deletes a deployment from the deployment history. - - A template deployment that is currently running cannot be deleted. - Deleting a template deployment removes the associated deployment - operations. This is an asynchronous operation that returns a status of - 202 until the template deployment is successfully deleted. The Location - response header contains the URI that is used to obtain the status of - the process. While the process is running, a call to the URI in the - Location header returns a status of 202. When the process finishes, the - URI in the Location header returns a status of 204 on success. If the - asynchronous request failed, the URI in the Location header returns an - error-level status code. + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_at_management_group_scope_initial.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + def begin_delete_at_management_group_scope( + self, + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """A template deployment that is currently running cannot be deleted. Deleting a template deployment removes the associated deployment operations. This is an asynchronous operation that returns a status of 202 until the template deployment is successfully deleted. The Location response header contains the URI that is used to obtain the status of the process. While the process is running, a call to the URI in the Location header returns a status of 202. When the process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. + + Deletes a deployment from the deployment history. :param group_id: The management group ID. :type group_id: str :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns None or - ClientRawResponse if raw==True - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._delete_at_management_group_scope_initial( group_id=group_id, deployment_name=deployment_name, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - delete_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} + begin_delete_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore def check_existence_at_management_group_scope( - self, group_id, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Checks whether the deployment exists. :param group_id: The management group ID. :type group_id: str :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: bool or ClientRawResponse if raw=true - :rtype: bool or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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'] + 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\._\(\)]+$') + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204, 404]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = (response.status_code == 204) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - return deserialized - check_existence_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + if cls: + return cls(pipeline_response, None, {}) + + 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, deployment_name, properties, location=None, custom_headers=None, raw=False, **operation_config): - parameters = models.Deployment(location=location, properties=properties) + self, + group_id, # type: str + deployment_name, # type: str + properties, # type: "models.DeploymentProperties" + location=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentExtended" + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.Deployment(location=location, properties=properties) + api_version = "2019-05-01" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.create_or_update_at_management_group_scope.metadata['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\._\(\)]+$') + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'Deployment') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 201]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', response) + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', response) + deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + 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 - def create_or_update_at_management_group_scope( - self, group_id, deployment_name, properties, location=None, custom_headers=None, raw=False, polling=True, **operation_config): - """Deploys resources at management group scope. + def begin_create_or_update_at_management_group_scope( + self, + group_id, # type: str + deployment_name, # type: str + properties, # type: "models.DeploymentProperties" + location=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """You can provide the template and parameters directly in the request or link to JSON files. - You can provide the template and parameters directly in the request or - link to JSON files. + Deploys resources at management group scope. :param group_id: The management group ID. :type group_id: str :param deployment_name: The name of the deployment. :type deployment_name: str :param properties: The deployment properties. - :type properties: - ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentProperties + :type properties: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentProperties :param location: The location to store the deployment data. :type location: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns DeploymentExtended or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentExtended] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentExtended]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 DeploymentExtended + :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] + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._create_or_update_at_management_group_scope_initial( group_id=group_id, deployment_name=deployment_name, properties=properties, location=location, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - deserialized = self._deserialize('DeploymentExtended', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - create_or_update_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} + begin_create_or_update_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore def get_at_management_group_scope( - self, group_id, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentExtended" """Gets a deployment. :param group_id: The management group ID. :type group_id: str :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentExtended or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentExtended - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExtended or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentExtended + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-01" + # Construct URL - url = self.get_at_management_group_scope.metadata['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\._\(\)]+$') + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', response) + deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} + get_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore def cancel_at_management_group_scope( - self, group_id, deployment_name, custom_headers=None, raw=False, **operation_config): - """Cancels a currently running template deployment. + self, + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """You can cancel a deployment only if the provisioningState is Accepted or Running. After the deployment is canceled, the provisioningState is set to Canceled. Canceling a template deployment stops the currently running template deployment and leaves the resources partially deployed. - You can cancel a deployment only if the provisioningState is Accepted - or Running. After the deployment is canceled, the provisioningState is - set to Canceled. Canceling a template deployment stops the currently - running template deployment and leaves the resources partially - deployed. + Cancels a currently running template deployment. :param group_id: The management group ID. :type group_id: str :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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'] + 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\._\(\)]+$') + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - cancel_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} + if cls: + return cls(pipeline_response, None, {}) + + 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( - self, group_id, deployment_name, properties, location=None, custom_headers=None, raw=False, **operation_config): - """Validates whether the specified template is syntactically correct and - will be accepted by Azure Resource Manager.. + self, + group_id, # type: str + deployment_name, # type: str + properties, # type: "models.DeploymentProperties" + location=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentValidateResult" + """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. :param group_id: The management group ID. :type group_id: str :param deployment_name: The name of the deployment. :type deployment_name: str :param properties: The deployment properties. - :type properties: - ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentProperties + :type properties: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentProperties :param location: The location to store the deployment data. :type location: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentValidateResult or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentValidateResult - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentValidateResult + :raises: ~azure.core.exceptions.HttpResponseError """ - parameters = models.Deployment(location=location, properties=properties) + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentValidateResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.Deployment(location=location, properties=properties) + api_version = "2019-05-01" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.validate_at_management_group_scope.metadata['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\._\(\)]+$') + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'Deployment') # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 400]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', response) + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', response) + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + 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'} + validate_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore def export_template_at_management_group_scope( - self, group_id, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentExportResult" """Exports the template used for specified deployment. :param group_id: The management group ID. :type group_id: str :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentExportResult or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentExportResult - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentExportResult + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExportResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-01" + # Construct URL - url = self.export_template_at_management_group_scope.metadata['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\._\(\)]+$') + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentExportResult', response) + deserialized = self._deserialize('DeploymentExportResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + 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'} + export_template_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore def list_at_management_group_scope( - self, group_id, filter=None, top=None, custom_headers=None, raw=False, **operation_config): + self, + group_id, # type: str + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.DeploymentListResult"] """Get all the deployments for a management group. :param group_id: The management group ID. :type group_id: str - :param filter: The filter to apply on the operation. For example, you - can use $filter=provisioningState eq '{state}'. + :param filter: The filter to apply on the operation. For example, you can use + $filter=provisioningState eq '{state}'. :type filter: str - :param top: The number of results to get. If null is passed, returns - all deployments. + :param top: The number of results to get. If null is passed, returns all deployments. :type top: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of DeploymentExtended - :rtype: - ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentExtendedPaged[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentExtended] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_at_management_group_scope.metadata['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) + '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 = {} + 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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response - - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.DeploymentExtendedPaged(internal_paging, self._deserialize.dependencies, header_dict) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return deserialized - list_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/'} + 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/'} # type: ignore def _delete_at_subscription_scope_initial( - self, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-01" + # Construct URL - url = self.delete_at_subscription_scope.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [202, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - - def delete_at_subscription_scope( - self, deployment_name, custom_headers=None, raw=False, polling=True, **operation_config): - """Deletes a deployment from the deployment history. - - A template deployment that is currently running cannot be deleted. - Deleting a template deployment removes the associated deployment - operations. This is an asynchronous operation that returns a status of - 202 until the template deployment is successfully deleted. The Location - response header contains the URI that is used to obtain the status of - the process. While the process is running, a call to the URI in the - Location header returns a status of 202. When the process finishes, the - URI in the Location header returns a status of 204 on success. If the - asynchronous request failed, the URI in the Location header returns an - error-level status code. + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + def begin_delete_at_subscription_scope( + self, + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """A template deployment that is currently running cannot be deleted. Deleting a template deployment removes the associated deployment operations. This is an asynchronous operation that returns a status of 202 until the template deployment is successfully deleted. The Location response header contains the URI that is used to obtain the status of the process. While the process is running, a call to the URI in the Location header returns a status of 202. When the process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. + + Deletes a deployment from the deployment history. :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns None or - ClientRawResponse if raw==True - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._delete_at_subscription_scope_initial( deployment_name=deployment_name, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - delete_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} + begin_delete_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore def check_existence_at_subscription_scope( - self, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Checks whether the deployment exists. :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: bool or ClientRawResponse if raw=true - :rtype: bool or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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'] + 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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204, 404]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = (response.status_code == 204) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - return deserialized - check_existence_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + if cls: + return cls(pipeline_response, None, {}) + + 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, properties, location=None, custom_headers=None, raw=False, **operation_config): - parameters = models.Deployment(location=location, properties=properties) + self, + deployment_name, # type: str + properties, # type: "models.DeploymentProperties" + location=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentExtended" + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.Deployment(location=location, properties=properties) + api_version = "2019-05-01" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.create_or_update_at_subscription_scope.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'Deployment') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 201]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', response) + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', response) + deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + 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 - def create_or_update_at_subscription_scope( - self, deployment_name, properties, location=None, custom_headers=None, raw=False, polling=True, **operation_config): - """Deploys resources at subscription scope. + def begin_create_or_update_at_subscription_scope( + self, + deployment_name, # type: str + properties, # type: "models.DeploymentProperties" + location=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """You can provide the template and parameters directly in the request or link to JSON files. - You can provide the template and parameters directly in the request or - link to JSON files. + Deploys resources at subscription scope. :param deployment_name: The name of the deployment. :type deployment_name: str :param properties: The deployment properties. - :type properties: - ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentProperties + :type properties: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentProperties :param location: The location to store the deployment data. :type location: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns DeploymentExtended or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentExtended] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentExtended]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 DeploymentExtended + :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] + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._create_or_update_at_subscription_scope_initial( deployment_name=deployment_name, properties=properties, location=location, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - deserialized = self._deserialize('DeploymentExtended', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - create_or_update_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} + begin_create_or_update_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore def get_at_subscription_scope( - self, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentExtended" """Gets a deployment. :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentExtended or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentExtended - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExtended or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentExtended + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-01" + # Construct URL - url = self.get_at_subscription_scope.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', response) + deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} + get_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore def cancel_at_subscription_scope( - self, deployment_name, custom_headers=None, raw=False, **operation_config): - """Cancels a currently running template deployment. + self, + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """You can cancel a deployment only if the provisioningState is Accepted or Running. After the deployment is canceled, the provisioningState is set to Canceled. Canceling a template deployment stops the currently running template deployment and leaves the resources partially deployed. - You can cancel a deployment only if the provisioningState is Accepted - or Running. After the deployment is canceled, the provisioningState is - set to Canceled. Canceling a template deployment stops the currently - running template deployment and leaves the resources partially - deployed. + Cancels a currently running template deployment. :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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'] + 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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - cancel_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} + if cls: + return cls(pipeline_response, None, {}) + + cancel_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore def validate_at_subscription_scope( - self, deployment_name, properties, location=None, custom_headers=None, raw=False, **operation_config): - """Validates whether the specified template is syntactically correct and - will be accepted by Azure Resource Manager.. + self, + deployment_name, # type: str + properties, # type: "models.DeploymentProperties" + location=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentValidateResult" + """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. :param deployment_name: The name of the deployment. :type deployment_name: str :param properties: The deployment properties. - :type properties: - ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentProperties + :type properties: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentProperties :param location: The location to store the deployment data. :type location: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentValidateResult or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentValidateResult - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentValidateResult + :raises: ~azure.core.exceptions.HttpResponseError """ - parameters = models.Deployment(location=location, properties=properties) + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentValidateResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.Deployment(location=location, properties=properties) + api_version = "2019-05-01" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.validate_at_subscription_scope.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'Deployment') # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 400]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', response) + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', response) + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - validate_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} + validate_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore def export_template_at_subscription_scope( - self, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentExportResult" """Exports the template used for specified deployment. :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentExportResult or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentExportResult - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentExportResult + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExportResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-01" + # Construct URL - url = self.export_template_at_subscription_scope.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentExportResult', response) + deserialized = self._deserialize('DeploymentExportResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - export_template_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} + export_template_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore def list_at_subscription_scope( - self, filter=None, top=None, custom_headers=None, raw=False, **operation_config): + self, + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.DeploymentListResult"] """Get all the deployments for a subscription. - :param filter: The filter to apply on the operation. For example, you - can use $filter=provisioningState eq '{state}'. + :param filter: The filter to apply on the operation. For example, you can use + $filter=provisioningState eq '{state}'. :type filter: str - :param top: The number of results to get. If null is passed, returns - all deployments. + :param top: The number of results to get. If null is passed, returns all deployments. :type top: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of DeploymentExtended - :rtype: - ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentExtendedPaged[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentExtended] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_at_subscription_scope.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response - - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.DeploymentExtendedPaged(internal_paging, self._deserialize.dependencies, header_dict) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return deserialized - list_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/'} + return pipeline_response + return ItemPaged( + get_next, extract_data + ) + list_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/'} # type: ignore def _delete_initial( - self, resource_group_name, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-01" + # Construct URL - url = self.delete.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [202, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - - def delete( - self, resource_group_name, deployment_name, custom_headers=None, raw=False, polling=True, **operation_config): - """Deletes a deployment from the deployment history. - - A template deployment that is currently running cannot be deleted. - Deleting a template deployment removes the associated deployment - operations. Deleting a template deployment does not affect the state of - the resource group. This is an asynchronous operation that returns a - status of 202 until the template deployment is successfully deleted. - The Location response header contains the URI that is used to obtain - the status of the process. While the process is running, a call to the - URI in the Location header returns a status of 202. When the process - finishes, the URI in the Location header returns a status of 204 on - success. If the asynchronous request failed, the URI in the Location - header returns an error-level status code. - - :param resource_group_name: The name of the resource group with the - deployment to delete. The name is case insensitive. + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + def begin_delete( + self, + resource_group_name, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """A template deployment that is currently running cannot be deleted. Deleting a template deployment removes the associated deployment operations. Deleting a template deployment does not affect the state of the resource group. This is an asynchronous operation that returns a status of 202 until the template deployment is successfully deleted. The Location response header contains the URI that is used to obtain the status of the process. While the process is running, a call to the URI in the Location header returns a status of 202. When the process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. + + Deletes a deployment from the deployment history. + + :param resource_group_name: The name of the resource group with the deployment to delete. The + name is case insensitive. :type resource_group_name: str :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns None or - ClientRawResponse if raw==True - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._delete_initial( resource_group_name=resource_group_name, deployment_name=deployment_name, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore def check_existence( - self, resource_group_name, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Checks whether the deployment exists. - :param resource_group_name: The name of the resource group with the - deployment to check. The name is case insensitive. + :param resource_group_name: The name of the resource group with the deployment to check. The + name is case insensitive. :type resource_group_name: str :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: bool or ClientRawResponse if raw=true - :rtype: bool or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-01" + # Construct URL - url = self.check_existence.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204, 404]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = (response.status_code == 204) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - return deserialized - check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + 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, deployment_name, properties, location=None, custom_headers=None, raw=False, **operation_config): - parameters = models.Deployment(location=location, properties=properties) + self, + resource_group_name, # type: str + deployment_name, # type: str + properties, # type: "models.DeploymentProperties" + location=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentExtended" + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.Deployment(location=location, properties=properties) + api_version = "2019-05-01" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.create_or_update.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'Deployment') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 201]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', response) + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', response) + deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - - def create_or_update( - self, resource_group_name, deployment_name, properties, location=None, custom_headers=None, raw=False, polling=True, **operation_config): - """Deploys resources to a resource group. - - You can provide the template and parameters directly in the request or - link to JSON files. - - :param resource_group_name: The name of the resource group to deploy - the resources to. The name is case insensitive. The resource group - must already exist. + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + def begin_create_or_update( + self, + resource_group_name, # type: str + deployment_name, # type: str + properties, # type: "models.DeploymentProperties" + location=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """You can provide the template and parameters directly in the request or link to JSON files. + + Deploys resources to a resource group. + + :param resource_group_name: The name of the resource group to deploy the resources to. The name + is case insensitive. The resource group must already exist. :type resource_group_name: str :param deployment_name: The name of the deployment. :type deployment_name: str :param properties: The deployment properties. - :type properties: - ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentProperties + :type properties: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentProperties :param location: The location to store the deployment data. :type location: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns DeploymentExtended or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentExtended] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentExtended]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 DeploymentExtended + :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] + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._create_or_update_initial( resource_group_name=resource_group_name, deployment_name=deployment_name, properties=properties, location=location, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - deserialized = self._deserialize('DeploymentExtended', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore def get( - self, resource_group_name, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentExtended" """Gets a deployment. - :param resource_group_name: The name of the resource group. The name - is case insensitive. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentExtended or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentExtended - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExtended or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentExtended + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-01" + # Construct URL - url = self.get.metadata['url'] + url = self.get.metadata['url'] # type: 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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', response) + deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore def cancel( - self, resource_group_name, deployment_name, custom_headers=None, raw=False, **operation_config): - """Cancels a currently running template deployment. + self, + resource_group_name, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """You can cancel a deployment only if the provisioningState is Accepted or Running. After the deployment is canceled, the provisioningState is set to Canceled. Canceling a template deployment stops the currently running template deployment and leaves the resource group partially deployed. - You can cancel a deployment only if the provisioningState is Accepted - or Running. After the deployment is canceled, the provisioningState is - set to Canceled. Canceling a template deployment stops the currently - running template deployment and leaves the resource group partially - deployed. + Cancels a currently running template deployment. - :param resource_group_name: The name of the resource group. The name - is case insensitive. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-01" + # Construct URL - url = self.cancel.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - cancel.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} + if cls: + return cls(pipeline_response, None, {}) - def validate( - self, resource_group_name, deployment_name, properties, location=None, custom_headers=None, raw=False, **operation_config): - """Validates whether the specified template is syntactically correct and - will be accepted by Azure Resource Manager.. + cancel.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore - :param resource_group_name: The name of the resource group the - template will be deployed to. The name is case insensitive. + def validate( + self, + resource_group_name, # type: str + deployment_name, # type: str + properties, # type: "models.DeploymentProperties" + location=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentValidateResult" + """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. :type resource_group_name: str :param deployment_name: The name of the deployment. :type deployment_name: str :param properties: The deployment properties. - :type properties: - ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentProperties + :type properties: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentProperties :param location: The location to store the deployment data. :type location: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentValidateResult or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentValidateResult - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentValidateResult + :raises: ~azure.core.exceptions.HttpResponseError """ - parameters = models.Deployment(location=location, properties=properties) + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentValidateResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.Deployment(location=location, properties=properties) + api_version = "2019-05-01" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.validate.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'Deployment') # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 400]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', response) + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', response) + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - validate.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} + validate.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore def export_template( - self, resource_group_name, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentExportResult" """Exports the template used for specified deployment. - :param resource_group_name: The name of the resource group. The name - is case insensitive. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentExportResult or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentExportResult - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentExportResult + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExportResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-01" + # Construct URL - url = self.export_template.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentExportResult', response) + deserialized = self._deserialize('DeploymentExportResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} + export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore def list_by_resource_group( - self, resource_group_name, filter=None, top=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.DeploymentListResult"] """Get all the deployments for a resource group. - :param resource_group_name: The name of the resource group with the - deployments to get. The name is case insensitive. + :param resource_group_name: The name of the resource group with the deployments to get. The + name is case insensitive. :type resource_group_name: str - :param filter: The filter to apply on the operation. For example, you - can use $filter=provisioningState eq '{state}'. + :param filter: The filter to apply on the operation. For example, you can use + $filter=provisioningState eq '{state}'. :type filter: str - :param top: The number of results to get. If null is passed, returns - all deployments. + :param top: The number of results to get. If null is passed, returns all deployments. :type top: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of DeploymentExtended - :rtype: - ~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentExtendedPaged[~azure.mgmt.resource.resources.v2019_05_01.models.DeploymentExtended] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_by_resource_group.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.DeploymentExtendedPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/'} + return ItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/'} # type: ignore def calculate_template_hash( - self, template, custom_headers=None, raw=False, **operation_config): + self, + template, # type: object + **kwargs # type: Any + ): + # type: (...) -> "models.TemplateHashResult" """Calculate the hash of the given template. :param template: The template provided to calculate hash. :type template: object - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: TemplateHashResult or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_05_01.models.TemplateHashResult - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateHashResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.TemplateHashResult + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TemplateHashResult"] + error_map = {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.calculate_template_hash.metadata['url'] + url = self.calculate_template_hash.metadata['url'] # type: ignore # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(template, 'object') # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('TemplateHashResult', response) + deserialized = self._deserialize('TemplateHashResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - calculate_template_hash.metadata = {'url': '/providers/Microsoft.Resources/calculateTemplateHash'} + 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 a7143c98e194..b4eff7ad5baf 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 @@ -1,102 +1,106 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class Operations(object): """Operations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2019_05_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for this operation. Constant value: "2019-05-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-05-01" - - self.config = config + self._config = config def list( - self, custom_headers=None, raw=False, **operation_config): + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.OperationListResult"] """Lists all of the available Microsoft.Resources REST API operations. - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of Operation - :rtype: - ~azure.mgmt.resource.resources.v2019_05_01.models.OperationPaged[~azure.mgmt.resource.resources.v2019_05_01.models.Operation] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of OperationListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['url'] - + url = self.list.metadata['url'] # type: ignore # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('OperationListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.OperationPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list.metadata = {'url': '/providers/Microsoft.Resources/operations'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.Resources/operations'} # type: ignore 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 62f3a46ff684..7971378dbe17 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 @@ -1,300 +1,287 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class ProvidersOperations(object): """ProvidersOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2019_05_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for this operation. Constant value: "2019-05-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-05-01" - - self.config = config + self._config = config def unregister( - self, resource_provider_namespace, custom_headers=None, raw=False, **operation_config): + self, + resource_provider_namespace, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.Provider" """Unregisters a subscription from a resource provider. - :param resource_provider_namespace: The namespace of the resource - provider to unregister. + :param resource_provider_namespace: The namespace of the resource provider to unregister. :type resource_provider_namespace: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: Provider or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.Provider or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Provider or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.Provider + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Provider"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-01" + # Construct URL - url = self.unregister.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('Provider', response) + deserialized = self._deserialize('Provider', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - unregister.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister'} + unregister.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister'} # type: ignore def register( - self, resource_provider_namespace, custom_headers=None, raw=False, **operation_config): + self, + resource_provider_namespace, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.Provider" """Registers a subscription with a resource provider. - :param resource_provider_namespace: The namespace of the resource - provider to register. + :param resource_provider_namespace: The namespace of the resource provider to register. :type resource_provider_namespace: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: Provider or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.Provider or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Provider or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.Provider + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Provider"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-01" + # Construct URL - url = self.register.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('Provider', response) + deserialized = self._deserialize('Provider', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - register.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register'} + register.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register'} # type: ignore def list( - self, top=None, expand=None, custom_headers=None, raw=False, **operation_config): + self, + top=None, # type: Optional[int] + expand=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.ProviderListResult"] """Gets all resource providers for a subscription. - :param top: The number of results to return. If null is passed returns - all deployments. + :param top: The number of results to return. If null is passed returns all deployments. :type top: int - :param expand: The properties to include in the results. For example, - use &$expand=metadata in the query string to retrieve resource - provider metadata. To include property aliases in response, use - $expand=resourceTypes/aliases. + :param expand: The properties to include in the results. For example, use &$expand=metadata in + the query string to retrieve resource provider metadata. To include property aliases in + response, use $expand=resourceTypes/aliases. :type expand: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of Provider - :rtype: - ~azure.mgmt.resource.resources.v2019_05_01.models.ProviderPaged[~azure.mgmt.resource.resources.v2019_05_01.models.Provider] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of ProviderListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['url'] + url = self.list.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_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 = {} + 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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('ProviderListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.ProviderPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers'} # type: ignore def get( - self, resource_provider_namespace, expand=None, custom_headers=None, raw=False, **operation_config): + self, + resource_provider_namespace, # type: str + expand=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.Provider" """Gets the specified resource provider. - :param resource_provider_namespace: The namespace of the resource - provider. + :param resource_provider_namespace: The namespace of the resource provider. :type resource_provider_namespace: str - :param expand: The $expand query parameter. For example, to include - property aliases in response, use $expand=resourceTypes/aliases. + :param expand: The $expand query parameter. For example, to include property aliases in + response, use $expand=resourceTypes/aliases. :type expand: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: Provider or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.Provider or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Provider or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.Provider + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Provider"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-01" + # Construct URL - url = self.get.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('Provider', response) + deserialized = self._deserialize('Provider', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}'} + 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 2269457e7810..4d23fc908baf 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 @@ -1,530 +1,517 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError -from msrest.polling import LROPoller, NoPolling -from msrestazure.polling.arm_polling import ARMPolling +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, List, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class ResourceGroupsOperations(object): """ResourceGroupsOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2019_05_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for this operation. Constant value: "2019-05-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-05-01" - - self.config = config + self._config = config def check_existence( - self, resource_group_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Checks whether a resource group exists. - :param resource_group_name: The name of the resource group to check. - The name is case insensitive. + :param resource_group_name: The name of the resource group to check. The name is case + insensitive. :type resource_group_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: bool or ClientRawResponse if raw=true - :rtype: bool or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-01" + # Construct URL - url = self.check_existence.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204, 404]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = (response.status_code == 204) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - return deserialized - check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore def create_or_update( - self, resource_group_name, parameters, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + parameters, # type: "models.ResourceGroup" + **kwargs # type: Any + ): + # type: (...) -> "models.ResourceGroup" """Creates or updates a resource group. - :param resource_group_name: The name of the resource group to create - or update. Can include alphanumeric, underscore, parentheses, hyphen, - period (except at end), and Unicode characters that match the allowed - characters. + :param resource_group_name: The name of the resource group to create or update. Can include + alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters + that match the allowed characters. :type resource_group_name: str - :param parameters: Parameters supplied to the create or update a - resource group. - :type parameters: - ~azure.mgmt.resource.resources.v2019_05_01.models.ResourceGroup - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: ResourceGroup or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_05_01.models.ResourceGroup or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :param parameters: Parameters supplied to the create or update a resource group. + :type parameters: ~azure.mgmt.resource.resources.v2019_05_01.models.ResourceGroup + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.ResourceGroup + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceGroup"] + error_map = {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.create_or_update.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'ResourceGroup') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 201]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ResourceGroup', response) + deserialized = self._deserialize('ResourceGroup', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('ResourceGroup', response) + deserialized = self._deserialize('ResourceGroup', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} - + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore def _delete_initial( - self, resource_group_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-01" + # Construct URL - url = self.delete.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 202]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore - def delete( - self, resource_group_name, custom_headers=None, raw=False, polling=True, **operation_config): - """Deletes a resource group. + def begin_delete( + self, + resource_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """When you delete a resource group, all of its resources are also deleted. Deleting a resource group deletes all of its template deployments and currently stored operations. - When you delete a resource group, all of its resources are also - deleted. Deleting a resource group deletes all of its template - deployments and currently stored operations. + Deletes a resource group. - :param resource_group_name: The name of the resource group to delete. - The name is case insensitive. + :param resource_group_name: The name of the resource group to delete. The name is case + insensitive. :type resource_group_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns None or - ClientRawResponse if raw==True - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._delete_initial( resource_group_name=resource_group_name, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore def get( - self, resource_group_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.ResourceGroup" """Gets a resource group. - :param resource_group_name: The name of the resource group to get. The - name is case insensitive. + :param resource_group_name: The name of the resource group to get. The name is case + insensitive. :type resource_group_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: ResourceGroup or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_05_01.models.ResourceGroup or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.ResourceGroup + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceGroup"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-01" + # Construct URL - url = self.get.metadata['url'] + url = self.get.metadata['url'] # type: 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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('ResourceGroup', response) + deserialized = self._deserialize('ResourceGroup', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore def update( - self, resource_group_name, parameters, custom_headers=None, raw=False, **operation_config): - """Updates a resource group. - - Resource groups can be updated through a simple PATCH operation to a - group address. The format of the request is the same as that for - creating a resource group. If a field is unspecified, the current value - is retained. - - :param resource_group_name: The name of the resource group to update. - The name is case insensitive. + self, + resource_group_name, # type: str + parameters, # type: "models.ResourceGroupPatchable" + **kwargs # type: Any + ): + # type: (...) -> "models.ResourceGroup" + """Resource groups can be updated through a simple PATCH operation to a group address. The format of the request is the same as that for creating a resource group. If a field is unspecified, the current value is retained. + + Updates a resource group. + + :param resource_group_name: The name of the resource group to update. The name is case + insensitive. :type resource_group_name: str :param parameters: Parameters supplied to update a resource group. - :type parameters: - ~azure.mgmt.resource.resources.v2019_05_01.models.ResourceGroupPatchable - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: ResourceGroup or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_05_01.models.ResourceGroup or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :type parameters: ~azure.mgmt.resource.resources.v2019_05_01.models.ResourceGroupPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.ResourceGroup + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceGroup"] + error_map = {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.update.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'ResourceGroupPatchable') # Construct and send request - request = self._client.patch(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('ResourceGroup', response) + deserialized = self._deserialize('ResourceGroup', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore def export_template( - self, resource_group_name, resources=None, options=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + resources=None, # type: Optional[List[str]] + options=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.ResourceGroupExportResult" """Captures the specified resource group as a template. - :param resource_group_name: The name of the resource group to export - as a template. + :param resource_group_name: The name of the resource group to export as a template. :type resource_group_name: str - :param resources: The IDs of the resources to filter the export by. To - export all resources, supply an array with single entry '*'. + :param 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', - 'SkipResourceNameParameterization', 'SkipAllParameterization' + :param options: The export template options. A CSV-formatted list containing zero or more of + the following: 'IncludeParameterDefaultValue', 'IncludeComments', + 'SkipResourceNameParameterization', 'SkipAllParameterization'. :type options: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: ResourceGroupExportResult or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_05_01.models.ResourceGroupExportResult - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroupExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.ResourceGroupExportResult + :raises: ~azure.core.exceptions.HttpResponseError """ - parameters = models.ExportTemplateRequest(resources=resources, options=options) + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceGroupExportResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.ExportTemplateRequest(resources=resources, options=options) + api_version = "2019-05-01" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.export_template.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'ExportTemplateRequest') # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('ResourceGroupExportResult', response) + deserialized = self._deserialize('ResourceGroupExportResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate'} + export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate'} # type: ignore def list( - self, filter=None, top=None, custom_headers=None, raw=False, **operation_config): + self, + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.ResourceGroupListResult"] """Gets all the resource groups for a subscription. - :param filter: The filter to apply on the operation.

You can - filter by tag names and values. For example, to filter for a tag name - and value, use $filter=tagName eq 'tag1' and tagValue eq 'Value1' + :param filter: The filter to apply on the operation.:code:`
`:code:`
`You can filter by + tag names and values. For example, to filter for a tag name and value, use $filter=tagName eq + 'tag1' and tagValue eq 'Value1'. :type filter: str - :param top: The number of results to return. If null is passed, - returns all resource groups. + :param top: The number of results to return. If null is passed, returns all resource groups. :type top: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of ResourceGroup - :rtype: - ~azure.mgmt.resource.resources.v2019_05_01.models.ResourceGroupPaged[~azure.mgmt.resource.resources.v2019_05_01.models.ResourceGroup] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['url'] + url = self.list.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_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 = {} + 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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('ResourceGroupListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.ResourceGroupPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups'} # type: ignore 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 21b94a1a4edf..14be42f7e710 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 @@ -1,558 +1,577 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError -from msrest.polling import LROPoller, NoPolling -from msrestazure.polling.arm_polling import ARMPolling +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, List, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class ResourcesOperations(object): """ResourcesOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2019_05_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for this operation. Constant value: "2019-05-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-05-01" - - self.config = config + self._config = config def list_by_resource_group( - self, resource_group_name, filter=None, expand=None, top=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + filter=None, # type: Optional[str] + expand=None, # type: Optional[str] + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.ResourceListResult"] """Get all the resources for a resource group. - :param resource_group_name: The resource group with the resources to - get. + :param resource_group_name: The resource group with the resources to get. :type resource_group_name: str - :param filter: The filter to apply on the operation.

The - properties you can use for eq (equals) or ne (not equals) are: - location, resourceType, name, resourceGroup, identity, - identity/principalId, plan, plan/publisher, plan/product, plan/name, - plan/version, and plan/promotionCode.

For example, to filter by - a resource type, use: $filter=resourceType eq - 'Microsoft.Network/virtualNetworks'

You can use - substringof(value, property) in the filter. The properties you can use - for substring are: name and resourceGroup.

For example, to get - all resources with 'demo' anywhere in the name, use: - $filter=substringof('demo', name)

You can link more than one - substringof together by adding and/or operators.

You can filter - by tag names and values. For example, to filter for a tag name and - value, use $filter=tagName eq 'tag1' and tagValue eq - 'Value1'

You can use some properties together when filtering. - The combinations you can use are: substringof and/or resourceType, - plan and plan/publisher and plan/name, identity and - identity/principalId. + :param filter: The filter to apply on the operation.:code:`
`:code:`
`The properties you + can use for eq (equals) or ne (not equals) are: location, resourceType, name, resourceGroup, + identity, identity/principalId, plan, plan/publisher, plan/product, plan/name, plan/version, + and plan/promotionCode.:code:`
`:code:`
`For example, to filter by a resource type, use: + $filter=resourceType eq 'Microsoft.Network/virtualNetworks':code:`
`:code:`
`You can use + substringof(value, property) in the filter. The properties you can use for substring are: name + and resourceGroup.:code:`
`:code:`
`For example, to get all resources with 'demo' + anywhere in the name, use: $filter=substringof('demo', name):code:`
`:code:`
`You can + link more than one substringof together by adding and/or operators.:code:`
`:code:`
`You + can filter by tag names and values. For example, to filter for a tag name and value, use + $filter=tagName eq 'tag1' and tagValue eq 'Value1':code:`
`:code:`
`You can use some + properties together when filtering. The combinations you can use are: substringof and/or + resourceType, plan and plan/publisher and plan/name, identity and identity/principalId. :type filter: str - :param expand: Comma-separated list of additional properties to be - included in the response. Valid values include `createdTime`, - `changedTime` and `provisioningState`. For example, - `$expand=createdTime,changedTime`. + :param expand: Comma-separated list of additional properties to be included in the response. + Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, + ``$expand=createdTime,changedTime``. :type expand: str - :param top: The 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 - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of GenericResourceExpanded - :rtype: - ~azure.mgmt.resource.resources.v2019_05_01.models.GenericResourceExpandedPaged[~azure.mgmt.resource.resources.v2019_05_01.models.GenericResourceExpanded] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of ResourceListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_by_resource_group.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('ResourceListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response - - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.GenericResourceExpandedPaged(internal_paging, self._deserialize.dependencies, header_dict) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return deserialized - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources'} + return pipeline_response + return ItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources'} # type: ignore def _move_resources_initial( - self, source_resource_group_name, resources=None, target_resource_group=None, custom_headers=None, raw=False, **operation_config): - parameters = models.ResourcesMoveInfo(resources=resources, target_resource_group=target_resource_group) + self, + source_resource_group_name, # type: str + resources=None, # type: Optional[List[str]] + target_resource_group=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.ResourcesMoveInfo(resources=resources, target_resource_group=target_resource_group) + api_version = "2019-05-01" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.move_resources.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'ResourcesMoveInfo') + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [202, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - - def move_resources( - self, source_resource_group_name, resources=None, target_resource_group=None, custom_headers=None, raw=False, polling=True, **operation_config): - """Moves resources from one resource group to another resource group. - - The resources to move must be in the same source resource group. The - target resource group may be in a different subscription. When moving - resources, both the source group and the target group are locked for - the duration of the operation. Write and delete operations are blocked - on the groups until the move completes. . - - :param source_resource_group_name: The name of the resource group - containing the resources to move. + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore + + def begin_move_resources( + self, + source_resource_group_name, # type: str + resources=None, # type: Optional[List[str]] + target_resource_group=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """The resources to move must be in the same source resource group. The target resource group may be in a different subscription. When moving resources, both the source group and the target group are locked for the duration of the operation. Write and delete operations are blocked on the groups until the move completes. + + Moves resources from one resource group to another resource group. + + :param source_resource_group_name: The name of the resource group containing the resources to + move. :type source_resource_group_name: str :param resources: The IDs of the resources. :type resources: list[str] :param target_resource_group: The target resource group. :type target_resource_group: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns None or - ClientRawResponse if raw==True - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._move_resources_initial( source_resource_group_name=source_resource_group_name, resources=resources, target_resource_group=target_resource_group, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} - + begin_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore def _validate_move_resources_initial( - self, source_resource_group_name, resources=None, target_resource_group=None, custom_headers=None, raw=False, **operation_config): - parameters = models.ResourcesMoveInfo(resources=resources, target_resource_group=target_resource_group) + self, + source_resource_group_name, # type: str + resources=None, # type: Optional[List[str]] + target_resource_group=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.ResourcesMoveInfo(resources=resources, target_resource_group=target_resource_group) + api_version = "2019-05-01" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.validate_move_resources.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'ResourcesMoveInfo') + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [202, 204, 409]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - - def validate_move_resources( - self, source_resource_group_name, resources=None, target_resource_group=None, custom_headers=None, raw=False, polling=True, **operation_config): - """Validates whether resources can be moved from one resource group to - another resource group. - - This operation checks whether the specified resources can be moved to - the target. The resources to move must be in the same source resource - group. The target resource group may be in a different subscription. If - validation succeeds, it returns HTTP response code 204 (no content). If - validation fails, it returns HTTP response code 409 (Conflict) with an - error message. Retrieve the URL in the Location header value to check - the result of the long-running operation. - - :param source_resource_group_name: The name of the resource group - containing the resources to validate for move. + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _validate_move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} # type: ignore + + def begin_validate_move_resources( + self, + source_resource_group_name, # type: str + resources=None, # type: Optional[List[str]] + target_resource_group=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """This operation checks whether the specified resources can be moved to the target. The resources to move must be in the same source resource group. The target resource group may be in a different subscription. If validation succeeds, it returns HTTP response code 204 (no content). If validation fails, it returns HTTP response code 409 (Conflict) with an error message. Retrieve the URL in the Location header value to check the result of the long-running operation. + + Validates whether resources can be moved from one resource group to another resource group. + + :param source_resource_group_name: The name of the resource group containing the resources to + validate for move. :type source_resource_group_name: str :param resources: The IDs of the resources. :type resources: list[str] :param target_resource_group: The target resource group. :type target_resource_group: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns None or - ClientRawResponse if raw==True - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._validate_move_resources_initial( source_resource_group_name=source_resource_group_name, resources=resources, target_resource_group=target_resource_group, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - validate_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} + begin_validate_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} # type: ignore def list( - self, filter=None, expand=None, top=None, custom_headers=None, raw=False, **operation_config): + self, + filter=None, # type: Optional[str] + expand=None, # type: Optional[str] + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.ResourceListResult"] """Get all the resources in a subscription. - :param filter: The filter to apply on the operation.

The - properties you can use for eq (equals) or ne (not equals) are: - location, resourceType, name, resourceGroup, identity, - identity/principalId, plan, plan/publisher, plan/product, plan/name, - plan/version, and plan/promotionCode.

For example, to filter by - a resource type, use: $filter=resourceType eq - 'Microsoft.Network/virtualNetworks'

You can use - substringof(value, property) in the filter. The properties you can use - for substring are: name and resourceGroup.

For example, to get - all resources with 'demo' anywhere in the name, use: - $filter=substringof('demo', name)

You can link more than one - substringof together by adding and/or operators.

You can filter - by tag names and values. For example, to filter for a tag name and - value, use $filter=tagName eq 'tag1' and tagValue eq - 'Value1'

You can use some properties together when filtering. - The combinations you can use are: substringof and/or resourceType, - plan and plan/publisher and plan/name, identity and - identity/principalId. + :param filter: The filter to apply on the operation.:code:`
`:code:`
`The properties you + can use for eq (equals) or ne (not equals) are: location, resourceType, name, resourceGroup, + identity, identity/principalId, plan, plan/publisher, plan/product, plan/name, plan/version, + and plan/promotionCode.:code:`
`:code:`
`For example, to filter by a resource type, use: + $filter=resourceType eq 'Microsoft.Network/virtualNetworks':code:`
`:code:`
`You can use + substringof(value, property) in the filter. The properties you can use for substring are: name + and resourceGroup.:code:`
`:code:`
`For example, to get all resources with 'demo' + anywhere in the name, use: $filter=substringof('demo', name):code:`
`:code:`
`You can + link more than one substringof together by adding and/or operators.:code:`
`:code:`
`You + can filter by tag names and values. For example, to filter for a tag name and value, use + $filter=tagName eq 'tag1' and tagValue eq 'Value1':code:`
`:code:`
`You can use some + properties together when filtering. The combinations you can use are: substringof and/or + resourceType, plan and plan/publisher and plan/name, identity and identity/principalId. :type filter: str - :param expand: Comma-separated list of additional properties to be - included in the response. Valid values include `createdTime`, - `changedTime` and `provisioningState`. For example, - `$expand=createdTime,changedTime`. + :param expand: Comma-separated list of additional properties to be included in the response. + Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, + ``$expand=createdTime,changedTime``. :type expand: str - :param top: The number of results to return. If null is passed, - returns all resource groups. + :param top: The number of results to return. If null is passed, returns all resource groups. :type top: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of GenericResourceExpanded - :rtype: - ~azure.mgmt.resource.resources.v2019_05_01.models.GenericResourceExpandedPaged[~azure.mgmt.resource.resources.v2019_05_01.models.GenericResourceExpanded] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of ResourceListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['url'] + url = self.list.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_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 = {} + 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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('ResourceListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.GenericResourceExpandedPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resources'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resources'} # type: ignore def check_existence( - self, resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, api_version, custom_headers=None, raw=False, **operation_config): + self, + 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: (...) -> None """Checks whether a resource exists. - :param resource_group_name: The name of the resource group containing - the resource to check. The name is case insensitive. + :param resource_group_name: The name of the resource group containing the resource to check. + The name is case insensitive. :type resource_group_name: str - :param resource_provider_namespace: The resource provider of the - resource to check. + :param resource_provider_namespace: The resource provider of the resource to check. :type resource_provider_namespace: str :param parent_resource_path: The parent resource identity. :type parent_resource_path: str :param resource_type: The resource type. :type resource_type: str - :param resource_name: The name of the resource to check whether it - exists. + :param resource_name: The name of the resource to check whether it exists. :type resource_name: str - :param api_version: The API version to use for the operation. - :type api_version: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: bool or ClientRawResponse if raw=true - :rtype: bool or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-01" + # Construct URL - url = self.check_existence.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204, 404]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = (response.status_code == 204) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - return deserialized - check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + 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, resource_provider_namespace, parent_resource_path, resource_type, resource_name, api_version, custom_headers=None, raw=False, **operation_config): + self, + 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: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-01" + # Construct URL - url = self.delete.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - - def delete( - self, resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, api_version, custom_headers=None, raw=False, polling=True, **operation_config): + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + def begin_delete( + self, + 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: (...) -> LROPoller """Deletes a resource. - :param resource_group_name: The name of the resource group that - contains the resource to delete. The name is case insensitive. + :param resource_group_name: The name of the resource group that contains the resource to + delete. The name is case insensitive. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource - provider. + :param resource_provider_namespace: The namespace of the resource provider. :type resource_provider_namespace: str :param parent_resource_path: The parent resource identity. :type parent_resource_path: str @@ -560,109 +579,122 @@ def delete( :type resource_type: str :param resource_name: The name of the resource to delete. :type resource_name: str - :param api_version: The API version to use for the operation. - :type api_version: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns None or - ClientRawResponse if raw==True - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._delete_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, - api_version=api_version, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} - + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore def _create_or_update_initial( - self, resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, api_version, parameters, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + parameters, # type: "models.GenericResource" + **kwargs # type: Any + ): + # type: (...) -> "models.GenericResource" + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {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.create_or_update.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'GenericResource') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 201, 202]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('GenericResource', response) + deserialized = self._deserialize('GenericResource', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('GenericResource', response) + deserialized = self._deserialize('GenericResource', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - - def create_or_update( - self, resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, api_version, parameters, custom_headers=None, raw=False, polling=True, **operation_config): + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + def begin_create_or_update( + self, + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + parameters, # type: "models.GenericResource" + **kwargs # type: Any + ): + # type: (...) -> LROPoller """Creates a resource. - :param resource_group_name: The name of the resource group for the - resource. The name is case insensitive. + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource - provider. + :param resource_provider_namespace: The namespace of the resource provider. :type resource_provider_namespace: str :param parent_resource_path: The parent resource identity. :type parent_resource_path: str @@ -670,117 +702,125 @@ def create_or_update( :type resource_type: str :param resource_name: The name of the resource to create. :type resource_name: str - :param api_version: The API version to use for the operation. - :type api_version: str :param parameters: Parameters for creating or updating the resource. - :type parameters: - ~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :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 polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns GenericResource or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 GenericResource + :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] + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._create_or_update_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, - api_version=api_version, parameters=parameters, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - deserialized = self._deserialize('GenericResource', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('GenericResource', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} - + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore def _update_initial( - self, resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, api_version, parameters, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + parameters, # type: "models.GenericResource" + **kwargs # type: Any + ): + # type: (...) -> "models.GenericResource" + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {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.update.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'GenericResource') # Construct and send request - request = self._client.patch(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 202]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('GenericResource', response) + deserialized = self._deserialize('GenericResource', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - - def update( - self, resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, api_version, parameters, custom_headers=None, raw=False, polling=True, **operation_config): + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + def begin_update( + self, + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + parameters, # type: "models.GenericResource" + **kwargs # type: Any + ): + # type: (...) -> LROPoller """Updates a resource. - :param resource_group_name: The name of the resource group for the - resource. The name is case insensitive. + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource - provider. + :param resource_provider_namespace: The namespace of the resource provider. :type resource_provider_namespace: str :param parent_resource_path: The parent resource identity. :type parent_resource_path: str @@ -788,64 +828,63 @@ def update( :type resource_type: str :param resource_name: The name of the resource to update. :type resource_name: str - :param api_version: The API version to use for the operation. - :type api_version: str :param parameters: Parameters for updating the resource. - :type parameters: - ~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :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 polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns GenericResource or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 GenericResource + :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] + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._update_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, - api_version=api_version, parameters=parameters, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - deserialized = self._deserialize('GenericResource', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('GenericResource', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore def get( - self, resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, api_version, custom_headers=None, raw=False, **operation_config): + self, + 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: (...) -> "models.GenericResource" """Gets a resource. - :param resource_group_name: The name of the resource group containing - the resource to get. The name is case insensitive. + :param resource_group_name: The name of the resource group containing the resource to get. The + name is case insensitive. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource - provider. + :param resource_provider_namespace: The namespace of the resource provider. :type resource_provider_namespace: str :param parent_resource_path: The parent resource identity. :type parent_resource_path: str @@ -853,461 +892,443 @@ def get( :type resource_type: str :param resource_name: The name of the resource to get. :type resource_name: str - :param api_version: The API version to use for the operation. - :type api_version: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: GenericResource or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GenericResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-01" + # Construct URL - url = self.get.metadata['url'] + url = self.get.metadata['url'] # type: 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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('GenericResource', response) + deserialized = self._deserialize('GenericResource', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore def check_existence_by_id( - self, resource_id, api_version, custom_headers=None, raw=False, **operation_config): + self, + resource_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Checks by ID whether a resource exists. - :param resource_id: The fully qualified ID of the resource, including - the resource name and resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. :type resource_id: str - :param api_version: The API version to use for the operation. - :type api_version: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: bool or ClientRawResponse if raw=true - :rtype: bool or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-01" + # Construct URL - url = self.check_existence_by_id.metadata['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) + '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 = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204, 404]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = (response.status_code == 204) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - return deserialized - check_existence_by_id.metadata = {'url': '/{resourceId}'} + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + return 200 <= response.status_code <= 299 + check_existence_by_id.metadata = {'url': '/{resourceId}'} # type: ignore def _delete_by_id_initial( - self, resource_id, api_version, custom_headers=None, raw=False, **operation_config): + self, + resource_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-01" + # Construct URL - url = self.delete_by_id.metadata['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) + '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 = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + _delete_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore - def delete_by_id( - self, resource_id, api_version, custom_headers=None, raw=False, polling=True, **operation_config): + def begin_delete_by_id( + self, + resource_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> LROPoller """Deletes a resource by ID. - :param resource_id: The fully qualified ID of the resource, including - the resource name and resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. :type resource_id: str - :param api_version: The API version to use for the operation. - :type api_version: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns None or - ClientRawResponse if raw==True - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._delete_by_id_initial( resource_id=resource_id, - api_version=api_version, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - delete_by_id.metadata = {'url': '/{resourceId}'} - + begin_delete_by_id.metadata = {'url': '/{resourceId}'} # type: ignore def _create_or_update_by_id_initial( - self, resource_id, api_version, parameters, custom_headers=None, raw=False, **operation_config): + self, + resource_id, # type: str + parameters, # type: "models.GenericResource" + **kwargs # type: Any + ): + # type: (...) -> "models.GenericResource" + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {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.create_or_update_by_id.metadata['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) + '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 = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'GenericResource') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 201, 202]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('GenericResource', response) + deserialized = self._deserialize('GenericResource', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('GenericResource', response) + deserialized = self._deserialize('GenericResource', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - - def create_or_update_by_id( - self, resource_id, api_version, parameters, custom_headers=None, raw=False, polling=True, **operation_config): + _create_or_update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + def begin_create_or_update_by_id( + self, + resource_id, # type: str + parameters, # type: "models.GenericResource" + **kwargs # type: Any + ): + # type: (...) -> LROPoller """Create a resource by ID. - :param resource_id: The fully qualified ID of the resource, including - the resource name and resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. :type resource_id: str - :param api_version: The API version to use for the operation. - :type api_version: str :param parameters: Create or update resource parameters. - :type parameters: - ~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :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 polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns GenericResource or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 GenericResource + :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] + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._create_or_update_by_id_initial( resource_id=resource_id, - api_version=api_version, parameters=parameters, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - deserialized = self._deserialize('GenericResource', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('GenericResource', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - create_or_update_by_id.metadata = {'url': '/{resourceId}'} - + begin_create_or_update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore def _update_by_id_initial( - self, resource_id, api_version, parameters, custom_headers=None, raw=False, **operation_config): + self, + resource_id, # type: str + parameters, # type: "models.GenericResource" + **kwargs # type: Any + ): + # type: (...) -> "models.GenericResource" + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {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.update_by_id.metadata['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) + '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 = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'GenericResource') # Construct and send request - request = self._client.patch(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 202]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('GenericResource', response) + deserialized = self._deserialize('GenericResource', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - - def update_by_id( - self, resource_id, api_version, parameters, custom_headers=None, raw=False, polling=True, **operation_config): + _update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + def begin_update_by_id( + self, + resource_id, # type: str + parameters, # type: "models.GenericResource" + **kwargs # type: Any + ): + # type: (...) -> LROPoller """Updates a resource by ID. - :param resource_id: The fully qualified ID of the resource, including - the resource name and resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. :type resource_id: str - :param api_version: The API version to use for the operation. - :type api_version: str :param parameters: Update resource parameters. - :type parameters: - ~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :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 polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns GenericResource or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 GenericResource + :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] + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._update_by_id_initial( resource_id=resource_id, - api_version=api_version, parameters=parameters, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - deserialized = self._deserialize('GenericResource', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('GenericResource', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - update_by_id.metadata = {'url': '/{resourceId}'} + begin_update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore def get_by_id( - self, resource_id, api_version, custom_headers=None, raw=False, **operation_config): + self, + resource_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.GenericResource" """Gets a resource by ID. - :param resource_id: The fully qualified ID of the resource, including - the resource name and resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. :type resource_id: str - :param api_version: The API version to use for the operation. - :type api_version: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: GenericResource or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GenericResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.GenericResource + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-01" + # Construct URL - url = self.get_by_id.metadata['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) + '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 = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('GenericResource', response) + deserialized = self._deserialize('GenericResource', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/{resourceId}'} + 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 64cedaf97d4b..74e6d5197c8a 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 @@ -1,340 +1,336 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class TagsOperations(object): """TagsOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2019_05_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for this operation. Constant value: "2019-05-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-05-01" - - self.config = config + self._config = config def delete_value( - self, tag_name, tag_value, custom_headers=None, raw=False, **operation_config): + self, + tag_name, # type: str + tag_value, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Deletes a tag value. :param tag_name: The name of the tag. :type tag_name: str :param tag_value: The value of the tag to delete. :type tag_value: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-01" + # Construct URL - url = self.delete_value.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} + delete_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore def create_or_update_value( - self, tag_name, tag_value, custom_headers=None, raw=False, **operation_config): + self, + tag_name, # type: str + tag_value, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.TagValue" """Creates a tag value. The name of the tag must already exist. :param tag_name: The name of the tag. :type tag_name: str :param tag_value: The value of the tag to create. :type tag_value: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: TagValue or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.TagValue or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagValue or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.TagValue + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TagValue"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-01" + # Construct URL - url = self.create_or_update_value.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.put(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 201]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('TagValue', response) + deserialized = self._deserialize('TagValue', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('TagValue', response) + deserialized = self._deserialize('TagValue', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} + create_or_update_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore def create_or_update( - self, tag_name, custom_headers=None, raw=False, **operation_config): - """Creates a tag in the subscription. + self, + tag_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.TagDetails" + """The tag name can have a maximum of 512 characters and is case insensitive. Tag names created by Azure have prefixes of microsoft, azure, or windows. You cannot create tags with one of these prefixes. - The tag name can have a maximum of 512 characters and is case - insensitive. Tag names created by Azure have prefixes of microsoft, - azure, or windows. You cannot create tags with one of these prefixes. + Creates a tag in the subscription. :param tag_name: The name of the tag to create. :type tag_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: TagDetails or ClientRawResponse if raw=true + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagDetails or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_01.models.TagDetails - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TagDetails"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-01" + # Construct URL - url = self.create_or_update.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.put(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 201]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('TagDetails', response) + deserialized = self._deserialize('TagDetails', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('TagDetails', response) + deserialized = self._deserialize('TagDetails', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore def delete( - self, tag_name, custom_headers=None, raw=False, **operation_config): - """Deletes a tag from the subscription. + self, + tag_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """You must remove all values from a resource tag before you can delete it. - You must remove all values from a resource tag before you can delete - it. + Deletes a tag from the subscription. :param tag_name: The name of the tag. :type tag_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-01" + # Construct URL - url = self.delete.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} + delete.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore def list( - self, custom_headers=None, raw=False, **operation_config): - """Gets the names and values of all resource tags that are defined in a - subscription. - - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of TagDetails - :rtype: - ~azure.mgmt.resource.resources.v2019_05_01.models.TagDetailsPaged[~azure.mgmt.resource.resources.v2019_05_01.models.TagDetails] - :raises: :class:`CloudError` + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.TagsListResult"] + """Gets the names and values of all resource tags that are defined in a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of TagsListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['url'] + url = self.list.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('TagsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.TagDetailsPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/py.typed b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file 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 deleted file mode 100644 index a0f07a74dc04..000000000000 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_01/version.py +++ /dev/null @@ -1,13 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -VERSION = "2019-05-01" - 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 68bc897193ac..fde2ed4c3b83 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 @@ -1,19 +1,16 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._configuration import ResourceManagementClientConfiguration from ._resource_management_client import ResourceManagementClient -__all__ = ['ResourceManagementClient', 'ResourceManagementClientConfiguration'] - -from .version import VERSION - -__version__ = VERSION +__all__ = ['ResourceManagementClient'] +try: + from ._patch import patch_sdk + patch_sdk() +except ImportError: + pass 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 3b326f792363..1d0e638f39b8 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 @@ -1,48 +1,69 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrestazure import AzureConfiguration -from .version import VERSION +from typing import TYPE_CHECKING +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + + from azure.core.credentials import TokenCredential + +VERSION = "unknown" + +class ResourceManagementClientConfiguration(Configuration): + """Configuration for ResourceManagementClient. -class ResourceManagementClientConfiguration(AzureConfiguration): - """Configuration for ResourceManagementClient Note that all parameters used to create this instance are saved as instance attributes. - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` + :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 """ def __init__( - self, credentials, subscription_id, base_url=None): - - if credentials is None: - raise ValueError("Parameter 'credentials' must not be None.") + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + 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.") - if not base_url: - base_url = 'https://management.azure.com' + super(ResourceManagementClientConfiguration, self).__init__(**kwargs) - super(ResourceManagementClientConfiguration, self).__init__(base_url) - - # Starting Autorest.Python 4.0.64, make connection pool activated by default - self.keep_alive = True - - self.add_user_agent('azure-mgmt-resource/{}'.format(VERSION)) - self.add_user_agent('Azure-SDK-For-Python') - - self.credentials = credentials + self.credential = credential self.subscription_id = subscription_id + self.api_version = "2019-05-10" + self.credential_scopes = ['https://management.azure.com/.default'] + self.credential_scopes.extend(kwargs.pop('credential_scopes', [])) + kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + 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) 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 new file mode 100644 index 000000000000..5e026fb92cab --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/_metadata.json @@ -0,0 +1,59 @@ +{ + "chosen_version": "2019-05-10", + "total_api_version_list": ["2019-05-10"], + "client": { + "name": "ResourceManagementClient", + "filename": "_resource_management_client", + "description": "Provides operations for working with resources and resource groups." + }, + "global_parameters": { + "sync_method": { + "credential": { + "method_signature": "credential, # type: \"TokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials.TokenCredential", + "required": true + }, + "subscription_id": { + "method_signature": "subscription_id, # type: str", + "description": "The ID of the target subscription.", + "docstring_type": "str", + "required": true + } + }, + "async_method": { + "credential": { + "method_signature": "credential, # type: \"AsyncTokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + }, + "subscription_id": { + "method_signature": "subscription_id, # type: str", + "description": "The ID of the target subscription.", + "docstring_type": "str", + "required": true + } + }, + "constant": { + }, + "call": "credential, subscription_id" + }, + "config": { + "credential": true, + "credential_scopes": ["https://management.azure.com/.default"] + }, + "operation_groups": { + "operations": "Operations", + "deployments": "DeploymentsOperations", + "providers": "ProvidersOperations", + "resources": "ResourcesOperations", + "resource_groups": "ResourceGroupsOperations", + "tags": "TagsOperations", + "deployment_operations": "DeploymentOperationsOperations" + }, + "operation_mixins": { + }, + "sync_imports": "None", + "async_imports": "None" +} \ 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 4c0fc85cf417..849c180921e7 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 @@ -1,16 +1,19 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.service_client import SDKClient -from msrest import Serializer, Deserializer +from typing import TYPE_CHECKING + +from azure.mgmt.core import ARMPipelineClient +from msrest import Deserializer, Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional from ._configuration import ResourceManagementClientConfiguration from .operations import Operations @@ -19,61 +22,76 @@ from .operations import ResourcesOperations from .operations import ResourceGroupsOperations from .operations import TagsOperations -from .operations import DeploymentOperations +from .operations import DeploymentOperationsOperations from . import models -class ResourceManagementClient(SDKClient): +class ResourceManagementClient(object): """Provides operations for working with resources and resource groups. - :ivar config: Configuration for client. - :vartype config: ResourceManagementClientConfiguration - :ivar operations: Operations operations :vartype operations: azure.mgmt.resource.resources.v2019_05_10.operations.Operations - :ivar deployments: Deployments operations + :ivar deployments: DeploymentsOperations operations :vartype deployments: azure.mgmt.resource.resources.v2019_05_10.operations.DeploymentsOperations - :ivar providers: Providers operations + :ivar providers: ProvidersOperations operations :vartype providers: azure.mgmt.resource.resources.v2019_05_10.operations.ProvidersOperations - :ivar resources: Resources operations + :ivar resources: ResourcesOperations operations :vartype resources: azure.mgmt.resource.resources.v2019_05_10.operations.ResourcesOperations - :ivar resource_groups: ResourceGroups operations + :ivar resource_groups: ResourceGroupsOperations operations :vartype resource_groups: azure.mgmt.resource.resources.v2019_05_10.operations.ResourceGroupsOperations - :ivar tags: Tags operations + :ivar tags: TagsOperations operations :vartype tags: azure.mgmt.resource.resources.v2019_05_10.operations.TagsOperations - :ivar deployment_operations: DeploymentOperations operations - :vartype deployment_operations: azure.mgmt.resource.resources.v2019_05_10.operations.DeploymentOperations - - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` + :ivar deployment_operations: DeploymentOperationsOperations operations + :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. """ def __init__( - self, credentials, subscription_id, base_url=None): - - self.config = ResourceManagementClientConfiguration(credentials, subscription_id, base_url) - super(ResourceManagementClient, self).__init__(self.config.credentials, self.config) + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = 'https://management.azure.com' + self._config = ResourceManagementClientConfiguration(credential, 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.api_version = '2019-05-10' self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self.operations = Operations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.deployments = DeploymentsOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.providers = ProvidersOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.resources = ResourcesOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.resource_groups = ResourceGroupsOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.tags = TagsOperations( - self._client, self.config, self._serialize, self._deserialize) - self.deployment_operations = DeploymentOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) + self.deployment_operations = DeploymentOperationsOperations( + self._client, self._config, self._serialize, self._deserialize) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> ResourceManagementClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) 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 new file mode 100644 index 000000000000..7f9b1bac71c5 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/__init__.py @@ -0,0 +1,10 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._resource_management_client_async import ResourceManagementClient +__all__ = ['ResourceManagementClient'] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/_configuration_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/_configuration_async.py new file mode 100644 index 000000000000..2d4eb4355cd8 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/_configuration_async.py @@ -0,0 +1,65 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + +VERSION = "unknown" + +class ResourceManagementClientConfiguration(Configuration): + """Configuration for ResourceManagementClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :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 + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + 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 + self.api_version = "2019-05-10" + self.credential_scopes = ['https://management.azure.com/.default'] + self.credential_scopes.extend(kwargs.pop('credential_scopes', [])) + kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs: Any + ) -> None: + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + 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) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/_resource_management_client_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/_resource_management_client_async.py new file mode 100644 index 000000000000..32e77f7d51e1 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/_resource_management_client_async.py @@ -0,0 +1,89 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, Optional + +from azure.mgmt.core import AsyncARMPipelineClient +from msrest import Deserializer, Serializer + +from ._configuration_async import ResourceManagementClientConfiguration +from .operations_async import Operations +from .operations_async import DeploymentsOperations +from .operations_async import ProvidersOperations +from .operations_async import ResourcesOperations +from .operations_async import ResourceGroupsOperations +from .operations_async import TagsOperations +from .operations_async import DeploymentOperationsOperations +from .. import models + + +class ResourceManagementClient(object): + """Provides operations for working with resources and resource groups. + + :ivar operations: Operations operations + :vartype operations: azure.mgmt.resource.resources.v2019_05_10.aio.operations_async.Operations + :ivar deployments: DeploymentsOperations operations + :vartype deployments: azure.mgmt.resource.resources.v2019_05_10.aio.operations_async.DeploymentsOperations + :ivar providers: ProvidersOperations operations + :vartype providers: azure.mgmt.resource.resources.v2019_05_10.aio.operations_async.ProvidersOperations + :ivar resources: ResourcesOperations operations + :vartype resources: azure.mgmt.resource.resources.v2019_05_10.aio.operations_async.ResourcesOperations + :ivar resource_groups: ResourceGroupsOperations operations + :vartype resource_groups: azure.mgmt.resource.resources.v2019_05_10.aio.operations_async.ResourceGroupsOperations + :ivar tags: TagsOperations operations + :vartype tags: azure.mgmt.resource.resources.v2019_05_10.aio.operations_async.TagsOperations + :ivar deployment_operations: DeploymentOperationsOperations operations + :vartype deployment_operations: azure.mgmt.resource.resources.v2019_05_10.aio.operations_async.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. + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: Optional[str] = None, + **kwargs: 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) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + + self.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 close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "ResourceManagementClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/operations_async/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/operations_async/__init__.py new file mode 100644 index 000000000000..f1fd8637fa69 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/operations_async/__init__.py @@ -0,0 +1,25 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._operations_async import Operations +from ._deployments_operations_async import DeploymentsOperations +from ._providers_operations_async import ProvidersOperations +from ._resources_operations_async import ResourcesOperations +from ._resource_groups_operations_async import ResourceGroupsOperations +from ._tags_operations_async import TagsOperations +from ._deployment_operations_operations_async import DeploymentOperationsOperations + +__all__ = [ + 'Operations', + 'DeploymentsOperations', + 'ProvidersOperations', + 'ResourcesOperations', + 'ResourceGroupsOperations', + 'TagsOperations', + 'DeploymentOperationsOperations', +] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/operations_async/_deployment_operations_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/operations_async/_deployment_operations_operations_async.py new file mode 100644 index 000000000000..3ed913558069 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/operations_async/_deployment_operations_operations_async.py @@ -0,0 +1,440 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import 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 ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class DeploymentOperationsOperations: + """DeploymentOperationsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2019_05_10.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def get_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + operation_id: str, + **kwargs + ) -> "models.DeploymentOperation": + """Gets a deployments operation. + + :param group_id: The management group ID. + :type group_id: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param operation_id: The ID of the operation to get. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentOperation or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentOperation + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentOperation"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-10" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentOperation', pipeline_response) + + if cls: + 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 + + def list_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.DeploymentOperationsListResult"]: + """Gets all deployments operations for a deployment. + + :param group_id: The management group ID. + :type group_id: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-10" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentOperationsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + 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 + + async def get_at_subscription_scope( + self, + deployment_name: str, + operation_id: str, + **kwargs + ) -> "models.DeploymentOperation": + """Gets a deployments operation. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param operation_id: The ID of the operation to get. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentOperation or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentOperation + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentOperation"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-10" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentOperation', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + def list_at_subscription_scope( + self, + deployment_name: str, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.DeploymentOperationsListResult"]: + """Gets all deployments operations for a deployment. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-10" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentOperationsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + 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 + + async def get( + self, + resource_group_name: str, + deployment_name: str, + operation_id: str, + **kwargs + ) -> "models.DeploymentOperation": + """Gets a deployments operation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param operation_id: The ID of the operation to get. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentOperation or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentOperation + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentOperation"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-10" + + # Construct URL + url = self.get.metadata['url'] # type: 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentOperation', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + def list( + self, + resource_group_name: str, + deployment_name: str, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.DeploymentOperationsListResult"]: + """Gets all deployments operations for a deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-10" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentOperationsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/operations_async/_deployments_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/operations_async/_deployments_operations_async.py new file mode 100644 index 000000000000..03dee13c307a --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/operations_async/_deployments_operations_async.py @@ -0,0 +1,1786 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.polling import AsyncNoPolling, AsyncPollingMethod, async_poller +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class DeploymentsOperations: + """DeploymentsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2019_05_10.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def _delete_at_management_group_scope_initial( + self, + group_id: str, + deployment_name: str, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_at_management_group_scope_initial.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def delete_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + **kwargs + ) -> None: + """A template deployment that is currently running cannot be deleted. Deleting a template deployment removes the associated deployment operations. This is an asynchronous operation that returns a status of 202 until the template deployment is successfully deleted. The Location response header contains the URI that is used to obtain the status of the process. While the process is running, a call to the URI in the Location header returns a status of 202. When the process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. + + Deletes a deployment from the deployment history. + + :param group_id: The management group ID. + :type group_id: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._delete_at_management_group_scope_initial( + group_id=group_id, + deployment_name=deployment_name, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + delete_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def check_existence_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + **kwargs + ) -> None: + """Checks whether the deployment exists. + + :param group_id: The management group ID. + :type group_id: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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] + + # Construct and send request + 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 + + if response.status_code not in [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + 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, + deployment_name: str, + properties: "models.DeploymentProperties", + location: Optional[str] = None, + **kwargs + ) -> "models.DeploymentExtended": + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.Deployment(location=location, properties=properties) + api_version = "2019-05-10" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + 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 + + async def create_or_update_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + properties: "models.DeploymentProperties", + location: Optional[str] = None, + **kwargs + ) -> "models.DeploymentExtended": + """You can provide the template and parameters directly in the request or link to JSON files. + + Deploys resources at management group scope. + + :param group_id: The management group ID. + :type group_id: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param properties: The deployment properties. + :type properties: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentProperties + :param location: The location to store the deployment data. + :type location: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: DeploymentExtended + :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentExtended + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._create_or_update_at_management_group_scope_initial( + group_id=group_id, + deployment_name=deployment_name, + properties=properties, + location=location, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + create_or_update_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def get_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + **kwargs + ) -> "models.DeploymentExtended": + """Gets a deployment. + + :param group_id: The management group ID. + :type group_id: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExtended or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentExtended + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-10" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + 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 + + async def cancel_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + **kwargs + ) -> None: + """You can cancel a deployment only if the provisioningState is Accepted or Running. After the deployment is canceled, the provisioningState is set to Canceled. Canceling a template deployment stops the currently running template deployment and leaves the resources partially deployed. + + Cancels a currently running template deployment. + + :param group_id: The management group ID. + :type group_id: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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] + + # Construct and send request + 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 [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + 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( + self, + group_id: str, + deployment_name: str, + properties: "models.DeploymentProperties", + location: Optional[str] = None, + **kwargs + ) -> "models.DeploymentValidateResult": + """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. + + :param group_id: The management group ID. + :type group_id: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param properties: The deployment properties. + :type properties: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentProperties + :param location: The location to store the deployment data. + :type location: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentValidateResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentValidateResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.Deployment(location=location, properties=properties) + api_version = "2019-05-10" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 400]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + + if response.status_code == 400: + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + + if cls: + 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 + + async def export_template_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + **kwargs + ) -> "models.DeploymentExportResult": + """Exports the template used for specified deployment. + + :param group_id: The management group ID. + :type group_id: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentExportResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExportResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-10" + + # 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'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + + if cls: + 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 + + def list_at_management_group_scope( + self, + group_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.DeploymentListResult"]: + """Get all the deployments for a management group. + + :param group_id: The management group ID. + :type group_id: str + :param filter: The filter to apply on the operation. For example, you can use + $filter=provisioningState eq '{state}'. + :type filter: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-10" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + 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/'} # type: ignore + + async def _delete_at_subscription_scope_initial( + self, + deployment_name: str, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def delete_at_subscription_scope( + self, + deployment_name: str, + **kwargs + ) -> None: + """A template deployment that is currently running cannot be deleted. Deleting a template deployment removes the associated deployment operations. This is an asynchronous operation that returns a status of 202 until the template deployment is successfully deleted. The Location response header contains the URI that is used to obtain the status of the process. While the process is running, a call to the URI in the Location header returns a status of 202. When the process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. + + Deletes a deployment from the deployment history. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._delete_at_subscription_scope_initial( + deployment_name=deployment_name, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + delete_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def check_existence_at_subscription_scope( + self, + deployment_name: str, + **kwargs + ) -> None: + """Checks whether the deployment exists. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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] + + # Construct and send request + 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 + + if response.status_code not in [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + 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, + properties: "models.DeploymentProperties", + location: Optional[str] = None, + **kwargs + ) -> "models.DeploymentExtended": + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.Deployment(location=location, properties=properties) + api_version = "2019-05-10" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + 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 + + async def create_or_update_at_subscription_scope( + self, + deployment_name: str, + properties: "models.DeploymentProperties", + location: Optional[str] = None, + **kwargs + ) -> "models.DeploymentExtended": + """You can provide the template and parameters directly in the request or link to JSON files. + + Deploys resources at subscription scope. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param properties: The deployment properties. + :type properties: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentProperties + :param location: The location to store the deployment data. + :type location: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: DeploymentExtended + :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentExtended + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._create_or_update_at_subscription_scope_initial( + deployment_name=deployment_name, + properties=properties, + location=location, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + create_or_update_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def get_at_subscription_scope( + self, + deployment_name: str, + **kwargs + ) -> "models.DeploymentExtended": + """Gets a deployment. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExtended or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentExtended + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-10" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def cancel_at_subscription_scope( + self, + deployment_name: str, + **kwargs + ) -> None: + """You can cancel a deployment only if the provisioningState is Accepted or Running. After the deployment is canceled, the provisioningState is set to Canceled. Canceling a template deployment stops the currently running template deployment and leaves the resources partially deployed. + + Cancels a currently running template deployment. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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] + + # Construct and send request + 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 [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + cancel_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + + async def validate_at_subscription_scope( + self, + deployment_name: str, + properties: "models.DeploymentProperties", + location: Optional[str] = None, + **kwargs + ) -> "models.DeploymentValidateResult": + """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param properties: The deployment properties. + :type properties: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentProperties + :param location: The location to store the deployment data. + :type location: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentValidateResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentValidateResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.Deployment(location=location, properties=properties) + api_version = "2019-05-10" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 400]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + + if response.status_code == 400: + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + + if cls: + 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 export_template_at_subscription_scope( + self, + deployment_name: str, + **kwargs + ) -> "models.DeploymentExportResult": + """Exports the template used for specified deployment. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentExportResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExportResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-10" + + # 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'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + export_template_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + def list_at_subscription_scope( + self, + filter: Optional[str] = None, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.DeploymentListResult"]: + """Get all the deployments for a subscription. + + :param filter: The filter to apply on the operation. For example, you can use + $filter=provisioningState eq '{state}'. + :type filter: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-10" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/'} # type: ignore + + async def _delete_initial( + self, + resource_group_name: str, + deployment_name: str, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def delete( + self, + resource_group_name: str, + deployment_name: str, + **kwargs + ) -> None: + """A template deployment that is currently running cannot be deleted. Deleting a template deployment removes the associated deployment operations. Deleting a template deployment does not affect the state of the resource group. This is an asynchronous operation that returns a status of 202 until the template deployment is successfully deleted. The Location response header contains the URI that is used to obtain the status of the process. While the process is running, a call to the URI in the Location header returns a status of 202. When the process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. + + Deletes a deployment from the deployment history. + + :param resource_group_name: The name of the resource group with the deployment to delete. The + name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def check_existence( + self, + resource_group_name: str, + deployment_name: str, + **kwargs + ) -> None: + """Checks whether the deployment exists. + + :param resource_group_name: The name of the resource group with the deployment to check. The + name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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] + + # Construct and send request + 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 + + if response.status_code not in [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + 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, + deployment_name: str, + properties: "models.DeploymentProperties", + location: Optional[str] = None, + **kwargs + ) -> "models.DeploymentExtended": + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.Deployment(location=location, properties=properties) + api_version = "2019-05-10" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def create_or_update( + self, + resource_group_name: str, + deployment_name: str, + properties: "models.DeploymentProperties", + location: Optional[str] = None, + **kwargs + ) -> "models.DeploymentExtended": + """You can provide the template and parameters directly in the request or link to JSON files. + + Deploys resources to a resource group. + + :param resource_group_name: The name of the resource group to deploy the resources to. The name + is case insensitive. The resource group must already exist. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param properties: The deployment properties. + :type properties: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentProperties + :param location: The location to store the deployment data. + :type location: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: DeploymentExtended + :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentExtended + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + properties=properties, + location=location, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def get( + self, + resource_group_name: str, + deployment_name: str, + **kwargs + ) -> "models.DeploymentExtended": + """Gets a deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExtended or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentExtended + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-10" + + # Construct URL + url = self.get.metadata['url'] # type: 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def cancel( + self, + resource_group_name: str, + deployment_name: str, + **kwargs + ) -> None: + """You can cancel a deployment only if the provisioningState is Accepted or Running. After the deployment is canceled, the provisioningState is set to Canceled. Canceling a template deployment stops the currently running template deployment and leaves the resource group partially deployed. + + Cancels a currently running template deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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] + + # Construct and send request + 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 [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + cancel.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + + async def validate( + self, + resource_group_name: str, + deployment_name: str, + properties: "models.DeploymentProperties", + location: Optional[str] = None, + **kwargs + ) -> "models.DeploymentValidateResult": + """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param properties: The deployment properties. + :type properties: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentProperties + :param location: The location to store the deployment data. + :type location: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentValidateResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentValidateResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.Deployment(location=location, properties=properties) + api_version = "2019-05-10" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 400]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + + if response.status_code == 400: + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + validate.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + async def export_template( + self, + resource_group_name: str, + deployment_name: str, + **kwargs + ) -> "models.DeploymentExportResult": + """Exports the template used for specified deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentExportResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExportResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-10" + + # 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'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + def list_by_resource_group( + self, + resource_group_name: str, + filter: Optional[str] = None, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.DeploymentListResult"]: + """Get all the deployments for a resource group. + + :param resource_group_name: The name of the resource group with the deployments to get. The + name is case insensitive. + :type resource_group_name: str + :param filter: The filter to apply on the operation. For example, you can use + $filter=provisioningState eq '{state}'. + :type filter: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-10" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + 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 + + async def calculate_template_hash( + self, + template: object, + **kwargs + ) -> "models.TemplateHashResult": + """Calculate the hash of the given template. + + :param template: The template provided to calculate hash. + :type template: object + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateHashResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.TemplateHashResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TemplateHashResult"] + error_map = {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.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'] = 'application/json' + + # Construct and send request + 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) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('TemplateHashResult', pipeline_response) + + if cls: + 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_async/_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/operations_async/_operations_async.py new file mode 100644 index 000000000000..8f4b9fdcbb35 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/operations_async/_operations_async.py @@ -0,0 +1,101 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import 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 ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class Operations: + """Operations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2019_05_10.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + **kwargs + ) -> AsyncIterable["models.OperationListResult"]: + """Lists all of the available Microsoft.Resources REST API operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of OperationListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-10" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('OperationListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.Resources/operations'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/operations_async/_providers_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/operations_async/_providers_operations_async.py new file mode 100644 index 000000000000..91cbfe6063d1 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/operations_async/_providers_operations_async.py @@ -0,0 +1,407 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import 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 ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ProvidersOperations: + """ProvidersOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2019_05_10.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def unregister( + self, + resource_provider_namespace: str, + **kwargs + ) -> "models.Provider": + """Unregisters a subscription from a resource provider. + + :param resource_provider_namespace: The namespace of the resource provider to unregister. + :type resource_provider_namespace: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Provider or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.Provider + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Provider"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-10" + + # 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'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Provider', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + unregister.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister'} # type: ignore + + async def register( + self, + resource_provider_namespace: str, + **kwargs + ) -> "models.Provider": + """Registers a subscription with a resource provider. + + :param resource_provider_namespace: The namespace of the resource provider to register. + :type resource_provider_namespace: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Provider or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.Provider + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Provider"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-10" + + # 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'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Provider', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + register.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register'} # type: ignore + + def list( + self, + top: Optional[int] = None, + expand: Optional[str] = None, + **kwargs + ) -> AsyncIterable["models.ProviderListResult"]: + """Gets all resource providers for a subscription. + + :param top: The number of results to return. If null is passed returns all deployments. + :type top: int + :param expand: The properties to include in the results. For example, use &$expand=metadata in + the query string to retrieve resource provider metadata. To include property aliases in + response, use $expand=resourceTypes/aliases. + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of ProviderListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-10" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ProviderListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers'} # type: ignore + + def list_at_tenant_scope( + self, + top: Optional[int] = None, + expand: Optional[str] = None, + **kwargs + ) -> AsyncIterable["models.ProviderListResult"]: + """Gets all resource providers for the tenant. + + :param top: The number of results to return. If null is passed returns all providers. + :type top: int + :param expand: The properties to include in the results. For example, use &$expand=metadata in + the query string to retrieve resource provider metadata. To include property aliases in + response, use $expand=resourceTypes/aliases. + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of ProviderListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-10" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ProviderListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_at_tenant_scope.metadata = {'url': '/providers'} # type: ignore + + async def get( + self, + resource_provider_namespace: str, + expand: Optional[str] = None, + **kwargs + ) -> "models.Provider": + """Gets the specified resource provider. + + :param resource_provider_namespace: The namespace of the resource provider. + :type resource_provider_namespace: str + :param expand: The $expand query parameter. For example, to include property aliases in + response, use $expand=resourceTypes/aliases. + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Provider or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.Provider + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Provider"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-10" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Provider', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}'} # type: ignore + + async def get_at_tenant_scope( + self, + resource_provider_namespace: str, + expand: Optional[str] = None, + **kwargs + ) -> "models.Provider": + """Gets the specified resource provider at the tenant level. + + :param resource_provider_namespace: The namespace of the resource provider. + :type resource_provider_namespace: str + :param expand: The $expand query parameter. For example, to include property aliases in + response, use $expand=resourceTypes/aliases. + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Provider or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.Provider + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Provider"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-10" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Provider', pipeline_response) + + if cls: + 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_async/_resource_groups_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/operations_async/_resource_groups_operations_async.py new file mode 100644 index 000000000000..c0643281c574 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/operations_async/_resource_groups_operations_async.py @@ -0,0 +1,505 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, List, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.polling import AsyncNoPolling, AsyncPollingMethod, async_poller +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ResourceGroupsOperations: + """ResourceGroupsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2019_05_10.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def check_existence( + self, + resource_group_name: str, + **kwargs + ) -> None: + """Checks whether a resource group exists. + + :param resource_group_name: The name of the resource group to check. 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: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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] + + # Construct and send request + 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 + + if response.status_code not in [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + async def create_or_update( + self, + resource_group_name: str, + parameters: "models.ResourceGroup", + **kwargs + ) -> "models.ResourceGroup": + """Creates or updates a resource group. + + :param resource_group_name: The name of the resource group to create or update. Can include + alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters + that match the allowed characters. + :type resource_group_name: str + :param parameters: Parameters supplied to the create or update a resource group. + :type parameters: ~azure.mgmt.resource.resources.v2019_05_10.models.ResourceGroup + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.ResourceGroup + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceGroup"] + error_map = {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.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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ResourceGroup', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ResourceGroup', pipeline_response) + + if cls: + 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, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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] + + # Construct and send request + 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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + async def delete( + self, + resource_group_name: str, + **kwargs + ) -> None: + """When you delete a resource group, all of its resources are also deleted. Deleting a resource group deletes all of its template deployments and currently stored operations. + + Deletes a resource group. + + :param resource_group_name: The name of the resource group to delete. 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 + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + async def get( + self, + resource_group_name: str, + **kwargs + ) -> "models.ResourceGroup": + """Gets a resource group. + + :param resource_group_name: The name of the resource group to get. 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: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.ResourceGroup + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceGroup"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-10" + + # Construct URL + url = self.get.metadata['url'] # type: 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ResourceGroup', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + async def update( + self, + resource_group_name: str, + parameters: "models.ResourceGroupPatchable", + **kwargs + ) -> "models.ResourceGroup": + """Resource groups can be updated through a simple PATCH operation to a group address. The format of the request is the same as that for creating a resource group. If a field is unspecified, the current value is retained. + + Updates a resource group. + + :param resource_group_name: The name of the resource group to update. The name is case + insensitive. + :type resource_group_name: str + :param parameters: Parameters supplied to update a resource group. + :type parameters: ~azure.mgmt.resource.resources.v2019_05_10.models.ResourceGroupPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.ResourceGroup + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceGroup"] + error_map = {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.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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ResourceGroup', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + async def export_template( + self, + resource_group_name: str, + resources: Optional[List[str]] = None, + options: Optional[str] = None, + **kwargs + ) -> "models.ResourceGroupExportResult": + """Captures the specified resource group as a template. + + :param resource_group_name: The name of the resource group to export as a template. + :type resource_group_name: str + :param 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', + 'SkipResourceNameParameterization', 'SkipAllParameterization'. + :type options: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroupExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.ResourceGroupExportResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceGroupExportResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.ExportTemplateRequest(resources=resources, options=options) + api_version = "2019-05-10" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ResourceGroupExportResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate'} # type: ignore + + def list( + self, + filter: Optional[str] = None, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.ResourceGroupListResult"]: + """Gets all the resource groups for a subscription. + + :param filter: The filter to apply on the operation.:code:`
`:code:`
`You can filter by + tag names and values. For example, to filter for a tag name and value, use $filter=tagName eq + 'tag1' and tagValue eq 'Value1'. + :type filter: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-10" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ResourceGroupListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/operations_async/_resources_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/operations_async/_resources_operations_async.py new file mode 100644 index 000000000000..c21169d792d0 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/operations_async/_resources_operations_async.py @@ -0,0 +1,1308 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, List, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.polling import AsyncNoPolling, AsyncPollingMethod, async_poller +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ResourcesOperations: + """ResourcesOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2019_05_10.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list_by_resource_group( + self, + resource_group_name: str, + filter: Optional[str] = None, + expand: Optional[str] = None, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.ResourceListResult"]: + """Get all the resources for a resource group. + + :param resource_group_name: The resource group with the resources to get. + :type resource_group_name: str + :param filter: The filter to apply on the operation.:code:`
`:code:`
`The properties you + can use for eq (equals) or ne (not equals) are: location, resourceType, name, resourceGroup, + identity, identity/principalId, plan, plan/publisher, plan/product, plan/name, plan/version, + and plan/promotionCode.:code:`
`:code:`
`For example, to filter by a resource type, use: + $filter=resourceType eq 'Microsoft.Network/virtualNetworks':code:`
`:code:`
`You can use + substringof(value, property) in the filter. The properties you can use for substring are: name + and resourceGroup.:code:`
`:code:`
`For example, to get all resources with 'demo' + anywhere in the name, use: $filter=substringof('demo', name):code:`
`:code:`
`You can + link more than one substringof together by adding and/or operators.:code:`
`:code:`
`You + can filter by tag names and values. For example, to filter for a tag name and value, use + $filter=tagName eq 'tag1' and tagValue eq 'Value1':code:`
`:code:`
`You can use some + properties together when filtering. The combinations you can use are: substringof and/or + resourceType, plan and plan/publisher and plan/name, identity and identity/principalId. + :type filter: str + :param expand: Comma-separated list of additional properties to be included in the response. + Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, + ``$expand=createdTime,changedTime``. + :type expand: str + :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 ResourceListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-10" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ResourceListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources'} # type: ignore + + async def _move_resources_initial( + self, + source_resource_group_name: str, + resources: Optional[List[str]] = None, + target_resource_group: Optional[str] = None, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.ResourcesMoveInfo(resources=resources, target_resource_group=target_resource_group) + 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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + + # Construct and send request + 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 + + if response.status_code not in [202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore + + async def move_resources( + self, + source_resource_group_name: str, + resources: Optional[List[str]] = None, + target_resource_group: Optional[str] = None, + **kwargs + ) -> None: + """The resources to move must be in the same source resource group. The target resource group may be in a different subscription. When moving resources, both the source group and the target group are locked for the duration of the operation. Write and delete operations are blocked on the groups until the move completes. + + Moves resources from one resource group to another resource group. + + :param source_resource_group_name: The name of the resource group containing the resources to + move. + :type source_resource_group_name: str + :param resources: The IDs of the resources. + :type resources: list[str] + :param target_resource_group: The target resource group. + :type target_resource_group: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._move_resources_initial( + source_resource_group_name=source_resource_group_name, + resources=resources, + target_resource_group=target_resource_group, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore + + async def _validate_move_resources_initial( + self, + source_resource_group_name: str, + resources: Optional[List[str]] = None, + target_resource_group: Optional[str] = None, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.ResourcesMoveInfo(resources=resources, target_resource_group=target_resource_group) + 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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + + # Construct and send request + 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 + + if response.status_code not in [202, 204, 409]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _validate_move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} # type: ignore + + async def validate_move_resources( + self, + source_resource_group_name: str, + resources: Optional[List[str]] = None, + target_resource_group: Optional[str] = None, + **kwargs + ) -> None: + """This operation checks whether the specified resources can be moved to the target. The resources to move must be in the same source resource group. The target resource group may be in a different subscription. If validation succeeds, it returns HTTP response code 204 (no content). If validation fails, it returns HTTP response code 409 (Conflict) with an error message. Retrieve the URL in the Location header value to check the result of the long-running operation. + + Validates whether resources can be moved from one resource group to another resource group. + + :param source_resource_group_name: The name of the resource group containing the resources to + validate for move. + :type source_resource_group_name: str + :param resources: The IDs of the resources. + :type resources: list[str] + :param target_resource_group: The target resource group. + :type target_resource_group: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._validate_move_resources_initial( + source_resource_group_name=source_resource_group_name, + resources=resources, + target_resource_group=target_resource_group, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + validate_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} # type: ignore + + def list( + self, + filter: Optional[str] = None, + expand: Optional[str] = None, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.ResourceListResult"]: + """Get all the resources in a subscription. + + :param filter: The filter to apply on the operation.:code:`
`:code:`
`The properties you + can use for eq (equals) or ne (not equals) are: location, resourceType, name, resourceGroup, + identity, identity/principalId, plan, plan/publisher, plan/product, plan/name, plan/version, + and plan/promotionCode.:code:`
`:code:`
`For example, to filter by a resource type, use: + $filter=resourceType eq 'Microsoft.Network/virtualNetworks':code:`
`:code:`
`You can use + substringof(value, property) in the filter. The properties you can use for substring are: name + and resourceGroup.:code:`
`:code:`
`For example, to get all resources with 'demo' + anywhere in the name, use: $filter=substringof('demo', name):code:`
`:code:`
`You can + link more than one substringof together by adding and/or operators.:code:`
`:code:`
`You + can filter by tag names and values. For example, to filter for a tag name and value, use + $filter=tagName eq 'tag1' and tagValue eq 'Value1':code:`
`:code:`
`You can use some + properties together when filtering. The combinations you can use are: substringof and/or + resourceType, plan and plan/publisher and plan/name, identity and identity/principalId. + :type filter: str + :param expand: Comma-separated list of additional properties to be included in the response. + Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, + ``$expand=createdTime,changedTime``. + :type expand: str + :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 ResourceListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-10" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ResourceListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resources'} # type: ignore + + async def check_existence( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + **kwargs + ) -> None: + """Checks whether a resource exists. + + :param resource_group_name: The name of the resource group containing the resource to check. + The name is case insensitive. + :type resource_group_name: str + :param resource_provider_namespace: The resource provider of the resource to check. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. + :type parent_resource_path: str + :param resource_type: The resource type. + :type resource_type: str + :param resource_name: The name of the resource to check whether it exists. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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\._\(\)]+$'), + 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), + 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_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] + + # Construct and send request + 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 + + if response.status_code not in [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + 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, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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\._\(\)]+$'), + 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), + 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + async def delete( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + **kwargs + ) -> None: + """Deletes a resource. + + :param resource_group_name: The name of the resource group that contains the resource to + delete. The name is case insensitive. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. + :type parent_resource_path: str + :param resource_type: The resource type. + :type resource_type: str + :param resource_name: The name of the resource to delete. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._delete_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, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + parameters: "models.GenericResource", + **kwargs + ) -> "models.GenericResource": + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {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._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'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 201, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('GenericResource', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + async def create_or_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + parameters: "models.GenericResource", + **kwargs + ) -> "models.GenericResource": + """Creates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to create. + :type resource_type: str + :param resource_name: The name of the resource to create. + :type resource_name: str + :param parameters: Parameters for creating or updating the resource. + :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 polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: GenericResource + :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._create_or_update_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, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + 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, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + parameters: "models.GenericResource", + **kwargs + ) -> "models.GenericResource": + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {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._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'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + async def update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + parameters: "models.GenericResource", + **kwargs + ) -> "models.GenericResource": + """Updates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to update. + :type resource_type: str + :param resource_name: The name of the resource to update. + :type resource_name: str + :param parameters: Parameters for updating the resource. + :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 polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: GenericResource + :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._update_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, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + async def get( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + **kwargs + ) -> "models.GenericResource": + """Gets a resource. + + :param resource_group_name: The name of the resource group containing the resource to get. The + name is case insensitive. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. + :type parent_resource_path: str + :param resource_type: The resource type of the resource. + :type resource_type: str + :param resource_name: The name of the resource to get. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GenericResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-10" + + # Construct URL + url = self.get.metadata['url'] # type: 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + async def check_existence_by_id( + self, + resource_id: str, + **kwargs + ) -> None: + """Checks by ID whether a resource exists. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + :type resource_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-10" + + # 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] + + # Construct and send request + 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 + + if response.status_code not in [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + 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, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-10" + + # 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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + async def delete_by_id( + self, + resource_id: str, + **kwargs + ) -> None: + """Deletes a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + :type resource_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._delete_by_id_initial( + resource_id=resource_id, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + delete_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + + async def _create_or_update_by_id_initial( + self, + resource_id: str, + parameters: "models.GenericResource", + **kwargs + ) -> "models.GenericResource": + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {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._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) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 201, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('GenericResource', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + async def create_or_update_by_id( + self, + resource_id: str, + parameters: "models.GenericResource", + **kwargs + ) -> "models.GenericResource": + """Create a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + :type resource_id: str + :param parameters: Create or update resource parameters. + :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 polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: GenericResource + :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._create_or_update_by_id_initial( + resource_id=resource_id, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + create_or_update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + + async def _update_by_id_initial( + self, + resource_id: str, + parameters: "models.GenericResource", + **kwargs + ) -> "models.GenericResource": + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {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._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) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + async def update_by_id( + self, + resource_id: str, + parameters: "models.GenericResource", + **kwargs + ) -> "models.GenericResource": + """Updates a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + :type resource_id: str + :param parameters: Update resource parameters. + :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 polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: GenericResource + :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._update_by_id_initial( + resource_id=resource_id, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + + async def get_by_id( + self, + resource_id: str, + **kwargs + ) -> "models.GenericResource": + """Gets a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + :type resource_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GenericResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-10" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + 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_async/_tags_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/operations_async/_tags_operations_async.py new file mode 100644 index 000000000000..3efdb2719c0f --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/aio/operations_async/_tags_operations_async.py @@ -0,0 +1,327 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import 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 ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class TagsOperations: + """TagsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2019_05_10.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def delete_value( + self, + tag_name: str, + tag_value: str, + **kwargs + ) -> None: + """Deletes a tag value. + + :param tag_name: The name of the tag. + :type tag_name: str + :param tag_value: The value of the tag to delete. + :type tag_value: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore + + async def create_or_update_value( + self, + tag_name: str, + tag_value: str, + **kwargs + ) -> "models.TagValue": + """Creates a tag value. The name of the tag must already exist. + + :param tag_name: The name of the tag. + :type tag_name: str + :param tag_value: The value of the tag to create. + :type tag_value: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagValue or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.TagValue + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TagValue"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-10" + + # 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'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('TagValue', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('TagValue', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore + + async def create_or_update( + self, + tag_name: str, + **kwargs + ) -> "models.TagDetails": + """The tag name can have a maximum of 512 characters and is case insensitive. Tag names created by Azure have prefixes of microsoft, azure, or windows. You cannot create tags with one of these prefixes. + + Creates a tag in the subscription. + + :param tag_name: The name of the tag to create. + :type tag_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagDetails or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.TagDetails + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TagDetails"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-10" + + # 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'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('TagDetails', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('TagDetails', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore + + async def delete( + self, + tag_name: str, + **kwargs + ) -> None: + """You must remove all values from a resource tag before you can delete it. + + Deletes a tag from the subscription. + + :param tag_name: The name of the tag. + :type tag_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore + + def list( + self, + **kwargs + ) -> AsyncIterable["models.TagsListResult"]: + """Gets the names and values of all resource tags that are defined in a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of TagsListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-10" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('TagsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/models/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/models/__init__.py index a4e62c5bf265..b94776ab3cce 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/models/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/models/__init__.py @@ -1,26 +1,26 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- try: from ._models_py3 import AliasPathType from ._models_py3 import AliasType from ._models_py3 import BasicDependency + from ._models_py3 import ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties from ._models_py3 import DebugSetting from ._models_py3 import Dependency from ._models_py3 import Deployment from ._models_py3 import DeploymentExportResult from ._models_py3 import DeploymentExtended from ._models_py3 import DeploymentExtendedFilter + from ._models_py3 import DeploymentListResult from ._models_py3 import DeploymentOperation from ._models_py3 import DeploymentOperationProperties + from ._models_py3 import DeploymentOperationsListResult from ._models_py3 import DeploymentProperties from ._models_py3 import DeploymentPropertiesExtended from ._models_py3 import DeploymentValidateResult @@ -32,21 +32,24 @@ from ._models_py3 import GenericResourceFilter from ._models_py3 import HttpMessage from ._models_py3 import Identity - from ._models_py3 import IdentityUserAssignedIdentitiesValue from ._models_py3 import OnErrorDeployment from ._models_py3 import OnErrorDeploymentExtended from ._models_py3 import Operation from ._models_py3 import OperationDisplay + from ._models_py3 import OperationListResult from ._models_py3 import ParametersLink from ._models_py3 import Plan from ._models_py3 import Provider + from ._models_py3 import ProviderListResult from ._models_py3 import ProviderResourceType from ._models_py3 import Resource from ._models_py3 import ResourceGroup from ._models_py3 import ResourceGroupExportResult from ._models_py3 import ResourceGroupFilter + from ._models_py3 import ResourceGroupListResult from ._models_py3 import ResourceGroupPatchable from ._models_py3 import ResourceGroupProperties + from ._models_py3 import ResourceListResult from ._models_py3 import ResourceManagementErrorWithDetails from ._models_py3 import ResourceProviderOperationDisplayProperties from ._models_py3 import ResourcesMoveInfo @@ -55,65 +58,67 @@ from ._models_py3 import TagCount from ._models_py3 import TagDetails from ._models_py3 import TagValue + from ._models_py3 import TagsListResult from ._models_py3 import TargetResource from ._models_py3 import TemplateHashResult from ._models_py3 import TemplateLink except (SyntaxError, ImportError): - from ._models import AliasPathType - from ._models import AliasType - from ._models import BasicDependency - from ._models import DebugSetting - from ._models import Dependency - from ._models import Deployment - from ._models import DeploymentExportResult - from ._models import DeploymentExtended - from ._models import DeploymentExtendedFilter - from ._models import DeploymentOperation - from ._models import DeploymentOperationProperties - from ._models import DeploymentProperties - from ._models import DeploymentPropertiesExtended - from ._models import DeploymentValidateResult - from ._models import ErrorAdditionalInfo - from ._models import ErrorResponse - from ._models import ExportTemplateRequest - from ._models import GenericResource - from ._models import GenericResourceExpanded - from ._models import GenericResourceFilter - from ._models import HttpMessage - from ._models import Identity - from ._models import IdentityUserAssignedIdentitiesValue - from ._models import OnErrorDeployment - from ._models import OnErrorDeploymentExtended - from ._models import Operation - from ._models import OperationDisplay - from ._models import ParametersLink - from ._models import Plan - from ._models import Provider - from ._models import ProviderResourceType - from ._models import Resource - from ._models import ResourceGroup - from ._models import ResourceGroupExportResult - from ._models import ResourceGroupFilter - from ._models import ResourceGroupPatchable - from ._models import ResourceGroupProperties - from ._models import ResourceManagementErrorWithDetails - from ._models import ResourceProviderOperationDisplayProperties - from ._models import ResourcesMoveInfo - from ._models import Sku - from ._models import SubResource - from ._models import TagCount - from ._models import TagDetails - from ._models import TagValue - from ._models import TargetResource - from ._models import TemplateHashResult - from ._models import TemplateLink -from ._paged_models import DeploymentExtendedPaged -from ._paged_models import DeploymentOperationPaged -from ._paged_models import GenericResourceExpandedPaged -from ._paged_models import OperationPaged -from ._paged_models import ProviderPaged -from ._paged_models import ResourceGroupPaged -from ._paged_models import TagDetailsPaged + from ._models import AliasPathType # type: ignore + from ._models import AliasType # type: ignore + from ._models import BasicDependency # type: ignore + from ._models import ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties # type: ignore + from ._models import DebugSetting # type: ignore + from ._models import Dependency # type: ignore + from ._models import Deployment # type: ignore + from ._models import DeploymentExportResult # type: ignore + from ._models import DeploymentExtended # type: ignore + from ._models import DeploymentExtendedFilter # type: ignore + from ._models import DeploymentListResult # type: ignore + from ._models import DeploymentOperation # type: ignore + from ._models import DeploymentOperationProperties # type: ignore + from ._models import DeploymentOperationsListResult # type: ignore + from ._models import DeploymentProperties # type: ignore + from ._models import DeploymentPropertiesExtended # type: ignore + from ._models import DeploymentValidateResult # type: ignore + from ._models import ErrorAdditionalInfo # type: ignore + from ._models import ErrorResponse # type: ignore + from ._models import ExportTemplateRequest # type: ignore + from ._models import GenericResource # type: ignore + from ._models import GenericResourceExpanded # type: ignore + from ._models import GenericResourceFilter # type: ignore + from ._models import HttpMessage # type: ignore + from ._models import Identity # type: ignore + from ._models import OnErrorDeployment # type: ignore + from ._models import OnErrorDeploymentExtended # type: ignore + from ._models import Operation # type: ignore + from ._models import OperationDisplay # type: ignore + from ._models import OperationListResult # type: ignore + from ._models import ParametersLink # type: ignore + from ._models import Plan # type: ignore + from ._models import Provider # type: ignore + from ._models import ProviderListResult # type: ignore + from ._models import ProviderResourceType # type: ignore + from ._models import Resource # type: ignore + from ._models import ResourceGroup # type: ignore + from ._models import ResourceGroupExportResult # type: ignore + from ._models import ResourceGroupFilter # type: ignore + from ._models import ResourceGroupListResult # type: ignore + from ._models import ResourceGroupPatchable # type: ignore + from ._models import ResourceGroupProperties # type: ignore + from ._models import ResourceListResult # type: ignore + from ._models import ResourceManagementErrorWithDetails # type: ignore + from ._models import ResourceProviderOperationDisplayProperties # type: ignore + from ._models import ResourcesMoveInfo # type: ignore + from ._models import Sku # type: ignore + from ._models import SubResource # type: ignore + from ._models import TagCount # type: ignore + from ._models import TagDetails # type: ignore + from ._models import TagValue # type: ignore + from ._models import TagsListResult # type: ignore + from ._models import TargetResource # type: ignore + from ._models import TemplateHashResult # type: ignore + from ._models import TemplateLink # type: ignore + from ._resource_management_client_enums import ( DeploymentMode, OnErrorDeploymentType, @@ -124,14 +129,17 @@ 'AliasPathType', 'AliasType', 'BasicDependency', + 'ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties', 'DebugSetting', 'Dependency', 'Deployment', 'DeploymentExportResult', 'DeploymentExtended', 'DeploymentExtendedFilter', + 'DeploymentListResult', 'DeploymentOperation', 'DeploymentOperationProperties', + 'DeploymentOperationsListResult', 'DeploymentProperties', 'DeploymentPropertiesExtended', 'DeploymentValidateResult', @@ -143,21 +151,24 @@ 'GenericResourceFilter', 'HttpMessage', 'Identity', - 'IdentityUserAssignedIdentitiesValue', 'OnErrorDeployment', 'OnErrorDeploymentExtended', 'Operation', 'OperationDisplay', + 'OperationListResult', 'ParametersLink', 'Plan', 'Provider', + 'ProviderListResult', 'ProviderResourceType', 'Resource', 'ResourceGroup', 'ResourceGroupExportResult', 'ResourceGroupFilter', + 'ResourceGroupListResult', 'ResourceGroupPatchable', 'ResourceGroupProperties', + 'ResourceListResult', 'ResourceManagementErrorWithDetails', 'ResourceProviderOperationDisplayProperties', 'ResourcesMoveInfo', @@ -166,16 +177,10 @@ 'TagCount', 'TagDetails', 'TagValue', + 'TagsListResult', 'TargetResource', 'TemplateHashResult', 'TemplateLink', - 'OperationPaged', - 'DeploymentExtendedPaged', - 'ProviderPaged', - 'GenericResourceExpandedPaged', - 'ResourceGroupPaged', - 'TagDetailsPaged', - 'DeploymentOperationPaged', 'DeploymentMode', 'OnErrorDeploymentType', 'ResourceIdentityType', 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 e45064cd70a9..784262bd4ab0 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 @@ -1,20 +1,16 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.serialization import Model -from msrest.exceptions import HttpOperationError +import msrest.serialization -class AliasPathType(Model): - """The type of the paths for alias. . +class AliasPathType(msrest.serialization.Model): + """The type of the paths for alias. :param path: The path of an alias. :type path: str @@ -27,20 +23,22 @@ class AliasPathType(Model): 'api_versions': {'key': 'apiVersions', 'type': '[str]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(AliasPathType, self).__init__(**kwargs) self.path = kwargs.get('path', None) self.api_versions = kwargs.get('api_versions', None) -class AliasType(Model): - """The alias type. . +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] + :type paths: list[~azure.mgmt.resource.resources.v2019_05_10.models.AliasPathType] """ _attribute_map = { @@ -48,13 +46,16 @@ class AliasType(Model): 'paths': {'key': 'paths', 'type': '[AliasPathType]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(AliasType, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.paths = kwargs.get('paths', None) -class BasicDependency(Model): +class BasicDependency(msrest.serialization.Model): """Deployment dependency information. :param id: The ID of the dependency. @@ -71,52 +72,55 @@ class BasicDependency(Model): 'resource_name': {'key': 'resourceName', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(BasicDependency, self).__init__(**kwargs) self.id = kwargs.get('id', None) self.resource_type = kwargs.get('resource_type', None) self.resource_name = kwargs.get('resource_name', None) -class CloudError(Model): - """An error response for a resource management request. +class ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties(msrest.serialization.Model): + """ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties. - :param error: - :type error: - ~azure.mgmt.resource.resources.v2019_05_10.models.ErrorResponse + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar principal_id: The principal id of user assigned identity. + :vartype principal_id: str + :ivar client_id: The client id of user assigned identity. + :vartype client_id: str """ - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorResponse'}, + _validation = { + 'principal_id': {'readonly': True}, + 'client_id': {'readonly': True}, } - def __init__(self, **kwargs): - super(CloudError, self).__init__(**kwargs) - self.error = kwargs.get('error', None) - - -class CloudErrorException(HttpOperationError): - """Server responsed with exception of type: 'CloudError'. - - :param deserialize: A deserializer - :param response: Server response to be deserialized. - """ - - def __init__(self, deserialize, response, *args): + _attribute_map = { + 'principal_id': {'key': 'principalId', 'type': 'str'}, + 'client_id': {'key': 'clientId', 'type': 'str'}, + } - super(CloudErrorException, self).__init__(deserialize, response, 'CloudError', *args) + def __init__( + self, + **kwargs + ): + super(ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties, self).__init__(**kwargs) + self.principal_id = None + self.client_id = None -class DebugSetting(Model): +class DebugSetting(msrest.serialization.Model): """The debug setting. - :param 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. + :param 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 """ @@ -124,17 +128,19 @@ class DebugSetting(Model): 'detail_level': {'key': 'detailLevel', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DebugSetting, self).__init__(**kwargs) self.detail_level = kwargs.get('detail_level', None) -class Dependency(Model): +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] + :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. @@ -150,7 +156,10 @@ class Dependency(Model): 'resource_name': {'key': 'resourceName', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Dependency, self).__init__(**kwargs) self.depends_on = kwargs.get('depends_on', None) self.id = kwargs.get('id', None) @@ -158,7 +167,7 @@ def __init__(self, **kwargs): self.resource_name = kwargs.get('resource_name', None) -class Deployment(Model): +class Deployment(msrest.serialization.Model): """Deployment operation parameters. All required parameters must be populated in order to send to Azure. @@ -166,8 +175,7 @@ class Deployment(Model): :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 + :type properties: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentProperties """ _validation = { @@ -179,14 +187,17 @@ class Deployment(Model): 'properties': {'key': 'properties', 'type': 'DeploymentProperties'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Deployment, self).__init__(**kwargs) self.location = kwargs.get('location', None) - self.properties = kwargs.get('properties', None) + self.properties = kwargs['properties'] -class DeploymentExportResult(Model): - """The deployment export result. . +class DeploymentExportResult(msrest.serialization.Model): + """The deployment export result. :param template: The template content. :type template: object @@ -196,16 +207,18 @@ class DeploymentExportResult(Model): 'template': {'key': 'template', 'type': 'object'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentExportResult, self).__init__(**kwargs) self.template = kwargs.get('template', None) -class DeploymentExtended(Model): +class DeploymentExtended(msrest.serialization.Model): """Deployment information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The ID of the deployment. :vartype id: str @@ -234,7 +247,10 @@ class DeploymentExtended(Model): 'properties': {'key': 'properties', 'type': 'DeploymentPropertiesExtended'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentExtended, self).__init__(**kwargs) self.id = None self.name = None @@ -243,7 +259,7 @@ def __init__(self, **kwargs): self.properties = kwargs.get('properties', None) -class DeploymentExtendedFilter(Model): +class DeploymentExtendedFilter(msrest.serialization.Model): """Deployment filter. :param provisioning_state: The provisioning state. @@ -254,16 +270,47 @@ class DeploymentExtendedFilter(Model): 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentExtendedFilter, self).__init__(**kwargs) self.provisioning_state = kwargs.get('provisioning_state', None) -class DeploymentOperation(Model): +class DeploymentListResult(msrest.serialization.Model): + """List of deployments. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[DeploymentExtended]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(DeploymentListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = None + + +class DeploymentOperation(msrest.serialization.Model): """Deployment operation information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Full deployment operation ID. :vartype id: str @@ -285,23 +332,25 @@ class DeploymentOperation(Model): 'properties': {'key': 'properties', 'type': 'DeploymentOperationProperties'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentOperation, self).__init__(**kwargs) self.id = None self.operation_id = None self.properties = kwargs.get('properties', None) -class DeploymentOperationProperties(Model): +class DeploymentOperationProperties(msrest.serialization.Model): """Deployment operation properties. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar provisioning_state: The state of the provisioning. :vartype provisioning_state: str :ivar timestamp: The date and time of the operation. - :vartype timestamp: datetime + :vartype timestamp: ~datetime.datetime :ivar duration: The duration of the operation. :vartype duration: str :ivar service_request_id: Deployment operation service request id. @@ -311,14 +360,11 @@ class DeploymentOperationProperties(Model): :ivar status_message: Operation status message. :vartype status_message: object :ivar target_resource: The target resource. - :vartype target_resource: - ~azure.mgmt.resource.resources.v2019_05_10.models.TargetResource + :vartype target_resource: ~azure.mgmt.resource.resources.v2019_05_10.models.TargetResource :ivar request: The HTTP request message. - :vartype request: - ~azure.mgmt.resource.resources.v2019_05_10.models.HttpMessage + :vartype request: ~azure.mgmt.resource.resources.v2019_05_10.models.HttpMessage :ivar response: The HTTP response message. - :vartype response: - ~azure.mgmt.resource.resources.v2019_05_10.models.HttpMessage + :vartype response: ~azure.mgmt.resource.resources.v2019_05_10.models.HttpMessage """ _validation = { @@ -345,7 +391,10 @@ class DeploymentOperationProperties(Model): 'response': {'key': 'response', 'type': 'HttpMessage'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentOperationProperties, self).__init__(**kwargs) self.provisioning_state = None self.timestamp = None @@ -358,48 +407,68 @@ def __init__(self, **kwargs): self.response = None -class DeploymentProperties(Model): +class DeploymentOperationsListResult(msrest.serialization.Model): + """List of deployment operations. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[DeploymentOperation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(DeploymentOperationsListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = None + + +class DeploymentProperties(msrest.serialization.Model): """Deployment properties. 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 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. + :param 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: object - :param 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. 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. + :param 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. + 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: object - :param 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 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 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 + 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 + :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 + :type on_error_deployment: ~azure.mgmt.resource.resources.v2019_05_10.models.OnErrorDeployment """ _validation = { @@ -411,66 +480,59 @@ class DeploymentProperties(Model): 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, 'parameters': {'key': 'parameters', 'type': 'object'}, 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, - 'mode': {'key': 'mode', 'type': 'DeploymentMode'}, + 'mode': {'key': 'mode', 'type': 'str'}, 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, 'on_error_deployment': {'key': 'onErrorDeployment', 'type': 'OnErrorDeployment'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentProperties, self).__init__(**kwargs) self.template = kwargs.get('template', None) self.template_link = kwargs.get('template_link', None) self.parameters = kwargs.get('parameters', None) self.parameters_link = kwargs.get('parameters_link', None) - self.mode = kwargs.get('mode', None) + self.mode = kwargs['mode'] self.debug_setting = kwargs.get('debug_setting', None) self.on_error_deployment = kwargs.get('on_error_deployment', None) -class DeploymentPropertiesExtended(Model): +class DeploymentPropertiesExtended(msrest.serialization.Model): """Deployment properties with additional details. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :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 + :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: object - :param providers: The list of resource providers needed for the - deployment. - :type providers: - list[~azure.mgmt.resource.resources.v2019_05_10.models.Provider] + :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 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: object - :param 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. + :param 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: object - :param 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 include: 'Incremental', 'Complete' - :type mode: str or - ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentMode + :param 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 + 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 + :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.OnErrorDeploymentExtended @@ -495,12 +557,15 @@ class DeploymentPropertiesExtended(Model): 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, 'parameters': {'key': 'parameters', 'type': 'object'}, 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, - 'mode': {'key': 'mode', 'type': 'DeploymentMode'}, + 'mode': {'key': 'mode', 'type': 'str'}, 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, 'on_error_deployment': {'key': 'onErrorDeployment', 'type': 'OnErrorDeploymentExtended'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentPropertiesExtended, self).__init__(**kwargs) self.provisioning_state = None self.correlation_id = None @@ -518,7 +583,7 @@ def __init__(self, **kwargs): self.on_error_deployment = kwargs.get('on_error_deployment', None) -class DeploymentValidateResult(Model): +class DeploymentValidateResult(msrest.serialization.Model): """Information from validate template deployment response. :param error: Validation error. @@ -534,17 +599,19 @@ class DeploymentValidateResult(Model): 'properties': {'key': 'properties', 'type': 'DeploymentPropertiesExtended'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentValidateResult, self).__init__(**kwargs) self.error = kwargs.get('error', None) self.properties = kwargs.get('properties', None) -class ErrorAdditionalInfo(Model): +class ErrorAdditionalInfo(msrest.serialization.Model): """The resource management error additional info. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar type: The additional info type. :vartype type: str @@ -562,17 +629,19 @@ class ErrorAdditionalInfo(Model): 'info': {'key': 'info', 'type': 'object'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None -class ErrorResponse(Model): +class ErrorResponse(msrest.serialization.Model): """The resource management error response. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar code: The error code. :vartype code: str @@ -581,8 +650,7 @@ class ErrorResponse(Model): :ivar target: The error target. :vartype target: str :ivar details: The error details. - :vartype details: - list[~azure.mgmt.resource.resources.v2019_05_10.models.ErrorResponse] + :vartype details: list[~azure.mgmt.resource.resources.v2019_05_10.models.ErrorResponse] :ivar additional_info: The error additional info. :vartype additional_info: list[~azure.mgmt.resource.resources.v2019_05_10.models.ErrorAdditionalInfo] @@ -604,7 +672,10 @@ class ErrorResponse(Model): 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ErrorResponse, self).__init__(**kwargs) self.code = None self.message = None @@ -613,16 +684,15 @@ def __init__(self, **kwargs): self.additional_info = None -class ExportTemplateRequest(Model): +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, supply an array with single entry '*'. + :param 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', 'SkipResourceNameParameterization', - 'SkipAllParameterization' + :param options: The export template options. A CSV-formatted list containing zero or more of + the following: 'IncludeParameterDefaultValue', 'IncludeComments', + 'SkipResourceNameParameterization', 'SkipAllParameterization'. :type options: str """ @@ -631,27 +701,29 @@ class ExportTemplateRequest(Model): 'options': {'key': 'options', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ExportTemplateRequest, self).__init__(**kwargs) self.resources = kwargs.get('resources', None) self.options = kwargs.get('options', None) -class Resource(Model): +class Resource(msrest.serialization.Model): """Specified resource. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID + :ivar id: Resource ID. :vartype id: str - :ivar name: Resource name + :ivar name: Resource name. :vartype name: str - :ivar type: Resource type + :ivar type: Resource type. :vartype type: str - :param location: Resource location + :param location: Resource location. :type location: str - :param tags: Resource tags + :param tags: A set of tags. Resource tags. :type tags: dict[str, str] """ @@ -669,7 +741,10 @@ class Resource(Model): 'tags': {'key': 'tags', 'type': '{str}'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -681,18 +756,17 @@ def __init__(self, **kwargs): class GenericResource(Resource): """Resource information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID + :ivar id: Resource ID. :vartype id: str - :ivar name: Resource name + :ivar name: Resource name. :vartype name: str - :ivar type: Resource type + :ivar type: Resource type. :vartype type: str - :param location: Resource location + :param location: Resource location. :type location: str - :param tags: Resource tags + :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 @@ -729,7 +803,10 @@ class GenericResource(Resource): 'identity': {'key': 'identity', 'type': 'Identity'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(GenericResource, self).__init__(**kwargs) self.plan = kwargs.get('plan', None) self.properties = kwargs.get('properties', None) @@ -742,18 +819,17 @@ def __init__(self, **kwargs): class GenericResourceExpanded(GenericResource): """Resource information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID + :ivar id: Resource ID. :vartype id: str - :ivar name: Resource name + :ivar name: Resource name. :vartype name: str - :ivar type: Resource type + :ivar type: Resource type. :vartype type: str - :param location: Resource location + :param location: Resource location. :type location: str - :param tags: Resource tags + :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 @@ -767,14 +843,14 @@ class GenericResourceExpanded(GenericResource): :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 created_time: The created time of the resource. This is only present - if requested via the $expand query parameter. - :vartype created_time: datetime - :ivar changed_time: The changed time of the resource. This is only present - if requested via the $expand query parameter. - :vartype changed_time: datetime - :ivar provisioning_state: The provisioning state of the resource. This is - only present if requested via the $expand query parameter. + :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 + :ivar changed_time: The changed time of the resource. This is only present if requested via the + $expand query parameter. + :vartype changed_time: ~datetime.datetime + :ivar provisioning_state: The provisioning state of the resource. This is only present if + requested via the $expand query parameter. :vartype provisioning_state: str """ @@ -805,14 +881,17 @@ class GenericResourceExpanded(GenericResource): 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(GenericResourceExpanded, self).__init__(**kwargs) self.created_time = None self.changed_time = None self.provisioning_state = None -class GenericResourceFilter(Model): +class GenericResourceFilter(msrest.serialization.Model): """Resource filter. :param resource_type: The resource type. @@ -829,14 +908,17 @@ class GenericResourceFilter(Model): 'tagvalue': {'key': 'tagvalue', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(GenericResourceFilter, self).__init__(**kwargs) self.resource_type = kwargs.get('resource_type', None) self.tagname = kwargs.get('tagname', None) self.tagvalue = kwargs.get('tagvalue', None) -class HttpMessage(Model): +class HttpMessage(msrest.serialization.Model): """HTTP message. :param content: HTTP message content. @@ -847,31 +929,31 @@ class HttpMessage(Model): 'content': {'key': 'content', 'type': 'object'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(HttpMessage, self).__init__(**kwargs) self.content = kwargs.get('content', None) -class Identity(Model): +class Identity(msrest.serialization.Model): """Identity for the resource. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar principal_id: The principal ID of resource identity. :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :param 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 user identity dictionary key references will be ARM - resource ids in the form: + :param 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 + 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, - ~azure.mgmt.resource.resources.v2019_05_10.models.IdentityUserAssignedIdentitiesValue] + ~azure.mgmt.resource.resources.v2019_05_10.models.ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties] """ _validation = { @@ -882,11 +964,14 @@ class Identity(Model): _attribute_map = { 'principal_id': {'key': 'principalId', 'type': 'str'}, 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'ResourceIdentityType'}, - 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{IdentityUserAssignedIdentitiesValue}'}, + 'type': {'key': 'type', 'type': 'str'}, + 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties}'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Identity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None @@ -894,71 +979,40 @@ def __init__(self, **kwargs): self.user_assigned_identities = kwargs.get('user_assigned_identities', None) -class IdentityUserAssignedIdentitiesValue(Model): - """IdentityUserAssignedIdentitiesValue. - - Variables are only populated by the server, and will be ignored when - sending a request. - - :ivar principal_id: The principal id of user assigned identity. - :vartype principal_id: str - :ivar client_id: The client id of user assigned identity. - :vartype client_id: str - """ - - _validation = { - 'principal_id': {'readonly': True}, - 'client_id': {'readonly': True}, - } - - _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'client_id': {'key': 'clientId', 'type': 'str'}, - } - - def __init__(self, **kwargs): - super(IdentityUserAssignedIdentitiesValue, self).__init__(**kwargs) - self.principal_id = None - self.client_id = None - - -class OnErrorDeployment(Model): +class OnErrorDeployment(msrest.serialization.Model): """Deployment on error behavior. - :param 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 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 """ _attribute_map = { - 'type': {'key': 'type', 'type': 'OnErrorDeploymentType'}, + 'type': {'key': 'type', 'type': 'str'}, 'deployment_name': {'key': 'deploymentName', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(OnErrorDeployment, self).__init__(**kwargs) self.type = kwargs.get('type', None) self.deployment_name = kwargs.get('deployment_name', None) -class OnErrorDeploymentExtended(Model): +class OnErrorDeploymentExtended(msrest.serialization.Model): """Deployment on error behavior with additional details. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar provisioning_state: The state of the provisioning for the on error - deployment. + :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 SpecificDeployment. Possible values include: - 'LastSuccessful', 'SpecificDeployment' - :type type: str or - ~azure.mgmt.resource.resources.v2019_05_10.models.OnErrorDeploymentType + :param 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 """ @@ -969,25 +1023,27 @@ class OnErrorDeploymentExtended(Model): _attribute_map = { 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'OnErrorDeploymentType'}, + 'type': {'key': 'type', 'type': 'str'}, 'deployment_name': {'key': 'deploymentName', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(OnErrorDeploymentExtended, self).__init__(**kwargs) self.provisioning_state = None self.type = kwargs.get('type', None) self.deployment_name = kwargs.get('deployment_name', None) -class Operation(Model): +class Operation(msrest.serialization.Model): """Microsoft.Resources operation. - :param name: Operation name: {provider}/{resource}/{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 + :type display: ~azure.mgmt.resource.resources.v2019_05_10.models.OperationDisplay """ _attribute_map = { @@ -995,19 +1051,21 @@ class Operation(Model): 'display': {'key': 'display', 'type': 'OperationDisplay'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Operation, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.display = kwargs.get('display', None) -class OperationDisplay(Model): +class OperationDisplay(msrest.serialization.Model): """The object that represents the operation. - :param provider: Service provider: Microsoft.Resources + :param provider: Service provider: Microsoft.Resources. :type provider: str - :param resource: Resource on which the operation is performed: Profile, - endpoint, etc. + :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 @@ -1022,7 +1080,10 @@ class OperationDisplay(Model): 'description': {'key': 'description', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(OperationDisplay, self).__init__(**kwargs) self.provider = kwargs.get('provider', None) self.resource = kwargs.get('resource', None) @@ -1030,15 +1091,37 @@ def __init__(self, **kwargs): self.description = kwargs.get('description', None) -class ParametersLink(Model): +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 + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Operation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(OperationListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class ParametersLink(msrest.serialization.Model): """Entity representing the reference to the deployment parameters. 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. + :param content_version: If included, must match the ContentVersion in the template. :type content_version: str """ @@ -1051,13 +1134,16 @@ class ParametersLink(Model): 'content_version': {'key': 'contentVersion', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ParametersLink, self).__init__(**kwargs) - self.uri = kwargs.get('uri', None) + self.uri = kwargs['uri'] self.content_version = kwargs.get('content_version', None) -class Plan(Model): +class Plan(msrest.serialization.Model): """Plan for the resource. :param name: The plan ID. @@ -1080,7 +1166,10 @@ class Plan(Model): 'version': {'key': 'version', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Plan, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.publisher = kwargs.get('publisher', None) @@ -1089,11 +1178,10 @@ def __init__(self, **kwargs): self.version = kwargs.get('version', None) -class Provider(Model): +class Provider(msrest.serialization.Model): """Resource provider information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The provider ID. :vartype id: str @@ -1101,8 +1189,7 @@ class Provider(Model): :type 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. + :ivar registration_policy: The registration policy of the resource provider. :vartype registration_policy: str :ivar resource_types: The collection of provider resource types. :vartype resource_types: @@ -1124,7 +1211,10 @@ class Provider(Model): 'resource_types': {'key': 'resourceTypes', 'type': '[ProviderResourceType]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Provider, self).__init__(**kwargs) self.id = None self.namespace = kwargs.get('namespace', None) @@ -1133,21 +1223,47 @@ def __init__(self, **kwargs): self.resource_types = None -class ProviderResourceType(Model): +class ProviderListResult(msrest.serialization.Model): + """List of resource providers. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Provider]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ProviderListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = None + + +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. + :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] + :type aliases: list[~azure.mgmt.resource.resources.v2019_05_10.models.AliasType] :param api_versions: The API version. :type api_versions: list[str] - :param capabilities: The additional capabilities offered by this resource - type. + :param capabilities: The additional capabilities offered by this resource type. :type capabilities: str :param properties: The properties. :type properties: dict[str, str] @@ -1162,7 +1278,10 @@ class ProviderResourceType(Model): 'properties': {'key': 'properties', 'type': '{str}'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ProviderResourceType, self).__init__(**kwargs) self.resource_type = kwargs.get('resource_type', None) self.locations = kwargs.get('locations', None) @@ -1172,11 +1291,10 @@ def __init__(self, **kwargs): self.properties = kwargs.get('properties', None) -class ResourceGroup(Model): +class ResourceGroup(msrest.serialization.Model): """Resource group information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. @@ -1187,16 +1305,13 @@ class ResourceGroup(Model): :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 resource group has been created. It must be one of - the supported Azure locations. + :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 + 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. + :param managed_by: The ID of the resource that manages this resource group. :type managed_by: str - :param tags: The tags attached to the resource group. + :param tags: A set of tags. The tags attached to the resource group. :type tags: dict[str, str] """ @@ -1217,18 +1332,21 @@ class ResourceGroup(Model): 'tags': {'key': 'tags', 'type': '{str}'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ResourceGroup, self).__init__(**kwargs) self.id = None self.name = None self.type = None self.properties = kwargs.get('properties', None) - self.location = kwargs.get('location', None) + self.location = kwargs['location'] self.managed_by = kwargs.get('managed_by', None) self.tags = kwargs.get('tags', None) -class ResourceGroupExportResult(Model): +class ResourceGroupExportResult(msrest.serialization.Model): """Resource group export result. :param template: The template content. @@ -1243,13 +1361,16 @@ class ResourceGroupExportResult(Model): 'error': {'key': 'error', 'type': 'ResourceManagementErrorWithDetails'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ResourceGroupExportResult, self).__init__(**kwargs) self.template = kwargs.get('template', None) self.error = kwargs.get('error', None) -class ResourceGroupFilter(Model): +class ResourceGroupFilter(msrest.serialization.Model): """Resource group filter. :param tag_name: The tag name. @@ -1263,24 +1384,54 @@ class ResourceGroupFilter(Model): 'tag_value': {'key': 'tagValue', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ResourceGroupFilter, self).__init__(**kwargs) self.tag_name = kwargs.get('tag_name', None) self.tag_value = kwargs.get('tag_value', None) -class ResourceGroupPatchable(Model): +class ResourceGroupListResult(msrest.serialization.Model): + """List of resource groups. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ResourceGroup]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ResourceGroupListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = None + + +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 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: The tags attached to the resource group. + :param tags: A set of tags. The tags attached to the resource group. :type tags: dict[str, str] """ @@ -1291,7 +1442,10 @@ class ResourceGroupPatchable(Model): 'tags': {'key': 'tags', 'type': '{str}'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ResourceGroupPatchable, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.properties = kwargs.get('properties', None) @@ -1299,11 +1453,10 @@ def __init__(self, **kwargs): self.tags = kwargs.get('tags', None) -class ResourceGroupProperties(Model): +class ResourceGroupProperties(msrest.serialization.Model): """The resource group properties. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar provisioning_state: The provisioning state. :vartype provisioning_state: str @@ -1317,16 +1470,47 @@ class ResourceGroupProperties(Model): 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ResourceGroupProperties, self).__init__(**kwargs) self.provisioning_state = None -class ResourceManagementErrorWithDetails(Model): +class ResourceListResult(msrest.serialization.Model): + """List of resource groups. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[GenericResourceExpanded]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ResourceListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = None + + +class ResourceManagementErrorWithDetails(msrest.serialization.Model): """The detailed error message of resource management. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar code: The error code returned when exporting the template. :vartype code: str @@ -1353,7 +1537,10 @@ class ResourceManagementErrorWithDetails(Model): 'details': {'key': 'details', 'type': '[ResourceManagementErrorWithDetails]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ResourceManagementErrorWithDetails, self).__init__(**kwargs) self.code = None self.message = None @@ -1361,7 +1548,7 @@ def __init__(self, **kwargs): self.details = None -class ResourceProviderOperationDisplayProperties(Model): +class ResourceProviderOperationDisplayProperties(msrest.serialization.Model): """Resource provider operation's display properties. :param publisher: Operation description. @@ -1384,7 +1571,10 @@ class ResourceProviderOperationDisplayProperties(Model): 'description': {'key': 'description', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ResourceProviderOperationDisplayProperties, self).__init__(**kwargs) self.publisher = kwargs.get('publisher', None) self.provider = kwargs.get('provider', None) @@ -1393,7 +1583,7 @@ def __init__(self, **kwargs): self.description = kwargs.get('description', None) -class ResourcesMoveInfo(Model): +class ResourcesMoveInfo(msrest.serialization.Model): """Parameters of move resources. :param resources: The IDs of the resources. @@ -1407,13 +1597,16 @@ class ResourcesMoveInfo(Model): 'target_resource_group': {'key': 'targetResourceGroup', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ResourcesMoveInfo, self).__init__(**kwargs) self.resources = kwargs.get('resources', None) self.target_resource_group = kwargs.get('target_resource_group', None) -class Sku(Model): +class Sku(msrest.serialization.Model): """SKU for the resource. :param name: The SKU name. @@ -1439,7 +1632,10 @@ class Sku(Model): 'capacity': {'key': 'capacity', 'type': 'int'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Sku, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.tier = kwargs.get('tier', None) @@ -1449,10 +1645,10 @@ def __init__(self, **kwargs): self.capacity = kwargs.get('capacity', None) -class SubResource(Model): +class SubResource(msrest.serialization.Model): """Sub-resource. - :param id: Resource ID + :param id: Resource ID. :type id: str """ @@ -1460,12 +1656,15 @@ class SubResource(Model): 'id': {'key': 'id', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(SubResource, self).__init__(**kwargs) self.id = kwargs.get('id', None) -class TagCount(Model): +class TagCount(msrest.serialization.Model): """Tag count. :param type: Type of count. @@ -1479,29 +1678,29 @@ class TagCount(Model): 'value': {'key': 'value', 'type': 'int'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(TagCount, self).__init__(**kwargs) self.type = kwargs.get('type', None) self.value = kwargs.get('value', None) -class TagDetails(Model): +class TagDetails(msrest.serialization.Model): """Tag details. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :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 created and has no associated resources, the value - is 0. + :param 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] + :type values: list[~azure.mgmt.resource.resources.v2019_05_10.models.TagValue] """ _validation = { @@ -1515,7 +1714,10 @@ class TagDetails(Model): 'values': {'key': 'values', 'type': '[TagValue]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(TagDetails, self).__init__(**kwargs) self.id = None self.tag_name = kwargs.get('tag_name', None) @@ -1523,11 +1725,39 @@ def __init__(self, **kwargs): self.values = kwargs.get('values', None) -class TagValue(Model): +class TagsListResult(msrest.serialization.Model): + """List of subscription tags. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[TagDetails]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(TagsListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = None + + +class TagValue(msrest.serialization.Model): """Tag information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The tag ID. :vartype id: str @@ -1547,14 +1777,17 @@ class TagValue(Model): 'count': {'key': 'count', 'type': 'TagCount'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(TagValue, self).__init__(**kwargs) self.id = None self.tag_value = kwargs.get('tag_value', None) self.count = kwargs.get('count', None) -class TargetResource(Model): +class TargetResource(msrest.serialization.Model): """Target resource. :param id: The ID of the resource. @@ -1571,16 +1804,18 @@ class TargetResource(Model): 'resource_type': {'key': 'resourceType', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(TargetResource, self).__init__(**kwargs) self.id = kwargs.get('id', None) self.resource_name = kwargs.get('resource_name', None) self.resource_type = kwargs.get('resource_type', None) -class TemplateHashResult(Model): - """Result of the request to calculate template hash. It contains a string of - minified template and its hash. +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 @@ -1593,21 +1828,23 @@ class TemplateHashResult(Model): 'template_hash': {'key': 'templateHash', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(TemplateHashResult, self).__init__(**kwargs) self.minified_template = kwargs.get('minified_template', None) self.template_hash = kwargs.get('template_hash', None) -class TemplateLink(Model): +class TemplateLink(msrest.serialization.Model): """Entity representing the reference to the template. 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. + :param content_version: If included, must match the ContentVersion in the template. :type content_version: str """ @@ -1620,7 +1857,10 @@ class TemplateLink(Model): 'content_version': {'key': 'contentVersion', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(TemplateLink, self).__init__(**kwargs) - self.uri = kwargs.get('uri', None) + self.uri = kwargs['uri'] self.content_version = kwargs.get('content_version', 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 8152c7a3c4dc..72b320d1b04a 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 @@ -1,20 +1,20 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.serialization import Model -from msrest.exceptions import HttpOperationError +from typing import Dict, List, Optional, Union +import msrest.serialization -class AliasPathType(Model): - """The type of the paths for alias. . +from ._resource_management_client_enums import * + + +class AliasPathType(msrest.serialization.Model): + """The type of the paths for alias. :param path: The path of an alias. :type path: str @@ -27,20 +27,25 @@ class AliasPathType(Model): 'api_versions': {'key': 'apiVersions', 'type': '[str]'}, } - def __init__(self, *, path: str=None, api_versions=None, **kwargs) -> None: + def __init__( + self, + *, + path: Optional[str] = None, + api_versions: Optional[List[str]] = None, + **kwargs + ): super(AliasPathType, self).__init__(**kwargs) self.path = path self.api_versions = api_versions -class AliasType(Model): - """The alias type. . +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] + :type paths: list[~azure.mgmt.resource.resources.v2019_05_10.models.AliasPathType] """ _attribute_map = { @@ -48,13 +53,19 @@ class AliasType(Model): 'paths': {'key': 'paths', 'type': '[AliasPathType]'}, } - def __init__(self, *, name: str=None, paths=None, **kwargs) -> None: + def __init__( + self, + *, + name: Optional[str] = None, + paths: Optional[List["AliasPathType"]] = None, + **kwargs + ): super(AliasType, self).__init__(**kwargs) self.name = name self.paths = paths -class BasicDependency(Model): +class BasicDependency(msrest.serialization.Model): """Deployment dependency information. :param id: The ID of the dependency. @@ -71,52 +82,59 @@ class BasicDependency(Model): 'resource_name': {'key': 'resourceName', 'type': 'str'}, } - def __init__(self, *, id: str=None, resource_type: str=None, resource_name: str=None, **kwargs) -> None: + def __init__( + self, + *, + id: Optional[str] = None, + resource_type: Optional[str] = None, + resource_name: Optional[str] = None, + **kwargs + ): super(BasicDependency, self).__init__(**kwargs) self.id = id self.resource_type = resource_type self.resource_name = resource_name -class CloudError(Model): - """An error response for a resource management request. +class ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties(msrest.serialization.Model): + """ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties. - :param error: - :type error: - ~azure.mgmt.resource.resources.v2019_05_10.models.ErrorResponse + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar principal_id: The principal id of user assigned identity. + :vartype principal_id: str + :ivar client_id: The client id of user assigned identity. + :vartype client_id: str """ - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorResponse'}, + _validation = { + 'principal_id': {'readonly': True}, + 'client_id': {'readonly': True}, } - def __init__(self, *, error=None, **kwargs) -> None: - super(CloudError, self).__init__(**kwargs) - self.error = error - - -class CloudErrorException(HttpOperationError): - """Server responsed with exception of type: 'CloudError'. - - :param deserialize: A deserializer - :param response: Server response to be deserialized. - """ - - def __init__(self, deserialize, response, *args): + _attribute_map = { + 'principal_id': {'key': 'principalId', 'type': 'str'}, + 'client_id': {'key': 'clientId', 'type': 'str'}, + } - super(CloudErrorException, self).__init__(deserialize, response, 'CloudError', *args) + def __init__( + self, + **kwargs + ): + super(ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties, self).__init__(**kwargs) + self.principal_id = None + self.client_id = None -class DebugSetting(Model): +class DebugSetting(msrest.serialization.Model): """The debug setting. - :param 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. + :param 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 """ @@ -124,17 +142,21 @@ class DebugSetting(Model): 'detail_level': {'key': 'detailLevel', 'type': 'str'}, } - def __init__(self, *, detail_level: str=None, **kwargs) -> None: + def __init__( + self, + *, + detail_level: Optional[str] = None, + **kwargs + ): super(DebugSetting, self).__init__(**kwargs) self.detail_level = detail_level -class Dependency(Model): +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] + :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. @@ -150,7 +172,15 @@ class Dependency(Model): 'resource_name': {'key': 'resourceName', 'type': 'str'}, } - def __init__(self, *, depends_on=None, id: str=None, resource_type: str=None, resource_name: str=None, **kwargs) -> None: + def __init__( + self, + *, + depends_on: Optional[List["BasicDependency"]] = None, + id: Optional[str] = None, + resource_type: Optional[str] = None, + resource_name: Optional[str] = None, + **kwargs + ): super(Dependency, self).__init__(**kwargs) self.depends_on = depends_on self.id = id @@ -158,7 +188,7 @@ def __init__(self, *, depends_on=None, id: str=None, resource_type: str=None, re self.resource_name = resource_name -class Deployment(Model): +class Deployment(msrest.serialization.Model): """Deployment operation parameters. All required parameters must be populated in order to send to Azure. @@ -166,8 +196,7 @@ class Deployment(Model): :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 + :type properties: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentProperties """ _validation = { @@ -179,14 +208,20 @@ class Deployment(Model): 'properties': {'key': 'properties', 'type': 'DeploymentProperties'}, } - def __init__(self, *, properties, location: str=None, **kwargs) -> None: + def __init__( + self, + *, + properties: "DeploymentProperties", + location: Optional[str] = None, + **kwargs + ): super(Deployment, self).__init__(**kwargs) self.location = location self.properties = properties -class DeploymentExportResult(Model): - """The deployment export result. . +class DeploymentExportResult(msrest.serialization.Model): + """The deployment export result. :param template: The template content. :type template: object @@ -196,16 +231,20 @@ class DeploymentExportResult(Model): 'template': {'key': 'template', 'type': 'object'}, } - def __init__(self, *, template=None, **kwargs) -> None: + def __init__( + self, + *, + template: Optional[object] = None, + **kwargs + ): super(DeploymentExportResult, self).__init__(**kwargs) self.template = template -class DeploymentExtended(Model): +class DeploymentExtended(msrest.serialization.Model): """Deployment information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The ID of the deployment. :vartype id: str @@ -234,7 +273,13 @@ class DeploymentExtended(Model): 'properties': {'key': 'properties', 'type': 'DeploymentPropertiesExtended'}, } - def __init__(self, *, location: str=None, properties=None, **kwargs) -> None: + def __init__( + self, + *, + location: Optional[str] = None, + properties: Optional["DeploymentPropertiesExtended"] = None, + **kwargs + ): super(DeploymentExtended, self).__init__(**kwargs) self.id = None self.name = None @@ -243,7 +288,7 @@ def __init__(self, *, location: str=None, properties=None, **kwargs) -> None: self.properties = properties -class DeploymentExtendedFilter(Model): +class DeploymentExtendedFilter(msrest.serialization.Model): """Deployment filter. :param provisioning_state: The provisioning state. @@ -254,16 +299,51 @@ class DeploymentExtendedFilter(Model): 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, } - def __init__(self, *, provisioning_state: str=None, **kwargs) -> None: + def __init__( + self, + *, + provisioning_state: Optional[str] = None, + **kwargs + ): super(DeploymentExtendedFilter, self).__init__(**kwargs) self.provisioning_state = provisioning_state -class DeploymentOperation(Model): +class DeploymentListResult(msrest.serialization.Model): + """List of deployments. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[DeploymentExtended]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["DeploymentExtended"]] = None, + **kwargs + ): + super(DeploymentListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class DeploymentOperation(msrest.serialization.Model): """Deployment operation information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Full deployment operation ID. :vartype id: str @@ -285,23 +365,27 @@ class DeploymentOperation(Model): 'properties': {'key': 'properties', 'type': 'DeploymentOperationProperties'}, } - def __init__(self, *, properties=None, **kwargs) -> None: + def __init__( + self, + *, + properties: Optional["DeploymentOperationProperties"] = None, + **kwargs + ): super(DeploymentOperation, self).__init__(**kwargs) self.id = None self.operation_id = None self.properties = properties -class DeploymentOperationProperties(Model): +class DeploymentOperationProperties(msrest.serialization.Model): """Deployment operation properties. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar provisioning_state: The state of the provisioning. :vartype provisioning_state: str :ivar timestamp: The date and time of the operation. - :vartype timestamp: datetime + :vartype timestamp: ~datetime.datetime :ivar duration: The duration of the operation. :vartype duration: str :ivar service_request_id: Deployment operation service request id. @@ -311,14 +395,11 @@ class DeploymentOperationProperties(Model): :ivar status_message: Operation status message. :vartype status_message: object :ivar target_resource: The target resource. - :vartype target_resource: - ~azure.mgmt.resource.resources.v2019_05_10.models.TargetResource + :vartype target_resource: ~azure.mgmt.resource.resources.v2019_05_10.models.TargetResource :ivar request: The HTTP request message. - :vartype request: - ~azure.mgmt.resource.resources.v2019_05_10.models.HttpMessage + :vartype request: ~azure.mgmt.resource.resources.v2019_05_10.models.HttpMessage :ivar response: The HTTP response message. - :vartype response: - ~azure.mgmt.resource.resources.v2019_05_10.models.HttpMessage + :vartype response: ~azure.mgmt.resource.resources.v2019_05_10.models.HttpMessage """ _validation = { @@ -345,7 +426,10 @@ class DeploymentOperationProperties(Model): 'response': {'key': 'response', 'type': 'HttpMessage'}, } - def __init__(self, **kwargs) -> None: + def __init__( + self, + **kwargs + ): super(DeploymentOperationProperties, self).__init__(**kwargs) self.provisioning_state = None self.timestamp = None @@ -358,48 +442,70 @@ def __init__(self, **kwargs) -> None: self.response = None -class DeploymentProperties(Model): +class DeploymentOperationsListResult(msrest.serialization.Model): + """List of deployment operations. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[DeploymentOperation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["DeploymentOperation"]] = None, + **kwargs + ): + super(DeploymentOperationsListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class DeploymentProperties(msrest.serialization.Model): """Deployment properties. 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 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. + :param 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: object - :param 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. 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. + :param 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. + 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: object - :param 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 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 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 + 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 + :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 + :type on_error_deployment: ~azure.mgmt.resource.resources.v2019_05_10.models.OnErrorDeployment """ _validation = { @@ -411,12 +517,23 @@ class DeploymentProperties(Model): 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, 'parameters': {'key': 'parameters', 'type': 'object'}, 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, - 'mode': {'key': 'mode', 'type': 'DeploymentMode'}, + 'mode': {'key': 'mode', 'type': 'str'}, 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, 'on_error_deployment': {'key': 'onErrorDeployment', 'type': 'OnErrorDeployment'}, } - def __init__(self, *, mode, template=None, template_link=None, parameters=None, parameters_link=None, debug_setting=None, on_error_deployment=None, **kwargs) -> None: + def __init__( + self, + *, + mode: Union[str, "DeploymentMode"], + template: Optional[object] = None, + template_link: Optional["TemplateLink"] = None, + parameters: Optional[object] = None, + parameters_link: Optional["ParametersLink"] = None, + debug_setting: Optional["DebugSetting"] = None, + on_error_deployment: Optional["OnErrorDeployment"] = None, + **kwargs + ): super(DeploymentProperties, self).__init__(**kwargs) self.template = template self.template_link = template_link @@ -427,50 +544,40 @@ def __init__(self, *, mode, template=None, template_link=None, parameters=None, self.on_error_deployment = on_error_deployment -class DeploymentPropertiesExtended(Model): +class DeploymentPropertiesExtended(msrest.serialization.Model): """Deployment properties with additional details. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :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 + :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: object - :param providers: The list of resource providers needed for the - deployment. - :type providers: - list[~azure.mgmt.resource.resources.v2019_05_10.models.Provider] + :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 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: object - :param 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. + :param 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: object - :param 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 include: 'Incremental', 'Complete' - :type mode: str or - ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentMode + :param 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 + 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 + :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.OnErrorDeploymentExtended @@ -495,12 +602,26 @@ class DeploymentPropertiesExtended(Model): 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, 'parameters': {'key': 'parameters', 'type': 'object'}, 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, - 'mode': {'key': 'mode', 'type': 'DeploymentMode'}, + 'mode': {'key': 'mode', 'type': 'str'}, 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, 'on_error_deployment': {'key': 'onErrorDeployment', 'type': 'OnErrorDeploymentExtended'}, } - def __init__(self, *, outputs=None, providers=None, dependencies=None, template=None, template_link=None, parameters=None, parameters_link=None, mode=None, debug_setting=None, on_error_deployment=None, **kwargs) -> None: + def __init__( + self, + *, + outputs: Optional[object] = None, + providers: Optional[List["Provider"]] = None, + dependencies: Optional[List["Dependency"]] = None, + template: Optional[object] = None, + template_link: Optional["TemplateLink"] = None, + parameters: Optional[object] = None, + parameters_link: Optional["ParametersLink"] = None, + mode: Optional[Union[str, "DeploymentMode"]] = None, + debug_setting: Optional["DebugSetting"] = None, + on_error_deployment: Optional["OnErrorDeploymentExtended"] = None, + **kwargs + ): super(DeploymentPropertiesExtended, self).__init__(**kwargs) self.provisioning_state = None self.correlation_id = None @@ -518,7 +639,7 @@ def __init__(self, *, outputs=None, providers=None, dependencies=None, template= self.on_error_deployment = on_error_deployment -class DeploymentValidateResult(Model): +class DeploymentValidateResult(msrest.serialization.Model): """Information from validate template deployment response. :param error: Validation error. @@ -534,17 +655,22 @@ class DeploymentValidateResult(Model): 'properties': {'key': 'properties', 'type': 'DeploymentPropertiesExtended'}, } - def __init__(self, *, error=None, properties=None, **kwargs) -> None: + def __init__( + self, + *, + error: Optional["ResourceManagementErrorWithDetails"] = None, + properties: Optional["DeploymentPropertiesExtended"] = None, + **kwargs + ): super(DeploymentValidateResult, self).__init__(**kwargs) self.error = error self.properties = properties -class ErrorAdditionalInfo(Model): +class ErrorAdditionalInfo(msrest.serialization.Model): """The resource management error additional info. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar type: The additional info type. :vartype type: str @@ -562,17 +688,19 @@ class ErrorAdditionalInfo(Model): 'info': {'key': 'info', 'type': 'object'}, } - def __init__(self, **kwargs) -> None: + def __init__( + self, + **kwargs + ): super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None -class ErrorResponse(Model): +class ErrorResponse(msrest.serialization.Model): """The resource management error response. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar code: The error code. :vartype code: str @@ -581,8 +709,7 @@ class ErrorResponse(Model): :ivar target: The error target. :vartype target: str :ivar details: The error details. - :vartype details: - list[~azure.mgmt.resource.resources.v2019_05_10.models.ErrorResponse] + :vartype details: list[~azure.mgmt.resource.resources.v2019_05_10.models.ErrorResponse] :ivar additional_info: The error additional info. :vartype additional_info: list[~azure.mgmt.resource.resources.v2019_05_10.models.ErrorAdditionalInfo] @@ -604,7 +731,10 @@ class ErrorResponse(Model): 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, } - def __init__(self, **kwargs) -> None: + def __init__( + self, + **kwargs + ): super(ErrorResponse, self).__init__(**kwargs) self.code = None self.message = None @@ -613,16 +743,15 @@ def __init__(self, **kwargs) -> None: self.additional_info = None -class ExportTemplateRequest(Model): +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, supply an array with single entry '*'. + :param 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', 'SkipResourceNameParameterization', - 'SkipAllParameterization' + :param options: The export template options. A CSV-formatted list containing zero or more of + the following: 'IncludeParameterDefaultValue', 'IncludeComments', + 'SkipResourceNameParameterization', 'SkipAllParameterization'. :type options: str """ @@ -631,27 +760,32 @@ class ExportTemplateRequest(Model): 'options': {'key': 'options', 'type': 'str'}, } - def __init__(self, *, resources=None, options: str=None, **kwargs) -> None: + def __init__( + self, + *, + resources: Optional[List[str]] = None, + options: Optional[str] = None, + **kwargs + ): super(ExportTemplateRequest, self).__init__(**kwargs) self.resources = resources self.options = options -class Resource(Model): +class Resource(msrest.serialization.Model): """Specified resource. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID + :ivar id: Resource ID. :vartype id: str - :ivar name: Resource name + :ivar name: Resource name. :vartype name: str - :ivar type: Resource type + :ivar type: Resource type. :vartype type: str - :param location: Resource location + :param location: Resource location. :type location: str - :param tags: Resource tags + :param tags: A set of tags. Resource tags. :type tags: dict[str, str] """ @@ -669,7 +803,13 @@ class Resource(Model): 'tags': {'key': 'tags', 'type': '{str}'}, } - def __init__(self, *, location: str=None, tags=None, **kwargs) -> None: + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -681,18 +821,17 @@ def __init__(self, *, location: str=None, tags=None, **kwargs) -> None: class GenericResource(Resource): """Resource information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID + :ivar id: Resource ID. :vartype id: str - :ivar name: Resource name + :ivar name: Resource name. :vartype name: str - :ivar type: Resource type + :ivar type: Resource type. :vartype type: str - :param location: Resource location + :param location: Resource location. :type location: str - :param tags: Resource tags + :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 @@ -729,7 +868,19 @@ class GenericResource(Resource): 'identity': {'key': 'identity', 'type': 'Identity'}, } - def __init__(self, *, location: str=None, tags=None, plan=None, properties=None, kind: str=None, managed_by: str=None, sku=None, identity=None, **kwargs) -> None: + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + plan: Optional["Plan"] = None, + properties: Optional[object] = None, + kind: Optional[str] = None, + managed_by: Optional[str] = None, + sku: Optional["Sku"] = None, + identity: Optional["Identity"] = None, + **kwargs + ): super(GenericResource, self).__init__(location=location, tags=tags, **kwargs) self.plan = plan self.properties = properties @@ -742,18 +893,17 @@ def __init__(self, *, location: str=None, tags=None, plan=None, properties=None, class GenericResourceExpanded(GenericResource): """Resource information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID + :ivar id: Resource ID. :vartype id: str - :ivar name: Resource name + :ivar name: Resource name. :vartype name: str - :ivar type: Resource type + :ivar type: Resource type. :vartype type: str - :param location: Resource location + :param location: Resource location. :type location: str - :param tags: Resource tags + :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 @@ -767,14 +917,14 @@ class GenericResourceExpanded(GenericResource): :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 created_time: The created time of the resource. This is only present - if requested via the $expand query parameter. - :vartype created_time: datetime - :ivar changed_time: The changed time of the resource. This is only present - if requested via the $expand query parameter. - :vartype changed_time: datetime - :ivar provisioning_state: The provisioning state of the resource. This is - only present if requested via the $expand query parameter. + :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 + :ivar changed_time: The changed time of the resource. This is only present if requested via the + $expand query parameter. + :vartype changed_time: ~datetime.datetime + :ivar provisioning_state: The provisioning state of the resource. This is only present if + requested via the $expand query parameter. :vartype provisioning_state: str """ @@ -805,14 +955,26 @@ class GenericResourceExpanded(GenericResource): 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, } - def __init__(self, *, location: str=None, tags=None, plan=None, properties=None, kind: str=None, managed_by: str=None, sku=None, identity=None, **kwargs) -> None: + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + plan: Optional["Plan"] = None, + properties: Optional[object] = None, + kind: Optional[str] = None, + managed_by: Optional[str] = None, + sku: Optional["Sku"] = None, + identity: Optional["Identity"] = None, + **kwargs + ): 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 self.provisioning_state = None -class GenericResourceFilter(Model): +class GenericResourceFilter(msrest.serialization.Model): """Resource filter. :param resource_type: The resource type. @@ -829,14 +991,21 @@ class GenericResourceFilter(Model): 'tagvalue': {'key': 'tagvalue', 'type': 'str'}, } - def __init__(self, *, resource_type: str=None, tagname: str=None, tagvalue: str=None, **kwargs) -> None: + def __init__( + self, + *, + resource_type: Optional[str] = None, + tagname: Optional[str] = None, + tagvalue: Optional[str] = None, + **kwargs + ): super(GenericResourceFilter, self).__init__(**kwargs) self.resource_type = resource_type self.tagname = tagname self.tagvalue = tagvalue -class HttpMessage(Model): +class HttpMessage(msrest.serialization.Model): """HTTP message. :param content: HTTP message content. @@ -847,31 +1016,33 @@ class HttpMessage(Model): 'content': {'key': 'content', 'type': 'object'}, } - def __init__(self, *, content=None, **kwargs) -> None: + def __init__( + self, + *, + content: Optional[object] = None, + **kwargs + ): super(HttpMessage, self).__init__(**kwargs) self.content = content -class Identity(Model): +class Identity(msrest.serialization.Model): """Identity for the resource. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar principal_id: The principal ID of resource identity. :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :param 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 user identity dictionary key references will be ARM - resource ids in the form: + :param 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 + 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, - ~azure.mgmt.resource.resources.v2019_05_10.models.IdentityUserAssignedIdentitiesValue] + ~azure.mgmt.resource.resources.v2019_05_10.models.ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties] """ _validation = { @@ -882,11 +1053,17 @@ class Identity(Model): _attribute_map = { 'principal_id': {'key': 'principalId', 'type': 'str'}, 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'ResourceIdentityType'}, - 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{IdentityUserAssignedIdentitiesValue}'}, + 'type': {'key': 'type', 'type': 'str'}, + 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties}'}, } - def __init__(self, *, type=None, user_assigned_identities=None, **kwargs) -> None: + def __init__( + self, + *, + type: Optional[Union[str, "ResourceIdentityType"]] = None, + user_assigned_identities: Optional[Dict[str, "ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties"]] = None, + **kwargs + ): super(Identity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None @@ -894,71 +1071,43 @@ def __init__(self, *, type=None, user_assigned_identities=None, **kwargs) -> Non self.user_assigned_identities = user_assigned_identities -class IdentityUserAssignedIdentitiesValue(Model): - """IdentityUserAssignedIdentitiesValue. - - Variables are only populated by the server, and will be ignored when - sending a request. - - :ivar principal_id: The principal id of user assigned identity. - :vartype principal_id: str - :ivar client_id: The client id of user assigned identity. - :vartype client_id: str - """ - - _validation = { - 'principal_id': {'readonly': True}, - 'client_id': {'readonly': True}, - } - - _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'client_id': {'key': 'clientId', 'type': 'str'}, - } - - def __init__(self, **kwargs) -> None: - super(IdentityUserAssignedIdentitiesValue, self).__init__(**kwargs) - self.principal_id = None - self.client_id = None - - -class OnErrorDeployment(Model): +class OnErrorDeployment(msrest.serialization.Model): """Deployment on error behavior. - :param 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 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 """ _attribute_map = { - 'type': {'key': 'type', 'type': 'OnErrorDeploymentType'}, + 'type': {'key': 'type', 'type': 'str'}, 'deployment_name': {'key': 'deploymentName', 'type': 'str'}, } - def __init__(self, *, type=None, deployment_name: str=None, **kwargs) -> None: + def __init__( + self, + *, + type: Optional[Union[str, "OnErrorDeploymentType"]] = None, + deployment_name: Optional[str] = None, + **kwargs + ): super(OnErrorDeployment, self).__init__(**kwargs) self.type = type self.deployment_name = deployment_name -class OnErrorDeploymentExtended(Model): +class OnErrorDeploymentExtended(msrest.serialization.Model): """Deployment on error behavior with additional details. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar provisioning_state: The state of the provisioning for the on error - deployment. + :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 SpecificDeployment. Possible values include: - 'LastSuccessful', 'SpecificDeployment' - :type type: str or - ~azure.mgmt.resource.resources.v2019_05_10.models.OnErrorDeploymentType + :param 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 """ @@ -969,25 +1118,30 @@ class OnErrorDeploymentExtended(Model): _attribute_map = { 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'OnErrorDeploymentType'}, + 'type': {'key': 'type', 'type': 'str'}, 'deployment_name': {'key': 'deploymentName', 'type': 'str'}, } - def __init__(self, *, type=None, deployment_name: str=None, **kwargs) -> None: + def __init__( + self, + *, + type: Optional[Union[str, "OnErrorDeploymentType"]] = None, + deployment_name: Optional[str] = None, + **kwargs + ): super(OnErrorDeploymentExtended, self).__init__(**kwargs) self.provisioning_state = None self.type = type self.deployment_name = deployment_name -class Operation(Model): +class Operation(msrest.serialization.Model): """Microsoft.Resources operation. - :param name: Operation name: {provider}/{resource}/{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 + :type display: ~azure.mgmt.resource.resources.v2019_05_10.models.OperationDisplay """ _attribute_map = { @@ -995,19 +1149,24 @@ class Operation(Model): 'display': {'key': 'display', 'type': 'OperationDisplay'}, } - def __init__(self, *, name: str=None, display=None, **kwargs) -> None: + def __init__( + self, + *, + name: Optional[str] = None, + display: Optional["OperationDisplay"] = None, + **kwargs + ): super(Operation, self).__init__(**kwargs) self.name = name self.display = display -class OperationDisplay(Model): +class OperationDisplay(msrest.serialization.Model): """The object that represents the operation. - :param provider: Service provider: Microsoft.Resources + :param provider: Service provider: Microsoft.Resources. :type provider: str - :param resource: Resource on which the operation is performed: Profile, - endpoint, etc. + :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 @@ -1022,7 +1181,15 @@ class OperationDisplay(Model): 'description': {'key': 'description', 'type': 'str'}, } - def __init__(self, *, provider: str=None, resource: str=None, operation: str=None, description: str=None, **kwargs) -> None: + def __init__( + self, + *, + provider: Optional[str] = None, + resource: Optional[str] = None, + operation: Optional[str] = None, + description: Optional[str] = None, + **kwargs + ): super(OperationDisplay, self).__init__(**kwargs) self.provider = provider self.resource = resource @@ -1030,15 +1197,40 @@ def __init__(self, *, provider: str=None, resource: str=None, operation: str=Non self.description = description -class ParametersLink(Model): +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 + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Operation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["Operation"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(OperationListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ParametersLink(msrest.serialization.Model): """Entity representing the reference to the deployment parameters. 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. + :param content_version: If included, must match the ContentVersion in the template. :type content_version: str """ @@ -1051,13 +1243,19 @@ class ParametersLink(Model): 'content_version': {'key': 'contentVersion', 'type': 'str'}, } - def __init__(self, *, uri: str, content_version: str=None, **kwargs) -> None: + def __init__( + self, + *, + uri: str, + content_version: Optional[str] = None, + **kwargs + ): super(ParametersLink, self).__init__(**kwargs) self.uri = uri self.content_version = content_version -class Plan(Model): +class Plan(msrest.serialization.Model): """Plan for the resource. :param name: The plan ID. @@ -1080,7 +1278,16 @@ class Plan(Model): 'version': {'key': 'version', 'type': 'str'}, } - def __init__(self, *, name: str=None, publisher: str=None, product: str=None, promotion_code: str=None, version: str=None, **kwargs) -> None: + def __init__( + self, + *, + name: Optional[str] = None, + publisher: Optional[str] = None, + product: Optional[str] = None, + promotion_code: Optional[str] = None, + version: Optional[str] = None, + **kwargs + ): super(Plan, self).__init__(**kwargs) self.name = name self.publisher = publisher @@ -1089,11 +1296,10 @@ def __init__(self, *, name: str=None, publisher: str=None, product: str=None, pr self.version = version -class Provider(Model): +class Provider(msrest.serialization.Model): """Resource provider information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The provider ID. :vartype id: str @@ -1101,8 +1307,7 @@ class Provider(Model): :type 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. + :ivar registration_policy: The registration policy of the resource provider. :vartype registration_policy: str :ivar resource_types: The collection of provider resource types. :vartype resource_types: @@ -1124,7 +1329,12 @@ class Provider(Model): 'resource_types': {'key': 'resourceTypes', 'type': '[ProviderResourceType]'}, } - def __init__(self, *, namespace: str=None, **kwargs) -> None: + def __init__( + self, + *, + namespace: Optional[str] = None, + **kwargs + ): super(Provider, self).__init__(**kwargs) self.id = None self.namespace = namespace @@ -1133,21 +1343,49 @@ def __init__(self, *, namespace: str=None, **kwargs) -> None: self.resource_types = None -class ProviderResourceType(Model): +class ProviderListResult(msrest.serialization.Model): + """List of resource providers. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Provider]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["Provider"]] = None, + **kwargs + ): + super(ProviderListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +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. + :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] + :type aliases: list[~azure.mgmt.resource.resources.v2019_05_10.models.AliasType] :param api_versions: The API version. :type api_versions: list[str] - :param capabilities: The additional capabilities offered by this resource - type. + :param capabilities: The additional capabilities offered by this resource type. :type capabilities: str :param properties: The properties. :type properties: dict[str, str] @@ -1162,7 +1400,17 @@ class ProviderResourceType(Model): 'properties': {'key': 'properties', 'type': '{str}'}, } - def __init__(self, *, resource_type: str=None, locations=None, aliases=None, api_versions=None, capabilities: str=None, properties=None, **kwargs) -> None: + def __init__( + self, + *, + resource_type: Optional[str] = None, + locations: Optional[List[str]] = None, + aliases: Optional[List["AliasType"]] = None, + api_versions: Optional[List[str]] = None, + capabilities: Optional[str] = None, + properties: Optional[Dict[str, str]] = None, + **kwargs + ): super(ProviderResourceType, self).__init__(**kwargs) self.resource_type = resource_type self.locations = locations @@ -1172,11 +1420,10 @@ def __init__(self, *, resource_type: str=None, locations=None, aliases=None, api self.properties = properties -class ResourceGroup(Model): +class ResourceGroup(msrest.serialization.Model): """Resource group information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. @@ -1187,16 +1434,13 @@ class ResourceGroup(Model): :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 resource group has been created. It must be one of - the supported Azure locations. + :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 + 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. + :param managed_by: The ID of the resource that manages this resource group. :type managed_by: str - :param tags: The tags attached to the resource group. + :param tags: A set of tags. The tags attached to the resource group. :type tags: dict[str, str] """ @@ -1217,7 +1461,15 @@ class ResourceGroup(Model): 'tags': {'key': 'tags', 'type': '{str}'}, } - def __init__(self, *, location: str, properties=None, managed_by: str=None, tags=None, **kwargs) -> None: + def __init__( + self, + *, + location: str, + properties: Optional["ResourceGroupProperties"] = None, + managed_by: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): super(ResourceGroup, self).__init__(**kwargs) self.id = None self.name = None @@ -1228,7 +1480,7 @@ def __init__(self, *, location: str, properties=None, managed_by: str=None, tags self.tags = tags -class ResourceGroupExportResult(Model): +class ResourceGroupExportResult(msrest.serialization.Model): """Resource group export result. :param template: The template content. @@ -1243,13 +1495,19 @@ class ResourceGroupExportResult(Model): 'error': {'key': 'error', 'type': 'ResourceManagementErrorWithDetails'}, } - def __init__(self, *, template=None, error=None, **kwargs) -> None: + def __init__( + self, + *, + template: Optional[object] = None, + error: Optional["ResourceManagementErrorWithDetails"] = None, + **kwargs + ): super(ResourceGroupExportResult, self).__init__(**kwargs) self.template = template self.error = error -class ResourceGroupFilter(Model): +class ResourceGroupFilter(msrest.serialization.Model): """Resource group filter. :param tag_name: The tag name. @@ -1263,24 +1521,59 @@ class ResourceGroupFilter(Model): 'tag_value': {'key': 'tagValue', 'type': 'str'}, } - def __init__(self, *, tag_name: str=None, tag_value: str=None, **kwargs) -> None: + def __init__( + self, + *, + tag_name: Optional[str] = None, + tag_value: Optional[str] = None, + **kwargs + ): super(ResourceGroupFilter, self).__init__(**kwargs) self.tag_name = tag_name self.tag_value = tag_value -class ResourceGroupPatchable(Model): +class ResourceGroupListResult(msrest.serialization.Model): + """List of resource groups. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ResourceGroup]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["ResourceGroup"]] = None, + **kwargs + ): + super(ResourceGroupListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +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 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: The tags attached to the resource group. + :param tags: A set of tags. The tags attached to the resource group. :type tags: dict[str, str] """ @@ -1291,7 +1584,15 @@ class ResourceGroupPatchable(Model): 'tags': {'key': 'tags', 'type': '{str}'}, } - def __init__(self, *, name: str=None, properties=None, managed_by: str=None, tags=None, **kwargs) -> None: + def __init__( + self, + *, + name: Optional[str] = None, + properties: Optional["ResourceGroupProperties"] = None, + managed_by: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): super(ResourceGroupPatchable, self).__init__(**kwargs) self.name = name self.properties = properties @@ -1299,11 +1600,10 @@ def __init__(self, *, name: str=None, properties=None, managed_by: str=None, tag self.tags = tags -class ResourceGroupProperties(Model): +class ResourceGroupProperties(msrest.serialization.Model): """The resource group properties. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar provisioning_state: The provisioning state. :vartype provisioning_state: str @@ -1317,16 +1617,49 @@ class ResourceGroupProperties(Model): 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, } - def __init__(self, **kwargs) -> None: + def __init__( + self, + **kwargs + ): super(ResourceGroupProperties, self).__init__(**kwargs) self.provisioning_state = None -class ResourceManagementErrorWithDetails(Model): +class ResourceListResult(msrest.serialization.Model): + """List of resource groups. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[GenericResourceExpanded]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["GenericResourceExpanded"]] = None, + **kwargs + ): + super(ResourceListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class ResourceManagementErrorWithDetails(msrest.serialization.Model): """The detailed error message of resource management. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar code: The error code returned when exporting the template. :vartype code: str @@ -1353,7 +1686,10 @@ class ResourceManagementErrorWithDetails(Model): 'details': {'key': 'details', 'type': '[ResourceManagementErrorWithDetails]'}, } - def __init__(self, **kwargs) -> None: + def __init__( + self, + **kwargs + ): super(ResourceManagementErrorWithDetails, self).__init__(**kwargs) self.code = None self.message = None @@ -1361,7 +1697,7 @@ def __init__(self, **kwargs) -> None: self.details = None -class ResourceProviderOperationDisplayProperties(Model): +class ResourceProviderOperationDisplayProperties(msrest.serialization.Model): """Resource provider operation's display properties. :param publisher: Operation description. @@ -1384,7 +1720,16 @@ class ResourceProviderOperationDisplayProperties(Model): 'description': {'key': 'description', 'type': 'str'}, } - def __init__(self, *, publisher: str=None, provider: str=None, resource: str=None, operation: str=None, description: str=None, **kwargs) -> None: + def __init__( + self, + *, + publisher: Optional[str] = None, + provider: Optional[str] = None, + resource: Optional[str] = None, + operation: Optional[str] = None, + description: Optional[str] = None, + **kwargs + ): super(ResourceProviderOperationDisplayProperties, self).__init__(**kwargs) self.publisher = publisher self.provider = provider @@ -1393,7 +1738,7 @@ def __init__(self, *, publisher: str=None, provider: str=None, resource: str=Non self.description = description -class ResourcesMoveInfo(Model): +class ResourcesMoveInfo(msrest.serialization.Model): """Parameters of move resources. :param resources: The IDs of the resources. @@ -1407,13 +1752,19 @@ class ResourcesMoveInfo(Model): 'target_resource_group': {'key': 'targetResourceGroup', 'type': 'str'}, } - def __init__(self, *, resources=None, target_resource_group: str=None, **kwargs) -> None: + def __init__( + self, + *, + resources: Optional[List[str]] = None, + target_resource_group: Optional[str] = None, + **kwargs + ): super(ResourcesMoveInfo, self).__init__(**kwargs) self.resources = resources self.target_resource_group = target_resource_group -class Sku(Model): +class Sku(msrest.serialization.Model): """SKU for the resource. :param name: The SKU name. @@ -1439,7 +1790,17 @@ class Sku(Model): 'capacity': {'key': 'capacity', 'type': 'int'}, } - def __init__(self, *, name: str=None, tier: str=None, size: str=None, family: str=None, model: str=None, capacity: int=None, **kwargs) -> None: + def __init__( + self, + *, + name: Optional[str] = None, + tier: Optional[str] = None, + size: Optional[str] = None, + family: Optional[str] = None, + model: Optional[str] = None, + capacity: Optional[int] = None, + **kwargs + ): super(Sku, self).__init__(**kwargs) self.name = name self.tier = tier @@ -1449,10 +1810,10 @@ def __init__(self, *, name: str=None, tier: str=None, size: str=None, family: st self.capacity = capacity -class SubResource(Model): +class SubResource(msrest.serialization.Model): """Sub-resource. - :param id: Resource ID + :param id: Resource ID. :type id: str """ @@ -1460,12 +1821,17 @@ class SubResource(Model): 'id': {'key': 'id', 'type': 'str'}, } - def __init__(self, *, id: str=None, **kwargs) -> None: + def __init__( + self, + *, + id: Optional[str] = None, + **kwargs + ): super(SubResource, self).__init__(**kwargs) self.id = id -class TagCount(Model): +class TagCount(msrest.serialization.Model): """Tag count. :param type: Type of count. @@ -1479,29 +1845,32 @@ class TagCount(Model): 'value': {'key': 'value', 'type': 'int'}, } - def __init__(self, *, type: str=None, value: int=None, **kwargs) -> None: + def __init__( + self, + *, + type: Optional[str] = None, + value: Optional[int] = None, + **kwargs + ): super(TagCount, self).__init__(**kwargs) self.type = type self.value = value -class TagDetails(Model): +class TagDetails(msrest.serialization.Model): """Tag details. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :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 created and has no associated resources, the value - is 0. + :param 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] + :type values: list[~azure.mgmt.resource.resources.v2019_05_10.models.TagValue] """ _validation = { @@ -1515,7 +1884,14 @@ class TagDetails(Model): 'values': {'key': 'values', 'type': '[TagValue]'}, } - def __init__(self, *, tag_name: str=None, count=None, values=None, **kwargs) -> None: + def __init__( + self, + *, + tag_name: Optional[str] = None, + count: Optional["TagCount"] = None, + values: Optional[List["TagValue"]] = None, + **kwargs + ): super(TagDetails, self).__init__(**kwargs) self.id = None self.tag_name = tag_name @@ -1523,11 +1899,41 @@ def __init__(self, *, tag_name: str=None, count=None, values=None, **kwargs) -> self.values = values -class TagValue(Model): +class TagsListResult(msrest.serialization.Model): + """List of subscription tags. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[TagDetails]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["TagDetails"]] = None, + **kwargs + ): + super(TagsListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class TagValue(msrest.serialization.Model): """Tag information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The tag ID. :vartype id: str @@ -1547,14 +1953,20 @@ class TagValue(Model): 'count': {'key': 'count', 'type': 'TagCount'}, } - def __init__(self, *, tag_value: str=None, count=None, **kwargs) -> None: + def __init__( + self, + *, + tag_value: Optional[str] = None, + count: Optional["TagCount"] = None, + **kwargs + ): super(TagValue, self).__init__(**kwargs) self.id = None self.tag_value = tag_value self.count = count -class TargetResource(Model): +class TargetResource(msrest.serialization.Model): """Target resource. :param id: The ID of the resource. @@ -1571,16 +1983,22 @@ class TargetResource(Model): 'resource_type': {'key': 'resourceType', 'type': 'str'}, } - def __init__(self, *, id: str=None, resource_name: str=None, resource_type: str=None, **kwargs) -> None: + def __init__( + self, + *, + id: Optional[str] = None, + resource_name: Optional[str] = None, + resource_type: Optional[str] = None, + **kwargs + ): super(TargetResource, self).__init__(**kwargs) self.id = id self.resource_name = resource_name self.resource_type = resource_type -class TemplateHashResult(Model): - """Result of the request to calculate template hash. It contains a string of - minified template and its hash. +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 @@ -1593,21 +2011,26 @@ class TemplateHashResult(Model): 'template_hash': {'key': 'templateHash', 'type': 'str'}, } - def __init__(self, *, minified_template: str=None, template_hash: str=None, **kwargs) -> None: + def __init__( + self, + *, + minified_template: Optional[str] = None, + template_hash: Optional[str] = None, + **kwargs + ): super(TemplateHashResult, self).__init__(**kwargs) self.minified_template = minified_template self.template_hash = template_hash -class TemplateLink(Model): +class TemplateLink(msrest.serialization.Model): """Entity representing the reference to the template. 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. + :param content_version: If included, must match the ContentVersion in the template. :type content_version: str """ @@ -1620,7 +2043,13 @@ class TemplateLink(Model): 'content_version': {'key': 'contentVersion', 'type': 'str'}, } - def __init__(self, *, uri: str, content_version: str=None, **kwargs) -> None: + def __init__( + self, + *, + uri: str, + content_version: Optional[str] = None, + **kwargs + ): 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/v2019_05_10/models/_paged_models.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/models/_paged_models.py deleted file mode 100644 index 1e2a6f61155f..000000000000 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/models/_paged_models.py +++ /dev/null @@ -1,105 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.paging import Paged - - -class OperationPaged(Paged): - """ - A paging container for iterating over a list of :class:`Operation ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[Operation]'} - } - - def __init__(self, *args, **kwargs): - - super(OperationPaged, self).__init__(*args, **kwargs) -class DeploymentExtendedPaged(Paged): - """ - A paging container for iterating over a list of :class:`DeploymentExtended ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[DeploymentExtended]'} - } - - def __init__(self, *args, **kwargs): - - super(DeploymentExtendedPaged, self).__init__(*args, **kwargs) -class ProviderPaged(Paged): - """ - A paging container for iterating over a list of :class:`Provider ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[Provider]'} - } - - def __init__(self, *args, **kwargs): - - super(ProviderPaged, self).__init__(*args, **kwargs) -class GenericResourceExpandedPaged(Paged): - """ - A paging container for iterating over a list of :class:`GenericResourceExpanded ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[GenericResourceExpanded]'} - } - - def __init__(self, *args, **kwargs): - - super(GenericResourceExpandedPaged, self).__init__(*args, **kwargs) -class ResourceGroupPaged(Paged): - """ - A paging container for iterating over a list of :class:`ResourceGroup ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[ResourceGroup]'} - } - - def __init__(self, *args, **kwargs): - - super(ResourceGroupPaged, self).__init__(*args, **kwargs) -class TagDetailsPaged(Paged): - """ - A paging container for iterating over a list of :class:`TagDetails ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[TagDetails]'} - } - - def __init__(self, *args, **kwargs): - - super(TagDetailsPaged, self).__init__(*args, **kwargs) -class DeploymentOperationPaged(Paged): - """ - A paging container for iterating over a list of :class:`DeploymentOperation ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[DeploymentOperation]'} - } - - def __init__(self, *args, **kwargs): - - super(DeploymentOperationPaged, self).__init__(*args, **kwargs) 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 9fd73ca1de47..fb982486e0e9 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 @@ -1,30 +1,35 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from enum import Enum - class DeploymentMode(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 + the resource group that are not included in the template are deleted. Be careful when using + Complete mode as you may unintentionally delete resources. + """ incremental = "Incremental" complete = "Complete" - class OnErrorDeploymentType(str, Enum): + """The deployment on error behavior type. Possible values are LastSuccessful and + SpecificDeployment. + """ last_successful = "LastSuccessful" specific_deployment = "SpecificDeployment" - class ResourceIdentityType(str, Enum): + """The identity type. + """ system_assigned = "SystemAssigned" user_assigned = "UserAssigned" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/operations/__init__.py index 41027cf11028..a6f5fa20e792 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/operations/__init__.py @@ -1,12 +1,9 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from ._operations import Operations @@ -15,7 +12,7 @@ from ._resources_operations import ResourcesOperations from ._resource_groups_operations import ResourceGroupsOperations from ._tags_operations import TagsOperations -from ._deployment_operations import DeploymentOperations +from ._deployment_operations_operations import DeploymentOperationsOperations __all__ = [ 'Operations', @@ -24,5 +21,5 @@ 'ResourcesOperations', 'ResourceGroupsOperations', 'TagsOperations', - 'DeploymentOperations', + 'DeploymentOperationsOperations', ] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/operations/_deployment_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/operations/_deployment_operations.py deleted file mode 100644 index c98d21dca9ea..000000000000 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/operations/_deployment_operations.py +++ /dev/null @@ -1,457 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError - -from .. import models - - -class DeploymentOperations(object): - """DeploymentOperations operations. - - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. - - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for this operation. Constant value: "2019-05-10". - """ - - models = models - - def __init__(self, client, config, serializer, deserializer): - - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self.api_version = "2019-05-10" - - self.config = config - - def get_at_management_group_scope( - self, group_id, deployment_name, operation_id, custom_headers=None, raw=False, **operation_config): - """Gets a deployments operation. - - :param group_id: The management group ID. - :type group_id: str - :param deployment_name: The name of the deployment. - :type deployment_name: str - :param operation_id: The ID of the operation to get. - :type operation_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentOperation or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentOperation - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` - """ - # Construct URL - url = self.get_at_management_group_scope.metadata['url'] - 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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) - - if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentOperation', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - - return deserialized - get_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} - - def list_at_management_group_scope( - self, group_id, deployment_name, top=None, custom_headers=None, raw=False, **operation_config): - """Gets all deployments operations for a deployment. - - :param group_id: The management group ID. - :type group_id: str - :param deployment_name: The name of the deployment. - :type deployment_name: str - :param top: The number of results to return. - :type top: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of DeploymentOperation - :rtype: - ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentOperationPaged[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentOperation] - :raises: :class:`CloudError` - """ - def prepare_request(next_link=None): - if not next_link: - # Construct URL - url = self.list_at_management_group_scope.metadata['url'] - 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 = {} - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - else: - url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) - return request - - def internal_paging(next_link=None): - request = prepare_request(next_link) - - response = self._client.send(request, stream=False, **operation_config) - - if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response - - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.DeploymentOperationPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} - - def get_at_subscription_scope( - self, deployment_name, operation_id, custom_headers=None, raw=False, **operation_config): - """Gets a deployments operation. - - :param deployment_name: The name of the deployment. - :type deployment_name: str - :param operation_id: The ID of the operation to get. - :type operation_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentOperation or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentOperation - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` - """ - # Construct URL - url = self.get_at_subscription_scope.metadata['url'] - 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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) - - if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentOperation', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - - return deserialized - get_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} - - def list_at_subscription_scope( - self, deployment_name, top=None, custom_headers=None, raw=False, **operation_config): - """Gets all deployments operations for a deployment. - - :param deployment_name: The name of the deployment. - :type deployment_name: str - :param top: The number of results to return. - :type top: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of DeploymentOperation - :rtype: - ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentOperationPaged[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentOperation] - :raises: :class:`CloudError` - """ - def prepare_request(next_link=None): - if not next_link: - # Construct URL - url = self.list_at_subscription_scope.metadata['url'] - 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 = {} - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - else: - url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) - return request - - def internal_paging(next_link=None): - request = prepare_request(next_link) - - response = self._client.send(request, stream=False, **operation_config) - - if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response - - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.DeploymentOperationPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} - - def get( - self, resource_group_name, deployment_name, operation_id, custom_headers=None, raw=False, **operation_config): - """Gets a deployments operation. - - :param resource_group_name: The name of the resource group. The name - is case insensitive. - :type resource_group_name: str - :param deployment_name: The name of the deployment. - :type deployment_name: str - :param operation_id: The ID of the operation to get. - :type operation_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentOperation or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentOperation - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` - """ - # Construct URL - url = self.get.metadata['url'] - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, 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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) - - if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentOperation', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}'} - - def list( - self, resource_group_name, deployment_name, top=None, custom_headers=None, raw=False, **operation_config): - """Gets all deployments operations for a deployment. - - :param resource_group_name: The name of the resource group. The name - is case insensitive. - :type resource_group_name: str - :param deployment_name: The name of the deployment. - :type deployment_name: str - :param top: The number of results to return. - :type top: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of DeploymentOperation - :rtype: - ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentOperationPaged[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentOperation] - :raises: :class:`CloudError` - """ - def prepare_request(next_link=None): - if not next_link: - # Construct URL - url = self.list.metadata['url'] - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - else: - url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) - return request - - def internal_paging(next_link=None): - request = prepare_request(next_link) - - response = self._client.send(request, stream=False, **operation_config) - - if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response - - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.DeploymentOperationPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations'} 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 new file mode 100644 index 000000000000..1de5748aa6a2 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/operations/_deployment_operations_operations.py @@ -0,0 +1,450 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class DeploymentOperationsOperations(object): + """DeploymentOperationsOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2019_05_10.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def get_at_management_group_scope( + self, + group_id, # type: str + deployment_name, # type: str + operation_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentOperation" + """Gets a deployments operation. + + :param group_id: The management group ID. + :type group_id: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param operation_id: The ID of the operation to get. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentOperation or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentOperation + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentOperation"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-10" + + # 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'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentOperation', pipeline_response) + + if cls: + 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 + + def list_at_management_group_scope( + self, + group_id, # type: str + deployment_name, # type: str + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.DeploymentOperationsListResult"] + """Gets all deployments operations for a deployment. + + :param group_id: The management group ID. + :type group_id: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-10" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentOperationsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + 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 + + def get_at_subscription_scope( + self, + deployment_name, # type: str + operation_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentOperation" + """Gets a deployments operation. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param operation_id: The ID of the operation to get. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentOperation or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentOperation + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentOperation"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-10" + + # 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'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentOperation', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + def list_at_subscription_scope( + self, + deployment_name, # type: str + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.DeploymentOperationsListResult"] + """Gets all deployments operations for a deployment. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-10" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentOperationsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + 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 + + def get( + self, + resource_group_name, # type: str + deployment_name, # type: str + operation_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentOperation" + """Gets a deployments operation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param operation_id: The ID of the operation to get. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentOperation or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentOperation + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentOperation"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-10" + + # Construct URL + url = self.get.metadata['url'] # type: 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'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentOperation', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + def list( + self, + resource_group_name, # type: str + deployment_name, # type: str + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.DeploymentOperationsListResult"] + """Gets all deployments operations for a deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-10" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentOperationsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations'} # type: ignore 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 6c34b0ad2e0f..d7c1fc0a0a59 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 @@ -1,1858 +1,1821 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError -from msrest.polling import LROPoller, NoPolling -from msrestazure.polling.arm_polling import ARMPolling +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class DeploymentsOperations(object): """DeploymentsOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2019_05_10.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for this operation. Constant value: "2019-05-10". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-05-10" - - self.config = config - + self._config = config def _delete_at_management_group_scope_initial( - self, group_id, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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.metadata['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\._\(\)]+$') + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [202, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - - def delete_at_management_group_scope( - self, group_id, deployment_name, custom_headers=None, raw=False, polling=True, **operation_config): - """Deletes a deployment from the deployment history. - - A template deployment that is currently running cannot be deleted. - Deleting a template deployment removes the associated deployment - operations. This is an asynchronous operation that returns a status of - 202 until the template deployment is successfully deleted. The Location - response header contains the URI that is used to obtain the status of - the process. While the process is running, a call to the URI in the - Location header returns a status of 202. When the process finishes, the - URI in the Location header returns a status of 204 on success. If the - asynchronous request failed, the URI in the Location header returns an - error-level status code. + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_at_management_group_scope_initial.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + def begin_delete_at_management_group_scope( + self, + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """A template deployment that is currently running cannot be deleted. Deleting a template deployment removes the associated deployment operations. This is an asynchronous operation that returns a status of 202 until the template deployment is successfully deleted. The Location response header contains the URI that is used to obtain the status of the process. While the process is running, a call to the URI in the Location header returns a status of 202. When the process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. + + Deletes a deployment from the deployment history. :param group_id: The management group ID. :type group_id: str :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns None or - ClientRawResponse if raw==True - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._delete_at_management_group_scope_initial( group_id=group_id, deployment_name=deployment_name, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - delete_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} + begin_delete_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore def check_existence_at_management_group_scope( - self, group_id, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Checks whether the deployment exists. :param group_id: The management group ID. :type group_id: str :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: bool or ClientRawResponse if raw=true - :rtype: bool or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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'] + 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\._\(\)]+$') + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204, 404]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = (response.status_code == 204) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - return deserialized - check_existence_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + if cls: + return cls(pipeline_response, None, {}) + + 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, deployment_name, properties, location=None, custom_headers=None, raw=False, **operation_config): - parameters = models.Deployment(location=location, properties=properties) + self, + group_id, # type: str + deployment_name, # type: str + properties, # type: "models.DeploymentProperties" + location=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentExtended" + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.Deployment(location=location, properties=properties) + api_version = "2019-05-10" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.create_or_update_at_management_group_scope.metadata['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\._\(\)]+$') + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'Deployment') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 201]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', response) + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', response) + deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + 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 - def create_or_update_at_management_group_scope( - self, group_id, deployment_name, properties, location=None, custom_headers=None, raw=False, polling=True, **operation_config): - """Deploys resources at management group scope. + def begin_create_or_update_at_management_group_scope( + self, + group_id, # type: str + deployment_name, # type: str + properties, # type: "models.DeploymentProperties" + location=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """You can provide the template and parameters directly in the request or link to JSON files. - You can provide the template and parameters directly in the request or - link to JSON files. + Deploys resources at management group scope. :param group_id: The management group ID. :type group_id: str :param deployment_name: The name of the deployment. :type deployment_name: str :param properties: The deployment properties. - :type properties: - ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentProperties + :type properties: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentProperties :param location: The location to store the deployment data. :type location: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns DeploymentExtended or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentExtended] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentExtended]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 DeploymentExtended + :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] + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._create_or_update_at_management_group_scope_initial( group_id=group_id, deployment_name=deployment_name, properties=properties, location=location, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - deserialized = self._deserialize('DeploymentExtended', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - create_or_update_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} + begin_create_or_update_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore def get_at_management_group_scope( - self, group_id, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentExtended" """Gets a deployment. :param group_id: The management group ID. :type group_id: str :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentExtended or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentExtended - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExtended or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentExtended + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-10" + # Construct URL - url = self.get_at_management_group_scope.metadata['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\._\(\)]+$') + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', response) + deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} + get_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore def cancel_at_management_group_scope( - self, group_id, deployment_name, custom_headers=None, raw=False, **operation_config): - """Cancels a currently running template deployment. + self, + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """You can cancel a deployment only if the provisioningState is Accepted or Running. After the deployment is canceled, the provisioningState is set to Canceled. Canceling a template deployment stops the currently running template deployment and leaves the resources partially deployed. - You can cancel a deployment only if the provisioningState is Accepted - or Running. After the deployment is canceled, the provisioningState is - set to Canceled. Canceling a template deployment stops the currently - running template deployment and leaves the resources partially - deployed. + Cancels a currently running template deployment. :param group_id: The management group ID. :type group_id: str :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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'] + 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\._\(\)]+$') + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - cancel_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} + if cls: + return cls(pipeline_response, None, {}) + + 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( - self, group_id, deployment_name, properties, location=None, custom_headers=None, raw=False, **operation_config): - """Validates whether the specified template is syntactically correct and - will be accepted by Azure Resource Manager.. + self, + group_id, # type: str + deployment_name, # type: str + properties, # type: "models.DeploymentProperties" + location=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentValidateResult" + """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. :param group_id: The management group ID. :type group_id: str :param deployment_name: The name of the deployment. :type deployment_name: str :param properties: The deployment properties. - :type properties: - ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentProperties + :type properties: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentProperties :param location: The location to store the deployment data. :type location: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentValidateResult or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentValidateResult - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentValidateResult + :raises: ~azure.core.exceptions.HttpResponseError """ - parameters = models.Deployment(location=location, properties=properties) + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentValidateResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.Deployment(location=location, properties=properties) + api_version = "2019-05-10" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.validate_at_management_group_scope.metadata['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\._\(\)]+$') + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'Deployment') # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 400]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', response) + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', response) + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + 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'} + validate_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore def export_template_at_management_group_scope( - self, group_id, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentExportResult" """Exports the template used for specified deployment. :param group_id: The management group ID. :type group_id: str :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentExportResult or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentExportResult - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentExportResult + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExportResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-10" + # Construct URL - url = self.export_template_at_management_group_scope.metadata['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\._\(\)]+$') + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentExportResult', response) + deserialized = self._deserialize('DeploymentExportResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + 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'} + export_template_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore def list_at_management_group_scope( - self, group_id, filter=None, top=None, custom_headers=None, raw=False, **operation_config): + self, + group_id, # type: str + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.DeploymentListResult"] """Get all the deployments for a management group. :param group_id: The management group ID. :type group_id: str - :param filter: The filter to apply on the operation. For example, you - can use $filter=provisioningState eq '{state}'. + :param filter: The filter to apply on the operation. For example, you can use + $filter=provisioningState eq '{state}'. :type filter: str - :param top: The number of results to get. If null is passed, returns - all deployments. + :param top: The number of results to get. If null is passed, returns all deployments. :type top: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of DeploymentExtended - :rtype: - ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentExtendedPaged[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentExtended] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-10" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_at_management_group_scope.metadata['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) + '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 = {} + 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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response - - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.DeploymentExtendedPaged(internal_paging, self._deserialize.dependencies, header_dict) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return deserialized - list_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/'} + 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/'} # type: ignore def _delete_at_subscription_scope_initial( - self, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-10" + # Construct URL - url = self.delete_at_subscription_scope.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [202, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - - def delete_at_subscription_scope( - self, deployment_name, custom_headers=None, raw=False, polling=True, **operation_config): - """Deletes a deployment from the deployment history. - - A template deployment that is currently running cannot be deleted. - Deleting a template deployment removes the associated deployment - operations. This is an asynchronous operation that returns a status of - 202 until the template deployment is successfully deleted. The Location - response header contains the URI that is used to obtain the status of - the process. While the process is running, a call to the URI in the - Location header returns a status of 202. When the process finishes, the - URI in the Location header returns a status of 204 on success. If the - asynchronous request failed, the URI in the Location header returns an - error-level status code. + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + def begin_delete_at_subscription_scope( + self, + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """A template deployment that is currently running cannot be deleted. Deleting a template deployment removes the associated deployment operations. This is an asynchronous operation that returns a status of 202 until the template deployment is successfully deleted. The Location response header contains the URI that is used to obtain the status of the process. While the process is running, a call to the URI in the Location header returns a status of 202. When the process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. + + Deletes a deployment from the deployment history. :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns None or - ClientRawResponse if raw==True - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._delete_at_subscription_scope_initial( deployment_name=deployment_name, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - delete_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} + begin_delete_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore def check_existence_at_subscription_scope( - self, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Checks whether the deployment exists. :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: bool or ClientRawResponse if raw=true - :rtype: bool or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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'] + 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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204, 404]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = (response.status_code == 204) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - return deserialized - check_existence_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + if cls: + return cls(pipeline_response, None, {}) + + 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, properties, location=None, custom_headers=None, raw=False, **operation_config): - parameters = models.Deployment(location=location, properties=properties) + self, + deployment_name, # type: str + properties, # type: "models.DeploymentProperties" + location=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentExtended" + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.Deployment(location=location, properties=properties) + api_version = "2019-05-10" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.create_or_update_at_subscription_scope.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'Deployment') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 201]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', response) + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', response) + deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + 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 - def create_or_update_at_subscription_scope( - self, deployment_name, properties, location=None, custom_headers=None, raw=False, polling=True, **operation_config): - """Deploys resources at subscription scope. + def begin_create_or_update_at_subscription_scope( + self, + deployment_name, # type: str + properties, # type: "models.DeploymentProperties" + location=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """You can provide the template and parameters directly in the request or link to JSON files. - You can provide the template and parameters directly in the request or - link to JSON files. + Deploys resources at subscription scope. :param deployment_name: The name of the deployment. :type deployment_name: str :param properties: The deployment properties. - :type properties: - ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentProperties + :type properties: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentProperties :param location: The location to store the deployment data. :type location: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns DeploymentExtended or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentExtended] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentExtended]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 DeploymentExtended + :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] + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._create_or_update_at_subscription_scope_initial( deployment_name=deployment_name, properties=properties, location=location, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - deserialized = self._deserialize('DeploymentExtended', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - create_or_update_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} + begin_create_or_update_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore def get_at_subscription_scope( - self, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentExtended" """Gets a deployment. :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentExtended or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentExtended - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExtended or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentExtended + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-10" + # Construct URL - url = self.get_at_subscription_scope.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', response) + deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} + get_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore def cancel_at_subscription_scope( - self, deployment_name, custom_headers=None, raw=False, **operation_config): - """Cancels a currently running template deployment. + self, + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """You can cancel a deployment only if the provisioningState is Accepted or Running. After the deployment is canceled, the provisioningState is set to Canceled. Canceling a template deployment stops the currently running template deployment and leaves the resources partially deployed. - You can cancel a deployment only if the provisioningState is Accepted - or Running. After the deployment is canceled, the provisioningState is - set to Canceled. Canceling a template deployment stops the currently - running template deployment and leaves the resources partially - deployed. + Cancels a currently running template deployment. :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {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'] + 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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - cancel_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} + if cls: + return cls(pipeline_response, None, {}) + + cancel_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore def validate_at_subscription_scope( - self, deployment_name, properties, location=None, custom_headers=None, raw=False, **operation_config): - """Validates whether the specified template is syntactically correct and - will be accepted by Azure Resource Manager.. + self, + deployment_name, # type: str + properties, # type: "models.DeploymentProperties" + location=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentValidateResult" + """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. :param deployment_name: The name of the deployment. :type deployment_name: str :param properties: The deployment properties. - :type properties: - ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentProperties + :type properties: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentProperties :param location: The location to store the deployment data. :type location: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentValidateResult or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentValidateResult - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentValidateResult + :raises: ~azure.core.exceptions.HttpResponseError """ - parameters = models.Deployment(location=location, properties=properties) + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentValidateResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.Deployment(location=location, properties=properties) + api_version = "2019-05-10" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.validate_at_subscription_scope.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'Deployment') # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 400]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', response) + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', response) + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - validate_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} + validate_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore def export_template_at_subscription_scope( - self, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentExportResult" """Exports the template used for specified deployment. :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentExportResult or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentExportResult - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentExportResult + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExportResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-10" + # Construct URL - url = self.export_template_at_subscription_scope.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentExportResult', response) + deserialized = self._deserialize('DeploymentExportResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - export_template_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} + export_template_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore def list_at_subscription_scope( - self, filter=None, top=None, custom_headers=None, raw=False, **operation_config): + self, + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.DeploymentListResult"] """Get all the deployments for a subscription. - :param filter: The filter to apply on the operation. For example, you - can use $filter=provisioningState eq '{state}'. + :param filter: The filter to apply on the operation. For example, you can use + $filter=provisioningState eq '{state}'. :type filter: str - :param top: The number of results to get. If null is passed, returns - all deployments. + :param top: The number of results to get. If null is passed, returns all deployments. :type top: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of DeploymentExtended - :rtype: - ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentExtendedPaged[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentExtended] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-10" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_at_subscription_scope.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response - - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.DeploymentExtendedPaged(internal_paging, self._deserialize.dependencies, header_dict) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return deserialized - list_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/'} + return pipeline_response + return ItemPaged( + get_next, extract_data + ) + list_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/'} # type: ignore def _delete_initial( - self, resource_group_name, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-10" + # Construct URL - url = self.delete.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [202, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - - def delete( - self, resource_group_name, deployment_name, custom_headers=None, raw=False, polling=True, **operation_config): - """Deletes a deployment from the deployment history. - - A template deployment that is currently running cannot be deleted. - Deleting a template deployment removes the associated deployment - operations. Deleting a template deployment does not affect the state of - the resource group. This is an asynchronous operation that returns a - status of 202 until the template deployment is successfully deleted. - The Location response header contains the URI that is used to obtain - the status of the process. While the process is running, a call to the - URI in the Location header returns a status of 202. When the process - finishes, the URI in the Location header returns a status of 204 on - success. If the asynchronous request failed, the URI in the Location - header returns an error-level status code. - - :param resource_group_name: The name of the resource group with the - deployment to delete. The name is case insensitive. + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + def begin_delete( + self, + resource_group_name, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """A template deployment that is currently running cannot be deleted. Deleting a template deployment removes the associated deployment operations. Deleting a template deployment does not affect the state of the resource group. This is an asynchronous operation that returns a status of 202 until the template deployment is successfully deleted. The Location response header contains the URI that is used to obtain the status of the process. While the process is running, a call to the URI in the Location header returns a status of 202. When the process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. + + Deletes a deployment from the deployment history. + + :param resource_group_name: The name of the resource group with the deployment to delete. The + name is case insensitive. :type resource_group_name: str :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns None or - ClientRawResponse if raw==True - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._delete_initial( resource_group_name=resource_group_name, deployment_name=deployment_name, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore def check_existence( - self, resource_group_name, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Checks whether the deployment exists. - :param resource_group_name: The name of the resource group with the - deployment to check. The name is case insensitive. + :param resource_group_name: The name of the resource group with the deployment to check. The + name is case insensitive. :type resource_group_name: str :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: bool or ClientRawResponse if raw=true - :rtype: bool or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-10" + # Construct URL - url = self.check_existence.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204, 404]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = (response.status_code == 204) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - return deserialized - check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + 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, deployment_name, properties, location=None, custom_headers=None, raw=False, **operation_config): - parameters = models.Deployment(location=location, properties=properties) + self, + resource_group_name, # type: str + deployment_name, # type: str + properties, # type: "models.DeploymentProperties" + location=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentExtended" + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.Deployment(location=location, properties=properties) + api_version = "2019-05-10" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.create_or_update.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'Deployment') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 201]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', response) + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', response) + deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - - def create_or_update( - self, resource_group_name, deployment_name, properties, location=None, custom_headers=None, raw=False, polling=True, **operation_config): - """Deploys resources to a resource group. - - You can provide the template and parameters directly in the request or - link to JSON files. - - :param resource_group_name: The name of the resource group to deploy - the resources to. The name is case insensitive. The resource group - must already exist. + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + def begin_create_or_update( + self, + resource_group_name, # type: str + deployment_name, # type: str + properties, # type: "models.DeploymentProperties" + location=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """You can provide the template and parameters directly in the request or link to JSON files. + + Deploys resources to a resource group. + + :param resource_group_name: The name of the resource group to deploy the resources to. The name + is case insensitive. The resource group must already exist. :type resource_group_name: str :param deployment_name: The name of the deployment. :type deployment_name: str :param properties: The deployment properties. - :type properties: - ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentProperties + :type properties: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentProperties :param location: The location to store the deployment data. :type location: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns DeploymentExtended or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentExtended] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentExtended]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 DeploymentExtended + :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] + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._create_or_update_initial( resource_group_name=resource_group_name, deployment_name=deployment_name, properties=properties, location=location, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - deserialized = self._deserialize('DeploymentExtended', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore def get( - self, resource_group_name, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentExtended" """Gets a deployment. - :param resource_group_name: The name of the resource group. The name - is case insensitive. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentExtended or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentExtended - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExtended or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentExtended + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-10" + # Construct URL - url = self.get.metadata['url'] + url = self.get.metadata['url'] # type: 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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', response) + deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore def cancel( - self, resource_group_name, deployment_name, custom_headers=None, raw=False, **operation_config): - """Cancels a currently running template deployment. + self, + resource_group_name, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """You can cancel a deployment only if the provisioningState is Accepted or Running. After the deployment is canceled, the provisioningState is set to Canceled. Canceling a template deployment stops the currently running template deployment and leaves the resource group partially deployed. - You can cancel a deployment only if the provisioningState is Accepted - or Running. After the deployment is canceled, the provisioningState is - set to Canceled. Canceling a template deployment stops the currently - running template deployment and leaves the resource group partially - deployed. + Cancels a currently running template deployment. - :param resource_group_name: The name of the resource group. The name - is case insensitive. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-10" + # Construct URL - url = self.cancel.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - cancel.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} + if cls: + return cls(pipeline_response, None, {}) - def validate( - self, resource_group_name, deployment_name, properties, location=None, custom_headers=None, raw=False, **operation_config): - """Validates whether the specified template is syntactically correct and - will be accepted by Azure Resource Manager.. + cancel.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore - :param resource_group_name: The name of the resource group the - template will be deployed to. The name is case insensitive. + def validate( + self, + resource_group_name, # type: str + deployment_name, # type: str + properties, # type: "models.DeploymentProperties" + location=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentValidateResult" + """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. :type resource_group_name: str :param deployment_name: The name of the deployment. :type deployment_name: str :param properties: The deployment properties. - :type properties: - ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentProperties + :type properties: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentProperties :param location: The location to store the deployment data. :type location: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentValidateResult or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentValidateResult - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentValidateResult + :raises: ~azure.core.exceptions.HttpResponseError """ - parameters = models.Deployment(location=location, properties=properties) + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentValidateResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.Deployment(location=location, properties=properties) + api_version = "2019-05-10" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.validate.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'Deployment') # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 400]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', response) + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', response) + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - validate.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} + validate.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore def export_template( - self, resource_group_name, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentExportResult" """Exports the template used for specified deployment. - :param resource_group_name: The name of the resource group. The name - is case insensitive. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentExportResult or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentExportResult - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentExportResult + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExportResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-10" + # Construct URL - url = self.export_template.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentExportResult', response) + deserialized = self._deserialize('DeploymentExportResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} + export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore def list_by_resource_group( - self, resource_group_name, filter=None, top=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.DeploymentListResult"] """Get all the deployments for a resource group. - :param resource_group_name: The name of the resource group with the - deployments to get. The name is case insensitive. + :param resource_group_name: The name of the resource group with the deployments to get. The + name is case insensitive. :type resource_group_name: str - :param filter: The filter to apply on the operation. For example, you - can use $filter=provisioningState eq '{state}'. + :param filter: The filter to apply on the operation. For example, you can use + $filter=provisioningState eq '{state}'. :type filter: str - :param top: The number of results to get. If null is passed, returns - all deployments. + :param top: The number of results to get. If null is passed, returns all deployments. :type top: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of DeploymentExtended - :rtype: - ~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentExtendedPaged[~azure.mgmt.resource.resources.v2019_05_10.models.DeploymentExtended] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-10" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_by_resource_group.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.DeploymentExtendedPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/'} + return ItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/'} # type: ignore def calculate_template_hash( - self, template, custom_headers=None, raw=False, **operation_config): + self, + template, # type: object + **kwargs # type: Any + ): + # type: (...) -> "models.TemplateHashResult" """Calculate the hash of the given template. :param template: The template provided to calculate hash. :type template: object - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: TemplateHashResult or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_05_10.models.TemplateHashResult - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateHashResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.TemplateHashResult + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TemplateHashResult"] + error_map = {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.calculate_template_hash.metadata['url'] + url = self.calculate_template_hash.metadata['url'] # type: ignore # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(template, 'object') # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('TemplateHashResult', response) + deserialized = self._deserialize('TemplateHashResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - calculate_template_hash.metadata = {'url': '/providers/Microsoft.Resources/calculateTemplateHash'} + 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 2841f5e5873b..8f6b71075d8a 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 @@ -1,102 +1,106 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class Operations(object): """Operations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2019_05_10.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for this operation. Constant value: "2019-05-10". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-05-10" - - self.config = config + self._config = config def list( - self, custom_headers=None, raw=False, **operation_config): + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.OperationListResult"] """Lists all of the available Microsoft.Resources REST API operations. - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of Operation - :rtype: - ~azure.mgmt.resource.resources.v2019_05_10.models.OperationPaged[~azure.mgmt.resource.resources.v2019_05_10.models.Operation] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of OperationListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-10" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['url'] - + url = self.list.metadata['url'] # type: ignore # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('OperationListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.OperationPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list.metadata = {'url': '/providers/Microsoft.Resources/operations'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.Resources/operations'} # type: ignore 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 a6dc8fde1b2c..a5dc55bfc9a9 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 @@ -1,437 +1,417 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class ProvidersOperations(object): """ProvidersOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2019_05_10.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for this operation. Constant value: "2019-05-10". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-05-10" - - self.config = config + self._config = config def unregister( - self, resource_provider_namespace, custom_headers=None, raw=False, **operation_config): + self, + resource_provider_namespace, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.Provider" """Unregisters a subscription from a resource provider. - :param resource_provider_namespace: The namespace of the resource - provider to unregister. + :param resource_provider_namespace: The namespace of the resource provider to unregister. :type resource_provider_namespace: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: Provider or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.Provider or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Provider or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.Provider + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Provider"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-10" + # Construct URL - url = self.unregister.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('Provider', response) + deserialized = self._deserialize('Provider', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - unregister.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister'} + unregister.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister'} # type: ignore def register( - self, resource_provider_namespace, custom_headers=None, raw=False, **operation_config): + self, + resource_provider_namespace, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.Provider" """Registers a subscription with a resource provider. - :param resource_provider_namespace: The namespace of the resource - provider to register. + :param resource_provider_namespace: The namespace of the resource provider to register. :type resource_provider_namespace: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: Provider or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.Provider or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Provider or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.Provider + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Provider"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-10" + # Construct URL - url = self.register.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('Provider', response) + deserialized = self._deserialize('Provider', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - register.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register'} + register.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register'} # type: ignore def list( - self, top=None, expand=None, custom_headers=None, raw=False, **operation_config): + self, + top=None, # type: Optional[int] + expand=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.ProviderListResult"] """Gets all resource providers for a subscription. - :param top: The number of results to return. If null is passed returns - all deployments. + :param top: The number of results to return. If null is passed returns all deployments. :type top: int - :param expand: The properties to include in the results. For example, - use &$expand=metadata in the query string to retrieve resource - provider metadata. To include property aliases in response, use - $expand=resourceTypes/aliases. + :param expand: The properties to include in the results. For example, use &$expand=metadata in + the query string to retrieve resource provider metadata. To include property aliases in + response, use $expand=resourceTypes/aliases. :type expand: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of Provider - :rtype: - ~azure.mgmt.resource.resources.v2019_05_10.models.ProviderPaged[~azure.mgmt.resource.resources.v2019_05_10.models.Provider] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of ProviderListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-10" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['url'] + url = self.list.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_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 = {} + 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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('ProviderListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.ProviderPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers'} # type: ignore def list_at_tenant_scope( - self, top=None, expand=None, custom_headers=None, raw=False, **operation_config): + self, + top=None, # type: Optional[int] + expand=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.ProviderListResult"] """Gets all resource providers for the tenant. - :param top: The number of results to return. If null is passed returns - all providers. + :param top: The number of results to return. If null is passed returns all providers. :type top: int - :param expand: The properties to include in the results. For example, - use &$expand=metadata in the query string to retrieve resource - provider metadata. To include property aliases in response, use - $expand=resourceTypes/aliases. + :param expand: The properties to include in the results. For example, use &$expand=metadata in + the query string to retrieve resource provider metadata. To include property aliases in + response, use $expand=resourceTypes/aliases. :type expand: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of Provider - :rtype: - ~azure.mgmt.resource.resources.v2019_05_10.models.ProviderPaged[~azure.mgmt.resource.resources.v2019_05_10.models.Provider] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of ProviderListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-10" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_at_tenant_scope.metadata['url'] - + url = self.list_at_tenant_scope.metadata['url'] # type: ignore # Construct parameters - query_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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('ProviderListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.ProviderPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_at_tenant_scope.metadata = {'url': '/providers'} + return ItemPaged( + get_next, extract_data + ) + list_at_tenant_scope.metadata = {'url': '/providers'} # type: ignore def get( - self, resource_provider_namespace, expand=None, custom_headers=None, raw=False, **operation_config): + self, + resource_provider_namespace, # type: str + expand=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.Provider" """Gets the specified resource provider. - :param resource_provider_namespace: The namespace of the resource - provider. + :param resource_provider_namespace: The namespace of the resource provider. :type resource_provider_namespace: str - :param expand: The $expand query parameter. For example, to include - property aliases in response, use $expand=resourceTypes/aliases. + :param expand: The $expand query parameter. For example, to include property aliases in + response, use $expand=resourceTypes/aliases. :type expand: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: Provider or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.Provider or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Provider or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.Provider + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Provider"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-10" + # Construct URL - url = self.get.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('Provider', response) + deserialized = self._deserialize('Provider', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}'} # type: ignore def get_at_tenant_scope( - self, resource_provider_namespace, expand=None, custom_headers=None, raw=False, **operation_config): + self, + resource_provider_namespace, # type: str + expand=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.Provider" """Gets the specified resource provider at the tenant level. - :param resource_provider_namespace: The namespace of the resource - provider. + :param resource_provider_namespace: The namespace of the resource provider. :type resource_provider_namespace: str - :param expand: The $expand query parameter. For example, to include - property aliases in response, use $expand=resourceTypes/aliases. + :param expand: The $expand query parameter. For example, to include property aliases in + response, use $expand=resourceTypes/aliases. :type expand: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: Provider or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.Provider or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Provider or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.Provider + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Provider"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-10" + # Construct URL - url = self.get_at_tenant_scope.metadata['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') + 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('Provider', response) + deserialized = self._deserialize('Provider', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get_at_tenant_scope.metadata = {'url': '/providers/{resourceProviderNamespace}'} + 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 7190ebc30d33..d533845e5f29 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 @@ -1,530 +1,517 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError -from msrest.polling import LROPoller, NoPolling -from msrestazure.polling.arm_polling import ARMPolling +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, List, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class ResourceGroupsOperations(object): """ResourceGroupsOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2019_05_10.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for this operation. Constant value: "2019-05-10". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-05-10" - - self.config = config + self._config = config def check_existence( - self, resource_group_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Checks whether a resource group exists. - :param resource_group_name: The name of the resource group to check. - The name is case insensitive. + :param resource_group_name: The name of the resource group to check. The name is case + insensitive. :type resource_group_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: bool or ClientRawResponse if raw=true - :rtype: bool or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-10" + # Construct URL - url = self.check_existence.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204, 404]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = (response.status_code == 204) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - return deserialized - check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore def create_or_update( - self, resource_group_name, parameters, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + parameters, # type: "models.ResourceGroup" + **kwargs # type: Any + ): + # type: (...) -> "models.ResourceGroup" """Creates or updates a resource group. - :param resource_group_name: The name of the resource group to create - or update. Can include alphanumeric, underscore, parentheses, hyphen, - period (except at end), and Unicode characters that match the allowed - characters. + :param resource_group_name: The name of the resource group to create or update. Can include + alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters + that match the allowed characters. :type resource_group_name: str - :param parameters: Parameters supplied to the create or update a - resource group. - :type parameters: - ~azure.mgmt.resource.resources.v2019_05_10.models.ResourceGroup - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: ResourceGroup or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_05_10.models.ResourceGroup or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :param parameters: Parameters supplied to the create or update a resource group. + :type parameters: ~azure.mgmt.resource.resources.v2019_05_10.models.ResourceGroup + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.ResourceGroup + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceGroup"] + error_map = {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.create_or_update.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'ResourceGroup') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 201]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ResourceGroup', response) + deserialized = self._deserialize('ResourceGroup', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('ResourceGroup', response) + deserialized = self._deserialize('ResourceGroup', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} - + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore def _delete_initial( - self, resource_group_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-10" + # Construct URL - url = self.delete.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 202]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore - def delete( - self, resource_group_name, custom_headers=None, raw=False, polling=True, **operation_config): - """Deletes a resource group. + def begin_delete( + self, + resource_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """When you delete a resource group, all of its resources are also deleted. Deleting a resource group deletes all of its template deployments and currently stored operations. - When you delete a resource group, all of its resources are also - deleted. Deleting a resource group deletes all of its template - deployments and currently stored operations. + Deletes a resource group. - :param resource_group_name: The name of the resource group to delete. - The name is case insensitive. + :param resource_group_name: The name of the resource group to delete. The name is case + insensitive. :type resource_group_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns None or - ClientRawResponse if raw==True - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._delete_initial( resource_group_name=resource_group_name, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore def get( - self, resource_group_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.ResourceGroup" """Gets a resource group. - :param resource_group_name: The name of the resource group to get. The - name is case insensitive. + :param resource_group_name: The name of the resource group to get. The name is case + insensitive. :type resource_group_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: ResourceGroup or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_05_10.models.ResourceGroup or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.ResourceGroup + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceGroup"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-10" + # Construct URL - url = self.get.metadata['url'] + url = self.get.metadata['url'] # type: 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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('ResourceGroup', response) + deserialized = self._deserialize('ResourceGroup', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore def update( - self, resource_group_name, parameters, custom_headers=None, raw=False, **operation_config): - """Updates a resource group. - - Resource groups can be updated through a simple PATCH operation to a - group address. The format of the request is the same as that for - creating a resource group. If a field is unspecified, the current value - is retained. - - :param resource_group_name: The name of the resource group to update. - The name is case insensitive. + self, + resource_group_name, # type: str + parameters, # type: "models.ResourceGroupPatchable" + **kwargs # type: Any + ): + # type: (...) -> "models.ResourceGroup" + """Resource groups can be updated through a simple PATCH operation to a group address. The format of the request is the same as that for creating a resource group. If a field is unspecified, the current value is retained. + + Updates a resource group. + + :param resource_group_name: The name of the resource group to update. The name is case + insensitive. :type resource_group_name: str :param parameters: Parameters supplied to update a resource group. - :type parameters: - ~azure.mgmt.resource.resources.v2019_05_10.models.ResourceGroupPatchable - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: ResourceGroup or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_05_10.models.ResourceGroup or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :type parameters: ~azure.mgmt.resource.resources.v2019_05_10.models.ResourceGroupPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.ResourceGroup + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceGroup"] + error_map = {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.update.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'ResourceGroupPatchable') # Construct and send request - request = self._client.patch(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('ResourceGroup', response) + deserialized = self._deserialize('ResourceGroup', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore def export_template( - self, resource_group_name, resources=None, options=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + resources=None, # type: Optional[List[str]] + options=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.ResourceGroupExportResult" """Captures the specified resource group as a template. - :param resource_group_name: The name of the resource group to export - as a template. + :param resource_group_name: The name of the resource group to export as a template. :type resource_group_name: str - :param resources: The IDs of the resources to filter the export by. To - export all resources, supply an array with single entry '*'. + :param 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', - 'SkipResourceNameParameterization', 'SkipAllParameterization' + :param options: The export template options. A CSV-formatted list containing zero or more of + the following: 'IncludeParameterDefaultValue', 'IncludeComments', + 'SkipResourceNameParameterization', 'SkipAllParameterization'. :type options: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: ResourceGroupExportResult or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_05_10.models.ResourceGroupExportResult - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroupExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.ResourceGroupExportResult + :raises: ~azure.core.exceptions.HttpResponseError """ - parameters = models.ExportTemplateRequest(resources=resources, options=options) + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceGroupExportResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.ExportTemplateRequest(resources=resources, options=options) + api_version = "2019-05-10" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.export_template.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'ExportTemplateRequest') # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('ResourceGroupExportResult', response) + deserialized = self._deserialize('ResourceGroupExportResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate'} + export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate'} # type: ignore def list( - self, filter=None, top=None, custom_headers=None, raw=False, **operation_config): + self, + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.ResourceGroupListResult"] """Gets all the resource groups for a subscription. - :param filter: The filter to apply on the operation.

You can - filter by tag names and values. For example, to filter for a tag name - and value, use $filter=tagName eq 'tag1' and tagValue eq 'Value1' + :param filter: The filter to apply on the operation.:code:`
`:code:`
`You can filter by + tag names and values. For example, to filter for a tag name and value, use $filter=tagName eq + 'tag1' and tagValue eq 'Value1'. :type filter: str - :param top: The number of results to return. If null is passed, - returns all resource groups. + :param top: The number of results to return. If null is passed, returns all resource groups. :type top: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of ResourceGroup - :rtype: - ~azure.mgmt.resource.resources.v2019_05_10.models.ResourceGroupPaged[~azure.mgmt.resource.resources.v2019_05_10.models.ResourceGroup] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-10" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['url'] + url = self.list.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_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 = {} + 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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('ResourceGroupListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.ResourceGroupPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups'} # type: ignore 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 ac86f11d499c..298b28cbdde4 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 @@ -1,558 +1,577 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError -from msrest.polling import LROPoller, NoPolling -from msrestazure.polling.arm_polling import ARMPolling +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, List, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class ResourcesOperations(object): """ResourcesOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2019_05_10.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for this operation. Constant value: "2019-05-10". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-05-10" - - self.config = config + self._config = config def list_by_resource_group( - self, resource_group_name, filter=None, expand=None, top=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + filter=None, # type: Optional[str] + expand=None, # type: Optional[str] + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.ResourceListResult"] """Get all the resources for a resource group. - :param resource_group_name: The resource group with the resources to - get. + :param resource_group_name: The resource group with the resources to get. :type resource_group_name: str - :param filter: The filter to apply on the operation.

The - properties you can use for eq (equals) or ne (not equals) are: - location, resourceType, name, resourceGroup, identity, - identity/principalId, plan, plan/publisher, plan/product, plan/name, - plan/version, and plan/promotionCode.

For example, to filter by - a resource type, use: $filter=resourceType eq - 'Microsoft.Network/virtualNetworks'

You can use - substringof(value, property) in the filter. The properties you can use - for substring are: name and resourceGroup.

For example, to get - all resources with 'demo' anywhere in the name, use: - $filter=substringof('demo', name)

You can link more than one - substringof together by adding and/or operators.

You can filter - by tag names and values. For example, to filter for a tag name and - value, use $filter=tagName eq 'tag1' and tagValue eq - 'Value1'

You can use some properties together when filtering. - The combinations you can use are: substringof and/or resourceType, - plan and plan/publisher and plan/name, identity and - identity/principalId. + :param filter: The filter to apply on the operation.:code:`
`:code:`
`The properties you + can use for eq (equals) or ne (not equals) are: location, resourceType, name, resourceGroup, + identity, identity/principalId, plan, plan/publisher, plan/product, plan/name, plan/version, + and plan/promotionCode.:code:`
`:code:`
`For example, to filter by a resource type, use: + $filter=resourceType eq 'Microsoft.Network/virtualNetworks':code:`
`:code:`
`You can use + substringof(value, property) in the filter. The properties you can use for substring are: name + and resourceGroup.:code:`
`:code:`
`For example, to get all resources with 'demo' + anywhere in the name, use: $filter=substringof('demo', name):code:`
`:code:`
`You can + link more than one substringof together by adding and/or operators.:code:`
`:code:`
`You + can filter by tag names and values. For example, to filter for a tag name and value, use + $filter=tagName eq 'tag1' and tagValue eq 'Value1':code:`
`:code:`
`You can use some + properties together when filtering. The combinations you can use are: substringof and/or + resourceType, plan and plan/publisher and plan/name, identity and identity/principalId. :type filter: str - :param expand: Comma-separated list of additional properties to be - included in the response. Valid values include `createdTime`, - `changedTime` and `provisioningState`. For example, - `$expand=createdTime,changedTime`. + :param expand: Comma-separated list of additional properties to be included in the response. + Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, + ``$expand=createdTime,changedTime``. :type expand: str - :param top: The 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 - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of GenericResourceExpanded - :rtype: - ~azure.mgmt.resource.resources.v2019_05_10.models.GenericResourceExpandedPaged[~azure.mgmt.resource.resources.v2019_05_10.models.GenericResourceExpanded] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of ResourceListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-10" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_by_resource_group.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('ResourceListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response - - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.GenericResourceExpandedPaged(internal_paging, self._deserialize.dependencies, header_dict) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return deserialized - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources'} + return pipeline_response + return ItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources'} # type: ignore def _move_resources_initial( - self, source_resource_group_name, resources=None, target_resource_group=None, custom_headers=None, raw=False, **operation_config): - parameters = models.ResourcesMoveInfo(resources=resources, target_resource_group=target_resource_group) + self, + source_resource_group_name, # type: str + resources=None, # type: Optional[List[str]] + target_resource_group=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.ResourcesMoveInfo(resources=resources, target_resource_group=target_resource_group) + api_version = "2019-05-10" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.move_resources.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'ResourcesMoveInfo') + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [202, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - - def move_resources( - self, source_resource_group_name, resources=None, target_resource_group=None, custom_headers=None, raw=False, polling=True, **operation_config): - """Moves resources from one resource group to another resource group. - - The resources to move must be in the same source resource group. The - target resource group may be in a different subscription. When moving - resources, both the source group and the target group are locked for - the duration of the operation. Write and delete operations are blocked - on the groups until the move completes. . - - :param source_resource_group_name: The name of the resource group - containing the resources to move. + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore + + def begin_move_resources( + self, + source_resource_group_name, # type: str + resources=None, # type: Optional[List[str]] + target_resource_group=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """The resources to move must be in the same source resource group. The target resource group may be in a different subscription. When moving resources, both the source group and the target group are locked for the duration of the operation. Write and delete operations are blocked on the groups until the move completes. + + Moves resources from one resource group to another resource group. + + :param source_resource_group_name: The name of the resource group containing the resources to + move. :type source_resource_group_name: str :param resources: The IDs of the resources. :type resources: list[str] :param target_resource_group: The target resource group. :type target_resource_group: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns None or - ClientRawResponse if raw==True - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._move_resources_initial( source_resource_group_name=source_resource_group_name, resources=resources, target_resource_group=target_resource_group, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} - + begin_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore def _validate_move_resources_initial( - self, source_resource_group_name, resources=None, target_resource_group=None, custom_headers=None, raw=False, **operation_config): - parameters = models.ResourcesMoveInfo(resources=resources, target_resource_group=target_resource_group) + self, + source_resource_group_name, # type: str + resources=None, # type: Optional[List[str]] + target_resource_group=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.ResourcesMoveInfo(resources=resources, target_resource_group=target_resource_group) + api_version = "2019-05-10" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.validate_move_resources.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'ResourcesMoveInfo') + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [202, 204, 409]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - - def validate_move_resources( - self, source_resource_group_name, resources=None, target_resource_group=None, custom_headers=None, raw=False, polling=True, **operation_config): - """Validates whether resources can be moved from one resource group to - another resource group. - - This operation checks whether the specified resources can be moved to - the target. The resources to move must be in the same source resource - group. The target resource group may be in a different subscription. If - validation succeeds, it returns HTTP response code 204 (no content). If - validation fails, it returns HTTP response code 409 (Conflict) with an - error message. Retrieve the URL in the Location header value to check - the result of the long-running operation. - - :param source_resource_group_name: The name of the resource group - containing the resources to validate for move. + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _validate_move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} # type: ignore + + def begin_validate_move_resources( + self, + source_resource_group_name, # type: str + resources=None, # type: Optional[List[str]] + target_resource_group=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """This operation checks whether the specified resources can be moved to the target. The resources to move must be in the same source resource group. The target resource group may be in a different subscription. If validation succeeds, it returns HTTP response code 204 (no content). If validation fails, it returns HTTP response code 409 (Conflict) with an error message. Retrieve the URL in the Location header value to check the result of the long-running operation. + + Validates whether resources can be moved from one resource group to another resource group. + + :param source_resource_group_name: The name of the resource group containing the resources to + validate for move. :type source_resource_group_name: str :param resources: The IDs of the resources. :type resources: list[str] :param target_resource_group: The target resource group. :type target_resource_group: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns None or - ClientRawResponse if raw==True - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._validate_move_resources_initial( source_resource_group_name=source_resource_group_name, resources=resources, target_resource_group=target_resource_group, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - validate_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} + begin_validate_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} # type: ignore def list( - self, filter=None, expand=None, top=None, custom_headers=None, raw=False, **operation_config): + self, + filter=None, # type: Optional[str] + expand=None, # type: Optional[str] + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.ResourceListResult"] """Get all the resources in a subscription. - :param filter: The filter to apply on the operation.

The - properties you can use for eq (equals) or ne (not equals) are: - location, resourceType, name, resourceGroup, identity, - identity/principalId, plan, plan/publisher, plan/product, plan/name, - plan/version, and plan/promotionCode.

For example, to filter by - a resource type, use: $filter=resourceType eq - 'Microsoft.Network/virtualNetworks'

You can use - substringof(value, property) in the filter. The properties you can use - for substring are: name and resourceGroup.

For example, to get - all resources with 'demo' anywhere in the name, use: - $filter=substringof('demo', name)

You can link more than one - substringof together by adding and/or operators.

You can filter - by tag names and values. For example, to filter for a tag name and - value, use $filter=tagName eq 'tag1' and tagValue eq - 'Value1'

You can use some properties together when filtering. - The combinations you can use are: substringof and/or resourceType, - plan and plan/publisher and plan/name, identity and - identity/principalId. + :param filter: The filter to apply on the operation.:code:`
`:code:`
`The properties you + can use for eq (equals) or ne (not equals) are: location, resourceType, name, resourceGroup, + identity, identity/principalId, plan, plan/publisher, plan/product, plan/name, plan/version, + and plan/promotionCode.:code:`
`:code:`
`For example, to filter by a resource type, use: + $filter=resourceType eq 'Microsoft.Network/virtualNetworks':code:`
`:code:`
`You can use + substringof(value, property) in the filter. The properties you can use for substring are: name + and resourceGroup.:code:`
`:code:`
`For example, to get all resources with 'demo' + anywhere in the name, use: $filter=substringof('demo', name):code:`
`:code:`
`You can + link more than one substringof together by adding and/or operators.:code:`
`:code:`
`You + can filter by tag names and values. For example, to filter for a tag name and value, use + $filter=tagName eq 'tag1' and tagValue eq 'Value1':code:`
`:code:`
`You can use some + properties together when filtering. The combinations you can use are: substringof and/or + resourceType, plan and plan/publisher and plan/name, identity and identity/principalId. :type filter: str - :param expand: Comma-separated list of additional properties to be - included in the response. Valid values include `createdTime`, - `changedTime` and `provisioningState`. For example, - `$expand=createdTime,changedTime`. + :param expand: Comma-separated list of additional properties to be included in the response. + Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, + ``$expand=createdTime,changedTime``. :type expand: str - :param top: The number of results to return. If null is passed, - returns all resource groups. + :param top: The number of results to return. If null is passed, returns all resource groups. :type top: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of GenericResourceExpanded - :rtype: - ~azure.mgmt.resource.resources.v2019_05_10.models.GenericResourceExpandedPaged[~azure.mgmt.resource.resources.v2019_05_10.models.GenericResourceExpanded] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of ResourceListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-10" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['url'] + url = self.list.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_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 = {} + 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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('ResourceListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.GenericResourceExpandedPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resources'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resources'} # type: ignore def check_existence( - self, resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, api_version, custom_headers=None, raw=False, **operation_config): + self, + 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: (...) -> None """Checks whether a resource exists. - :param resource_group_name: The name of the resource group containing - the resource to check. The name is case insensitive. + :param resource_group_name: The name of the resource group containing the resource to check. + The name is case insensitive. :type resource_group_name: str - :param resource_provider_namespace: The resource provider of the - resource to check. + :param resource_provider_namespace: The resource provider of the resource to check. :type resource_provider_namespace: str :param parent_resource_path: The parent resource identity. :type parent_resource_path: str :param resource_type: The resource type. :type resource_type: str - :param resource_name: The name of the resource to check whether it - exists. + :param resource_name: The name of the resource to check whether it exists. :type resource_name: str - :param api_version: The API version to use for the operation. - :type api_version: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: bool or ClientRawResponse if raw=true - :rtype: bool or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-10" + # Construct URL - url = self.check_existence.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204, 404]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = (response.status_code == 204) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - return deserialized - check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + 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, resource_provider_namespace, parent_resource_path, resource_type, resource_name, api_version, custom_headers=None, raw=False, **operation_config): + self, + 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: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-10" + # Construct URL - url = self.delete.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - - def delete( - self, resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, api_version, custom_headers=None, raw=False, polling=True, **operation_config): + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + def begin_delete( + self, + 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: (...) -> LROPoller """Deletes a resource. - :param resource_group_name: The name of the resource group that - contains the resource to delete. The name is case insensitive. + :param resource_group_name: The name of the resource group that contains the resource to + delete. The name is case insensitive. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource - provider. + :param resource_provider_namespace: The namespace of the resource provider. :type resource_provider_namespace: str :param parent_resource_path: The parent resource identity. :type parent_resource_path: str @@ -560,109 +579,122 @@ def delete( :type resource_type: str :param resource_name: The name of the resource to delete. :type resource_name: str - :param api_version: The API version to use for the operation. - :type api_version: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns None or - ClientRawResponse if raw==True - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._delete_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, - api_version=api_version, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} - + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore def _create_or_update_initial( - self, resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, api_version, parameters, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + parameters, # type: "models.GenericResource" + **kwargs # type: Any + ): + # type: (...) -> "models.GenericResource" + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {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.create_or_update.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'GenericResource') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 201, 202]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('GenericResource', response) + deserialized = self._deserialize('GenericResource', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('GenericResource', response) + deserialized = self._deserialize('GenericResource', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - - def create_or_update( - self, resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, api_version, parameters, custom_headers=None, raw=False, polling=True, **operation_config): + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + def begin_create_or_update( + self, + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + parameters, # type: "models.GenericResource" + **kwargs # type: Any + ): + # type: (...) -> LROPoller """Creates a resource. - :param resource_group_name: The name of the resource group for the - resource. The name is case insensitive. + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource - provider. + :param resource_provider_namespace: The namespace of the resource provider. :type resource_provider_namespace: str :param parent_resource_path: The parent resource identity. :type parent_resource_path: str @@ -670,117 +702,125 @@ def create_or_update( :type resource_type: str :param resource_name: The name of the resource to create. :type resource_name: str - :param api_version: The API version to use for the operation. - :type api_version: str :param parameters: Parameters for creating or updating the resource. - :type parameters: - ~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :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 polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns GenericResource or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 GenericResource + :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] + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._create_or_update_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, - api_version=api_version, parameters=parameters, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - deserialized = self._deserialize('GenericResource', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('GenericResource', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} - + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore def _update_initial( - self, resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, api_version, parameters, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + parameters, # type: "models.GenericResource" + **kwargs # type: Any + ): + # type: (...) -> "models.GenericResource" + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {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.update.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'GenericResource') # Construct and send request - request = self._client.patch(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 202]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('GenericResource', response) + deserialized = self._deserialize('GenericResource', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - - def update( - self, resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, api_version, parameters, custom_headers=None, raw=False, polling=True, **operation_config): + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + def begin_update( + self, + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + parameters, # type: "models.GenericResource" + **kwargs # type: Any + ): + # type: (...) -> LROPoller """Updates a resource. - :param resource_group_name: The name of the resource group for the - resource. The name is case insensitive. + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource - provider. + :param resource_provider_namespace: The namespace of the resource provider. :type resource_provider_namespace: str :param parent_resource_path: The parent resource identity. :type parent_resource_path: str @@ -788,64 +828,63 @@ def update( :type resource_type: str :param resource_name: The name of the resource to update. :type resource_name: str - :param api_version: The API version to use for the operation. - :type api_version: str :param parameters: Parameters for updating the resource. - :type parameters: - ~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :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 polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns GenericResource or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 GenericResource + :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] + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._update_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, - api_version=api_version, parameters=parameters, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - deserialized = self._deserialize('GenericResource', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('GenericResource', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore def get( - self, resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, api_version, custom_headers=None, raw=False, **operation_config): + self, + 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: (...) -> "models.GenericResource" """Gets a resource. - :param resource_group_name: The name of the resource group containing - the resource to get. The name is case insensitive. + :param resource_group_name: The name of the resource group containing the resource to get. The + name is case insensitive. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource - provider. + :param resource_provider_namespace: The namespace of the resource provider. :type resource_provider_namespace: str :param parent_resource_path: The parent resource identity. :type parent_resource_path: str @@ -853,461 +892,443 @@ def get( :type resource_type: str :param resource_name: The name of the resource to get. :type resource_name: str - :param api_version: The API version to use for the operation. - :type api_version: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: GenericResource or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GenericResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-10" + # Construct URL - url = self.get.metadata['url'] + url = self.get.metadata['url'] # type: 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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('GenericResource', response) + deserialized = self._deserialize('GenericResource', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore def check_existence_by_id( - self, resource_id, api_version, custom_headers=None, raw=False, **operation_config): + self, + resource_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Checks by ID whether a resource exists. - :param resource_id: The fully qualified ID of the resource, including - the resource name and resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. :type resource_id: str - :param api_version: The API version to use for the operation. - :type api_version: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: bool or ClientRawResponse if raw=true - :rtype: bool or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-10" + # Construct URL - url = self.check_existence_by_id.metadata['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) + '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 = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204, 404]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = (response.status_code == 204) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - return deserialized - check_existence_by_id.metadata = {'url': '/{resourceId}'} + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + return 200 <= response.status_code <= 299 + check_existence_by_id.metadata = {'url': '/{resourceId}'} # type: ignore def _delete_by_id_initial( - self, resource_id, api_version, custom_headers=None, raw=False, **operation_config): + self, + resource_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-10" + # Construct URL - url = self.delete_by_id.metadata['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) + '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 = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + _delete_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore - def delete_by_id( - self, resource_id, api_version, custom_headers=None, raw=False, polling=True, **operation_config): + def begin_delete_by_id( + self, + resource_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> LROPoller """Deletes a resource by ID. - :param resource_id: The fully qualified ID of the resource, including - the resource name and resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. :type resource_id: str - :param api_version: The API version to use for the operation. - :type api_version: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns None or - ClientRawResponse if raw==True - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._delete_by_id_initial( resource_id=resource_id, - api_version=api_version, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - delete_by_id.metadata = {'url': '/{resourceId}'} - + begin_delete_by_id.metadata = {'url': '/{resourceId}'} # type: ignore def _create_or_update_by_id_initial( - self, resource_id, api_version, parameters, custom_headers=None, raw=False, **operation_config): + self, + resource_id, # type: str + parameters, # type: "models.GenericResource" + **kwargs # type: Any + ): + # type: (...) -> "models.GenericResource" + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {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.create_or_update_by_id.metadata['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) + '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 = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'GenericResource') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 201, 202]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('GenericResource', response) + deserialized = self._deserialize('GenericResource', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('GenericResource', response) + deserialized = self._deserialize('GenericResource', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - - def create_or_update_by_id( - self, resource_id, api_version, parameters, custom_headers=None, raw=False, polling=True, **operation_config): + _create_or_update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + def begin_create_or_update_by_id( + self, + resource_id, # type: str + parameters, # type: "models.GenericResource" + **kwargs # type: Any + ): + # type: (...) -> LROPoller """Create a resource by ID. - :param resource_id: The fully qualified ID of the resource, including - the resource name and resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. :type resource_id: str - :param api_version: The API version to use for the operation. - :type api_version: str :param parameters: Create or update resource parameters. - :type parameters: - ~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :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 polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns GenericResource or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 GenericResource + :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] + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._create_or_update_by_id_initial( resource_id=resource_id, - api_version=api_version, parameters=parameters, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - deserialized = self._deserialize('GenericResource', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('GenericResource', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - create_or_update_by_id.metadata = {'url': '/{resourceId}'} - + begin_create_or_update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore def _update_by_id_initial( - self, resource_id, api_version, parameters, custom_headers=None, raw=False, **operation_config): + self, + resource_id, # type: str + parameters, # type: "models.GenericResource" + **kwargs # type: Any + ): + # type: (...) -> "models.GenericResource" + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {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.update_by_id.metadata['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) + '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 = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'GenericResource') # Construct and send request - request = self._client.patch(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 202]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('GenericResource', response) + deserialized = self._deserialize('GenericResource', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - - def update_by_id( - self, resource_id, api_version, parameters, custom_headers=None, raw=False, polling=True, **operation_config): + _update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + def begin_update_by_id( + self, + resource_id, # type: str + parameters, # type: "models.GenericResource" + **kwargs # type: Any + ): + # type: (...) -> LROPoller """Updates a resource by ID. - :param resource_id: The fully qualified ID of the resource, including - the resource name and resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. :type resource_id: str - :param api_version: The API version to use for the operation. - :type api_version: str :param parameters: Update resource parameters. - :type parameters: - ~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :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 polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns GenericResource or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 GenericResource + :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] + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._update_by_id_initial( resource_id=resource_id, - api_version=api_version, parameters=parameters, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - deserialized = self._deserialize('GenericResource', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('GenericResource', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - update_by_id.metadata = {'url': '/{resourceId}'} + begin_update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore def get_by_id( - self, resource_id, api_version, custom_headers=None, raw=False, **operation_config): + self, + resource_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.GenericResource" """Gets a resource by ID. - :param resource_id: The fully qualified ID of the resource, including - the resource name and resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. :type resource_id: str - :param api_version: The API version to use for the operation. - :type api_version: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: GenericResource or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GenericResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.GenericResource + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-10" + # Construct URL - url = self.get_by_id.metadata['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) + '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 = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('GenericResource', response) + deserialized = self._deserialize('GenericResource', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/{resourceId}'} + 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 12ee3b33722f..d1291953d2cd 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 @@ -1,340 +1,336 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class TagsOperations(object): """TagsOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2019_05_10.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for this operation. Constant value: "2019-05-10". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-05-10" - - self.config = config + self._config = config def delete_value( - self, tag_name, tag_value, custom_headers=None, raw=False, **operation_config): + self, + tag_name, # type: str + tag_value, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Deletes a tag value. :param tag_name: The name of the tag. :type tag_name: str :param tag_value: The value of the tag to delete. :type tag_value: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-10" + # Construct URL - url = self.delete_value.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} + delete_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore def create_or_update_value( - self, tag_name, tag_value, custom_headers=None, raw=False, **operation_config): + self, + tag_name, # type: str + tag_value, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.TagValue" """Creates a tag value. The name of the tag must already exist. :param tag_name: The name of the tag. :type tag_name: str :param tag_value: The value of the tag to create. :type tag_value: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: TagValue or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.TagValue or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagValue or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.TagValue + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TagValue"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-10" + # Construct URL - url = self.create_or_update_value.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.put(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 201]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('TagValue', response) + deserialized = self._deserialize('TagValue', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('TagValue', response) + deserialized = self._deserialize('TagValue', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} + create_or_update_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore def create_or_update( - self, tag_name, custom_headers=None, raw=False, **operation_config): - """Creates a tag in the subscription. + self, + tag_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.TagDetails" + """The tag name can have a maximum of 512 characters and is case insensitive. Tag names created by Azure have prefixes of microsoft, azure, or windows. You cannot create tags with one of these prefixes. - The tag name can have a maximum of 512 characters and is case - insensitive. Tag names created by Azure have prefixes of microsoft, - azure, or windows. You cannot create tags with one of these prefixes. + Creates a tag in the subscription. :param tag_name: The name of the tag to create. :type tag_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: TagDetails or ClientRawResponse if raw=true + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagDetails or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_05_10.models.TagDetails - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TagDetails"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-10" + # Construct URL - url = self.create_or_update.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.put(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 201]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('TagDetails', response) + deserialized = self._deserialize('TagDetails', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('TagDetails', response) + deserialized = self._deserialize('TagDetails', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore def delete( - self, tag_name, custom_headers=None, raw=False, **operation_config): - """Deletes a tag from the subscription. + self, + tag_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """You must remove all values from a resource tag before you can delete it. - You must remove all values from a resource tag before you can delete - it. + Deletes a tag from the subscription. :param tag_name: The name of the tag. :type tag_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-10" + # Construct URL - url = self.delete.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} + delete.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore def list( - self, custom_headers=None, raw=False, **operation_config): - """Gets the names and values of all resource tags that are defined in a - subscription. - - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of TagDetails - :rtype: - ~azure.mgmt.resource.resources.v2019_05_10.models.TagDetailsPaged[~azure.mgmt.resource.resources.v2019_05_10.models.TagDetails] - :raises: :class:`CloudError` + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.TagsListResult"] + """Gets the names and values of all resource tags that are defined in a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of TagsListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-05-10" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['url'] + url = self.list.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('TagsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.TagDetailsPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/py.typed b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file 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 deleted file mode 100644 index 5da88867b6a2..000000000000 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_05_10/version.py +++ /dev/null @@ -1,13 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -VERSION = "2019-05-10" - 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 68bc897193ac..fde2ed4c3b83 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 @@ -1,19 +1,16 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._configuration import ResourceManagementClientConfiguration from ._resource_management_client import ResourceManagementClient -__all__ = ['ResourceManagementClient', 'ResourceManagementClientConfiguration'] - -from .version import VERSION - -__version__ = VERSION +__all__ = ['ResourceManagementClient'] +try: + from ._patch import patch_sdk + patch_sdk() +except ImportError: + pass 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 3b326f792363..e251713d2fed 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 @@ -1,48 +1,69 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrestazure import AzureConfiguration -from .version import VERSION +from typing import TYPE_CHECKING +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + + from azure.core.credentials import TokenCredential + +VERSION = "unknown" + +class ResourceManagementClientConfiguration(Configuration): + """Configuration for ResourceManagementClient. -class ResourceManagementClientConfiguration(AzureConfiguration): - """Configuration for ResourceManagementClient Note that all parameters used to create this instance are saved as instance attributes. - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` + :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 """ def __init__( - self, credentials, subscription_id, base_url=None): - - if credentials is None: - raise ValueError("Parameter 'credentials' must not be None.") + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + 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.") - if not base_url: - base_url = 'https://management.azure.com' + super(ResourceManagementClientConfiguration, self).__init__(**kwargs) - super(ResourceManagementClientConfiguration, self).__init__(base_url) - - # Starting Autorest.Python 4.0.64, make connection pool activated by default - self.keep_alive = True - - self.add_user_agent('azure-mgmt-resource/{}'.format(VERSION)) - self.add_user_agent('Azure-SDK-For-Python') - - self.credentials = credentials + self.credential = credential self.subscription_id = subscription_id + self.api_version = "2019-07-01" + self.credential_scopes = ['https://management.azure.com/.default'] + self.credential_scopes.extend(kwargs.pop('credential_scopes', [])) + kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + 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) 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 new file mode 100644 index 000000000000..6294101b761e --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/_metadata.json @@ -0,0 +1,59 @@ +{ + "chosen_version": "2019-07-01", + "total_api_version_list": ["2019-07-01"], + "client": { + "name": "ResourceManagementClient", + "filename": "_resource_management_client", + "description": "Provides operations for working with resources and resource groups." + }, + "global_parameters": { + "sync_method": { + "credential": { + "method_signature": "credential, # type: \"TokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials.TokenCredential", + "required": true + }, + "subscription_id": { + "method_signature": "subscription_id, # type: str", + "description": "The ID of the target subscription.", + "docstring_type": "str", + "required": true + } + }, + "async_method": { + "credential": { + "method_signature": "credential, # type: \"AsyncTokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + }, + "subscription_id": { + "method_signature": "subscription_id, # type: str", + "description": "The ID of the target subscription.", + "docstring_type": "str", + "required": true + } + }, + "constant": { + }, + "call": "credential, subscription_id" + }, + "config": { + "credential": true, + "credential_scopes": ["https://management.azure.com/.default"] + }, + "operation_groups": { + "operations": "Operations", + "deployments": "DeploymentsOperations", + "providers": "ProvidersOperations", + "resources": "ResourcesOperations", + "resource_groups": "ResourceGroupsOperations", + "tags": "TagsOperations", + "deployment_operations": "DeploymentOperationsOperations" + }, + "operation_mixins": { + }, + "sync_imports": "None", + "async_imports": "None" +} \ 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 f0cd1c10bfe0..6b69660944d9 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 @@ -1,16 +1,19 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.service_client import SDKClient -from msrest import Serializer, Deserializer +from typing import TYPE_CHECKING + +from azure.mgmt.core import ARMPipelineClient +from msrest import Deserializer, Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional from ._configuration import ResourceManagementClientConfiguration from .operations import Operations @@ -19,61 +22,76 @@ from .operations import ResourcesOperations from .operations import ResourceGroupsOperations from .operations import TagsOperations -from .operations import DeploymentOperations +from .operations import DeploymentOperationsOperations from . import models -class ResourceManagementClient(SDKClient): +class ResourceManagementClient(object): """Provides operations for working with resources and resource groups. - :ivar config: Configuration for client. - :vartype config: ResourceManagementClientConfiguration - :ivar operations: Operations operations :vartype operations: azure.mgmt.resource.resources.v2019_07_01.operations.Operations - :ivar deployments: Deployments operations + :ivar deployments: DeploymentsOperations operations :vartype deployments: azure.mgmt.resource.resources.v2019_07_01.operations.DeploymentsOperations - :ivar providers: Providers operations + :ivar providers: ProvidersOperations operations :vartype providers: azure.mgmt.resource.resources.v2019_07_01.operations.ProvidersOperations - :ivar resources: Resources operations + :ivar resources: ResourcesOperations operations :vartype resources: azure.mgmt.resource.resources.v2019_07_01.operations.ResourcesOperations - :ivar resource_groups: ResourceGroups operations + :ivar resource_groups: ResourceGroupsOperations operations :vartype resource_groups: azure.mgmt.resource.resources.v2019_07_01.operations.ResourceGroupsOperations - :ivar tags: Tags operations + :ivar tags: TagsOperations operations :vartype tags: azure.mgmt.resource.resources.v2019_07_01.operations.TagsOperations - :ivar deployment_operations: DeploymentOperations operations - :vartype deployment_operations: azure.mgmt.resource.resources.v2019_07_01.operations.DeploymentOperations - - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` + :ivar deployment_operations: DeploymentOperationsOperations operations + :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. """ def __init__( - self, credentials, subscription_id, base_url=None): - - self.config = ResourceManagementClientConfiguration(credentials, subscription_id, base_url) - super(ResourceManagementClient, self).__init__(self.config.credentials, self.config) + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = 'https://management.azure.com' + self._config = ResourceManagementClientConfiguration(credential, 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.api_version = '2019-07-01' self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self.operations = Operations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.deployments = DeploymentsOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.providers = ProvidersOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.resources = ResourcesOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.resource_groups = ResourceGroupsOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.tags = TagsOperations( - self._client, self.config, self._serialize, self._deserialize) - self.deployment_operations = DeploymentOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) + self.deployment_operations = DeploymentOperationsOperations( + self._client, self._config, self._serialize, self._deserialize) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> ResourceManagementClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) 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 new file mode 100644 index 000000000000..7f9b1bac71c5 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/__init__.py @@ -0,0 +1,10 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._resource_management_client_async import ResourceManagementClient +__all__ = ['ResourceManagementClient'] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/_configuration_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/_configuration_async.py new file mode 100644 index 000000000000..ff5f3cad4af9 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/_configuration_async.py @@ -0,0 +1,65 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + +VERSION = "unknown" + +class ResourceManagementClientConfiguration(Configuration): + """Configuration for ResourceManagementClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :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 + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + 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 + self.api_version = "2019-07-01" + self.credential_scopes = ['https://management.azure.com/.default'] + self.credential_scopes.extend(kwargs.pop('credential_scopes', [])) + kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs: Any + ) -> None: + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + 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) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/_resource_management_client_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/_resource_management_client_async.py new file mode 100644 index 000000000000..15ba1a19760b --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/_resource_management_client_async.py @@ -0,0 +1,89 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, Optional + +from azure.mgmt.core import AsyncARMPipelineClient +from msrest import Deserializer, Serializer + +from ._configuration_async import ResourceManagementClientConfiguration +from .operations_async import Operations +from .operations_async import DeploymentsOperations +from .operations_async import ProvidersOperations +from .operations_async import ResourcesOperations +from .operations_async import ResourceGroupsOperations +from .operations_async import TagsOperations +from .operations_async import DeploymentOperationsOperations +from .. import models + + +class ResourceManagementClient(object): + """Provides operations for working with resources and resource groups. + + :ivar operations: Operations operations + :vartype operations: azure.mgmt.resource.resources.v2019_07_01.aio.operations_async.Operations + :ivar deployments: DeploymentsOperations operations + :vartype deployments: azure.mgmt.resource.resources.v2019_07_01.aio.operations_async.DeploymentsOperations + :ivar providers: ProvidersOperations operations + :vartype providers: azure.mgmt.resource.resources.v2019_07_01.aio.operations_async.ProvidersOperations + :ivar resources: ResourcesOperations operations + :vartype resources: azure.mgmt.resource.resources.v2019_07_01.aio.operations_async.ResourcesOperations + :ivar resource_groups: ResourceGroupsOperations operations + :vartype resource_groups: azure.mgmt.resource.resources.v2019_07_01.aio.operations_async.ResourceGroupsOperations + :ivar tags: TagsOperations operations + :vartype tags: azure.mgmt.resource.resources.v2019_07_01.aio.operations_async.TagsOperations + :ivar deployment_operations: DeploymentOperationsOperations operations + :vartype deployment_operations: azure.mgmt.resource.resources.v2019_07_01.aio.operations_async.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. + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: Optional[str] = None, + **kwargs: 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) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + + self.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 close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "ResourceManagementClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/operations_async/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/operations_async/__init__.py new file mode 100644 index 000000000000..f1fd8637fa69 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/operations_async/__init__.py @@ -0,0 +1,25 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._operations_async import Operations +from ._deployments_operations_async import DeploymentsOperations +from ._providers_operations_async import ProvidersOperations +from ._resources_operations_async import ResourcesOperations +from ._resource_groups_operations_async import ResourceGroupsOperations +from ._tags_operations_async import TagsOperations +from ._deployment_operations_operations_async import DeploymentOperationsOperations + +__all__ = [ + 'Operations', + 'DeploymentsOperations', + 'ProvidersOperations', + 'ResourcesOperations', + 'ResourceGroupsOperations', + 'TagsOperations', + 'DeploymentOperationsOperations', +] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/operations_async/_deployment_operations_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/operations_async/_deployment_operations_operations_async.py new file mode 100644 index 000000000000..4d008e44272b --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/operations_async/_deployment_operations_operations_async.py @@ -0,0 +1,700 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import 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 ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class DeploymentOperationsOperations: + """DeploymentOperationsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2019_07_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def get_at_scope( + self, + scope: str, + deployment_name: str, + operation_id: str, + **kwargs + ) -> "models.DeploymentOperation": + """Gets a deployments operation. + + :param scope: The scope of a deployment. + :type scope: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param operation_id: The ID of the operation to get. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentOperation or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentOperation + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentOperation"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentOperation', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + def list_at_scope( + self, + scope: str, + deployment_name: str, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.DeploymentOperationsListResult"]: + """Gets all deployments operations for a deployment. + + :param scope: The scope of a deployment. + :type scope: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentOperationsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} # type: ignore + + async def get_at_tenant_scope( + self, + deployment_name: str, + operation_id: str, + **kwargs + ) -> "models.DeploymentOperation": + """Gets a deployments operation. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param operation_id: The ID of the operation to get. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentOperation or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentOperation + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentOperation"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentOperation', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + def list_at_tenant_scope( + self, + deployment_name: str, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.DeploymentOperationsListResult"]: + """Gets all deployments operations for a deployment. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentOperationsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} # type: ignore + + async def get_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + operation_id: str, + **kwargs + ) -> "models.DeploymentOperation": + """Gets a deployments operation. + + :param group_id: The management group ID. + :type group_id: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param operation_id: The ID of the operation to get. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentOperation or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentOperation + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentOperation"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentOperation', pipeline_response) + + if cls: + 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 + + def list_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.DeploymentOperationsListResult"]: + """Gets all deployments operations for a deployment. + + :param group_id: The management group ID. + :type group_id: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentOperationsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + 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 + + async def get_at_subscription_scope( + self, + deployment_name: str, + operation_id: str, + **kwargs + ) -> "models.DeploymentOperation": + """Gets a deployments operation. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param operation_id: The ID of the operation to get. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentOperation or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentOperation + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentOperation"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentOperation', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + def list_at_subscription_scope( + self, + deployment_name: str, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.DeploymentOperationsListResult"]: + """Gets all deployments operations for a deployment. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentOperationsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + 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 + + async def get( + self, + resource_group_name: str, + deployment_name: str, + operation_id: str, + **kwargs + ) -> "models.DeploymentOperation": + """Gets a deployments operation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param operation_id: The ID of the operation to get. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentOperation or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentOperation + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentOperation"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + + # Construct URL + url = self.get.metadata['url'] # type: 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentOperation', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + def list( + self, + resource_group_name: str, + deployment_name: str, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.DeploymentOperationsListResult"]: + """Gets all deployments operations for a deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentOperationsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/operations_async/_deployments_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/operations_async/_deployments_operations_async.py new file mode 100644 index 000000000000..623d71015327 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/operations_async/_deployments_operations_async.py @@ -0,0 +1,3112 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.polling import AsyncNoPolling, AsyncPollingMethod, async_poller +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class DeploymentsOperations: + """DeploymentsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2019_07_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def _delete_at_scope_initial( + self, + scope: str, + deployment_name: str, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + + # 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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_at_scope_initial.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def delete_at_scope( + self, + scope: str, + deployment_name: str, + **kwargs + ) -> None: + """A template deployment that is currently running cannot be deleted. Deleting a template deployment removes the associated deployment operations. This is an asynchronous operation that returns a status of 202 until the template deployment is successfully deleted. The Location response header contains the URI that is used to obtain the status of the process. While the process is running, a call to the URI in the Location header returns a status of 202. When the process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. + + Deletes a deployment from the deployment history. + + :param scope: The scope of a deployment. + :type scope: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._delete_at_scope_initial( + scope=scope, + deployment_name=deployment_name, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + delete_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def check_existence_at_scope( + self, + scope: str, + deployment_name: str, + **kwargs + ) -> None: + """Checks whether the deployment exists. + + :param scope: The scope of a deployment. + :type scope: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + + # 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] + + # Construct and send request + 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 + + if response.status_code not in [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + 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, + deployment_name: str, + properties: "models.DeploymentProperties", + location: Optional[str] = None, + **kwargs + ) -> "models.DeploymentExtended": + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.Deployment(location=location, properties=properties) + api_version = "2019-07-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_at_scope_initial.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def create_or_update_at_scope( + self, + scope: str, + deployment_name: str, + properties: "models.DeploymentProperties", + location: Optional[str] = None, + **kwargs + ) -> "models.DeploymentExtended": + """You can provide the template and parameters directly in the request or link to JSON files. + + Deploys resources at a given scope. + + :param scope: The scope of a deployment. + :type scope: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param properties: The deployment properties. + :type properties: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentProperties + :param location: The location to store the deployment data. + :type location: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: DeploymentExtended + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._create_or_update_at_scope_initial( + scope=scope, + deployment_name=deployment_name, + properties=properties, + location=location, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + create_or_update_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def get_at_scope( + self, + scope: str, + deployment_name: str, + **kwargs + ) -> "models.DeploymentExtended": + """Gets a deployment. + + :param scope: The scope of a deployment. + :type scope: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExtended or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def cancel_at_scope( + self, + scope: str, + deployment_name: str, + **kwargs + ) -> None: + """You can cancel a deployment only if the provisioningState is Accepted or Running. After the deployment is canceled, the provisioningState is set to Canceled. Canceling a template deployment stops the currently running template deployment and leaves the resources partially deployed. + + Cancels a currently running template deployment. + + :param scope: The scope of a deployment. + :type scope: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + + # 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] + + # Construct and send request + 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 [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + cancel_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + + async def validate_at_scope( + self, + scope: str, + deployment_name: str, + properties: "models.DeploymentProperties", + location: Optional[str] = None, + **kwargs + ) -> "models.DeploymentValidateResult": + """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. + + :param scope: The scope of a deployment. + :type scope: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param properties: The deployment properties. + :type properties: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentProperties + :param location: The location to store the deployment data. + :type location: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentValidateResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentValidateResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.Deployment(location=location, properties=properties) + api_version = "2019-07-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 400]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + + if response.status_code == 400: + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + validate_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + async def export_template_at_scope( + self, + scope: str, + deployment_name: str, + **kwargs + ) -> "models.DeploymentExportResult": + """Exports the template used for specified deployment. + + :param scope: The scope of a deployment. + :type scope: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExportResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExportResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + + # 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'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + export_template_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + def list_at_scope( + self, + scope: str, + filter: Optional[str] = None, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.DeploymentListResult"]: + """Get all the deployments at the given scope. + + :param scope: The scope of a deployment. + :type scope: str + :param filter: The filter to apply on the operation. For example, you can use + $filter=provisioningState eq '{state}'. + :type filter: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/'} # type: ignore + + async def _delete_at_tenant_scope_initial( + self, + deployment_name: str, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + + # 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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_at_tenant_scope_initial.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def delete_at_tenant_scope( + self, + deployment_name: str, + **kwargs + ) -> None: + """A template deployment that is currently running cannot be deleted. Deleting a template deployment removes the associated deployment operations. This is an asynchronous operation that returns a status of 202 until the template deployment is successfully deleted. The Location response header contains the URI that is used to obtain the status of the process. While the process is running, a call to the URI in the Location header returns a status of 202. When the process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. + + Deletes a deployment from the deployment history. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._delete_at_tenant_scope_initial( + deployment_name=deployment_name, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + delete_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def check_existence_at_tenant_scope( + self, + deployment_name: str, + **kwargs + ) -> None: + """Checks whether the deployment exists. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + + # 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] + + # Construct and send request + 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 + + if response.status_code not in [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + 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, + properties: "models.DeploymentProperties", + location: Optional[str] = None, + **kwargs + ) -> "models.DeploymentExtended": + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.Deployment(location=location, properties=properties) + api_version = "2019-07-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_at_tenant_scope_initial.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def create_or_update_at_tenant_scope( + self, + deployment_name: str, + properties: "models.DeploymentProperties", + location: Optional[str] = None, + **kwargs + ) -> "models.DeploymentExtended": + """You can provide the template and parameters directly in the request or link to JSON files. + + Deploys resources at tenant scope. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param properties: The deployment properties. + :type properties: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentProperties + :param location: The location to store the deployment data. + :type location: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: DeploymentExtended + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._create_or_update_at_tenant_scope_initial( + deployment_name=deployment_name, + properties=properties, + location=location, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + create_or_update_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def get_at_tenant_scope( + self, + deployment_name: str, + **kwargs + ) -> "models.DeploymentExtended": + """Gets a deployment. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExtended or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def cancel_at_tenant_scope( + self, + deployment_name: str, + **kwargs + ) -> None: + """You can cancel a deployment only if the provisioningState is Accepted or Running. After the deployment is canceled, the provisioningState is set to Canceled. Canceling a template deployment stops the currently running template deployment and leaves the resources partially deployed. + + Cancels a currently running template deployment. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + + # 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] + + # Construct and send request + 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 [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + cancel_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + + async def validate_at_tenant_scope( + self, + deployment_name: str, + properties: "models.DeploymentProperties", + location: Optional[str] = None, + **kwargs + ) -> "models.DeploymentValidateResult": + """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param properties: The deployment properties. + :type properties: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentProperties + :param location: The location to store the deployment data. + :type location: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentValidateResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentValidateResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.Deployment(location=location, properties=properties) + api_version = "2019-07-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 400]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + + if response.status_code == 400: + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + validate_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + async def export_template_at_tenant_scope( + self, + deployment_name: str, + **kwargs + ) -> "models.DeploymentExportResult": + """Exports the template used for specified deployment. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExportResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExportResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + + # 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'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + export_template_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + def list_at_tenant_scope( + self, + filter: Optional[str] = None, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.DeploymentListResult"]: + """Get all the deployments at the tenant scope. + + :param filter: The filter to apply on the operation. For example, you can use + $filter=provisioningState eq '{state}'. + :type filter: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/'} # type: ignore + + async def _delete_at_management_group_scope_initial( + self, + group_id: str, + deployment_name: str, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_at_management_group_scope_initial.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def delete_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + **kwargs + ) -> None: + """A template deployment that is currently running cannot be deleted. Deleting a template deployment removes the associated deployment operations. This is an asynchronous operation that returns a status of 202 until the template deployment is successfully deleted. The Location response header contains the URI that is used to obtain the status of the process. While the process is running, a call to the URI in the Location header returns a status of 202. When the process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. + + Deletes a deployment from the deployment history. + + :param group_id: The management group ID. + :type group_id: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._delete_at_management_group_scope_initial( + group_id=group_id, + deployment_name=deployment_name, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + delete_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def check_existence_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + **kwargs + ) -> None: + """Checks whether the deployment exists. + + :param group_id: The management group ID. + :type group_id: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-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] + + # Construct and send request + 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 + + if response.status_code not in [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + 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, + deployment_name: str, + properties: "models.DeploymentProperties", + location: Optional[str] = None, + **kwargs + ) -> "models.DeploymentExtended": + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.Deployment(location=location, properties=properties) + api_version = "2019-07-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + 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 + + async def create_or_update_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + properties: "models.DeploymentProperties", + location: Optional[str] = None, + **kwargs + ) -> "models.DeploymentExtended": + """You can provide the template and parameters directly in the request or link to JSON files. + + Deploys resources at management group scope. + + :param group_id: The management group ID. + :type group_id: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param properties: The deployment properties. + :type properties: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentProperties + :param location: The location to store the deployment data. + :type location: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: DeploymentExtended + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._create_or_update_at_management_group_scope_initial( + group_id=group_id, + deployment_name=deployment_name, + properties=properties, + location=location, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + create_or_update_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def get_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + **kwargs + ) -> "models.DeploymentExtended": + """Gets a deployment. + + :param group_id: The management group ID. + :type group_id: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExtended or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + 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 + + async def cancel_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + **kwargs + ) -> None: + """You can cancel a deployment only if the provisioningState is Accepted or Running. After the deployment is canceled, the provisioningState is set to Canceled. Canceling a template deployment stops the currently running template deployment and leaves the resources partially deployed. + + Cancels a currently running template deployment. + + :param group_id: The management group ID. + :type group_id: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-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] + + # Construct and send request + 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 [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + 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( + self, + group_id: str, + deployment_name: str, + properties: "models.DeploymentProperties", + location: Optional[str] = None, + **kwargs + ) -> "models.DeploymentValidateResult": + """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. + + :param group_id: The management group ID. + :type group_id: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param properties: The deployment properties. + :type properties: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentProperties + :param location: The location to store the deployment data. + :type location: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentValidateResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentValidateResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.Deployment(location=location, properties=properties) + api_version = "2019-07-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 400]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + + if response.status_code == 400: + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + + if cls: + 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 + + async def export_template_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + **kwargs + ) -> "models.DeploymentExportResult": + """Exports the template used for specified deployment. + + :param group_id: The management group ID. + :type group_id: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExportResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExportResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + + # 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'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + + if cls: + 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 + + def list_at_management_group_scope( + self, + group_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.DeploymentListResult"]: + """Get all the deployments for a management group. + + :param group_id: The management group ID. + :type group_id: str + :param filter: The filter to apply on the operation. For example, you can use + $filter=provisioningState eq '{state}'. + :type filter: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + 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/'} # type: ignore + + async def _delete_at_subscription_scope_initial( + self, + deployment_name: str, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def delete_at_subscription_scope( + self, + deployment_name: str, + **kwargs + ) -> None: + """A template deployment that is currently running cannot be deleted. Deleting a template deployment removes the associated deployment operations. This is an asynchronous operation that returns a status of 202 until the template deployment is successfully deleted. The Location response header contains the URI that is used to obtain the status of the process. While the process is running, a call to the URI in the Location header returns a status of 202. When the process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. + + Deletes a deployment from the deployment history. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._delete_at_subscription_scope_initial( + deployment_name=deployment_name, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + delete_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def check_existence_at_subscription_scope( + self, + deployment_name: str, + **kwargs + ) -> None: + """Checks whether the deployment exists. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-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] + + # Construct and send request + 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 + + if response.status_code not in [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + 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, + properties: "models.DeploymentProperties", + location: Optional[str] = None, + **kwargs + ) -> "models.DeploymentExtended": + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.Deployment(location=location, properties=properties) + api_version = "2019-07-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + 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 + + async def create_or_update_at_subscription_scope( + self, + deployment_name: str, + properties: "models.DeploymentProperties", + location: Optional[str] = None, + **kwargs + ) -> "models.DeploymentExtended": + """You can provide the template and parameters directly in the request or link to JSON files. + + Deploys resources at subscription scope. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param properties: The deployment properties. + :type properties: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentProperties + :param location: The location to store the deployment data. + :type location: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: DeploymentExtended + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._create_or_update_at_subscription_scope_initial( + deployment_name=deployment_name, + properties=properties, + location=location, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + create_or_update_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def get_at_subscription_scope( + self, + deployment_name: str, + **kwargs + ) -> "models.DeploymentExtended": + """Gets a deployment. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExtended or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def cancel_at_subscription_scope( + self, + deployment_name: str, + **kwargs + ) -> None: + """You can cancel a deployment only if the provisioningState is Accepted or Running. After the deployment is canceled, the provisioningState is set to Canceled. Canceling a template deployment stops the currently running template deployment and leaves the resources partially deployed. + + Cancels a currently running template deployment. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-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] + + # Construct and send request + 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 [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + cancel_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + + async def validate_at_subscription_scope( + self, + deployment_name: str, + properties: "models.DeploymentProperties", + location: Optional[str] = None, + **kwargs + ) -> "models.DeploymentValidateResult": + """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param properties: The deployment properties. + :type properties: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentProperties + :param location: The location to store the deployment data. + :type location: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentValidateResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentValidateResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.Deployment(location=location, properties=properties) + api_version = "2019-07-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 400]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + + if response.status_code == 400: + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + + if cls: + 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, + properties: "models.DeploymentWhatIfProperties", + location: Optional[str] = None, + **kwargs + ) -> "models.WhatIfOperationResult": + cls = kwargs.pop('cls', None) # type: ClsType["models.WhatIfOperationResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.DeploymentWhatIf(location=location, properties=properties) + api_version = "2019-07-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + deserialized = None + 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 + + async def what_if_at_subscription_scope( + self, + deployment_name: str, + properties: "models.DeploymentWhatIfProperties", + location: Optional[str] = None, + **kwargs + ) -> "models.WhatIfOperationResult": + """Returns changes that will be made by the deployment if executed at the scope of the subscription. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param properties: The deployment properties. + :type properties: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentWhatIfProperties + :param location: The location to store the deployment data. + :type location: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: WhatIfOperationResult + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.WhatIfOperationResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.WhatIfOperationResult"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._what_if_at_subscription_scope_initial( + deployment_name=deployment_name, + properties=properties, + location=location, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + 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 + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + what_if_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + + async def export_template_at_subscription_scope( + self, + deployment_name: str, + **kwargs + ) -> "models.DeploymentExportResult": + """Exports the template used for specified deployment. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExportResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExportResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + + # 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'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + export_template_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + def list_at_subscription_scope( + self, + filter: Optional[str] = None, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.DeploymentListResult"]: + """Get all the deployments for a subscription. + + :param filter: The filter to apply on the operation. For example, you can use + $filter=provisioningState eq '{state}'. + :type filter: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/'} # type: ignore + + async def _delete_initial( + self, + resource_group_name: str, + deployment_name: str, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def delete( + self, + resource_group_name: str, + deployment_name: str, + **kwargs + ) -> None: + """A template deployment that is currently running cannot be deleted. Deleting a template deployment removes the associated deployment operations. Deleting a template deployment does not affect the state of the resource group. This is an asynchronous operation that returns a status of 202 until the template deployment is successfully deleted. The Location response header contains the URI that is used to obtain the status of the process. While the process is running, a call to the URI in the Location header returns a status of 202. When the process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. + + Deletes a deployment from the deployment history. + + :param resource_group_name: The name of the resource group with the deployment to delete. The + name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def check_existence( + self, + resource_group_name: str, + deployment_name: str, + **kwargs + ) -> None: + """Checks whether the deployment exists. + + :param resource_group_name: The name of the resource group with the deployment to check. The + name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-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] + + # Construct and send request + 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 + + if response.status_code not in [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + 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, + deployment_name: str, + properties: "models.DeploymentProperties", + location: Optional[str] = None, + **kwargs + ) -> "models.DeploymentExtended": + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.Deployment(location=location, properties=properties) + api_version = "2019-07-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def create_or_update( + self, + resource_group_name: str, + deployment_name: str, + properties: "models.DeploymentProperties", + location: Optional[str] = None, + **kwargs + ) -> "models.DeploymentExtended": + """You can provide the template and parameters directly in the request or link to JSON files. + + Deploys resources to a resource group. + + :param resource_group_name: The name of the resource group to deploy the resources to. The name + is case insensitive. The resource group must already exist. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param properties: The deployment properties. + :type properties: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentProperties + :param location: The location to store the deployment data. + :type location: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: DeploymentExtended + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + properties=properties, + location=location, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def get( + self, + resource_group_name: str, + deployment_name: str, + **kwargs + ) -> "models.DeploymentExtended": + """Gets a deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExtended or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + + # Construct URL + url = self.get.metadata['url'] # type: 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def cancel( + self, + resource_group_name: str, + deployment_name: str, + **kwargs + ) -> None: + """You can cancel a deployment only if the provisioningState is Accepted or Running. After the deployment is canceled, the provisioningState is set to Canceled. Canceling a template deployment stops the currently running template deployment and leaves the resource group partially deployed. + + Cancels a currently running template deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-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] + + # Construct and send request + 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 [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + cancel.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + + async def validate( + self, + resource_group_name: str, + deployment_name: str, + properties: "models.DeploymentProperties", + location: Optional[str] = None, + **kwargs + ) -> "models.DeploymentValidateResult": + """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param properties: The deployment properties. + :type properties: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentProperties + :param location: The location to store the deployment data. + :type location: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentValidateResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentValidateResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.Deployment(location=location, properties=properties) + api_version = "2019-07-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 400]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + + if response.status_code == 400: + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + + if cls: + 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, + deployment_name: str, + properties: "models.DeploymentWhatIfProperties", + location: Optional[str] = None, + **kwargs + ) -> "models.WhatIfOperationResult": + cls = kwargs.pop('cls', None) # type: ClsType["models.WhatIfOperationResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.DeploymentWhatIf(location=location, properties=properties) + api_version = "2019-07-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + deserialized = None + 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 + + async def what_if( + self, + resource_group_name: str, + deployment_name: str, + properties: "models.DeploymentWhatIfProperties", + location: Optional[str] = None, + **kwargs + ) -> "models.WhatIfOperationResult": + """Returns changes that will be made by the deployment if executed at the scope of the resource group. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param properties: The deployment properties. + :type properties: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentWhatIfProperties + :param location: The location to store the deployment data. + :type location: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: WhatIfOperationResult + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.WhatIfOperationResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.WhatIfOperationResult"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._what_if_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + properties=properties, + location=location, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + 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 + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + what_if.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + + async def export_template( + self, + resource_group_name: str, + deployment_name: str, + **kwargs + ) -> "models.DeploymentExportResult": + """Exports the template used for specified deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExportResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExportResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + + # 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'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + def list_by_resource_group( + self, + resource_group_name: str, + filter: Optional[str] = None, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.DeploymentListResult"]: + """Get all the deployments for a resource group. + + :param resource_group_name: The name of the resource group with the deployments to get. The + name is case insensitive. + :type resource_group_name: str + :param filter: The filter to apply on the operation. For example, you can use + $filter=provisioningState eq '{state}'. + :type filter: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + 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 + + async def calculate_template_hash( + self, + template: object, + **kwargs + ) -> "models.TemplateHashResult": + """Calculate the hash of the given template. + + :param template: The template provided to calculate hash. + :type template: object + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateHashResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.TemplateHashResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TemplateHashResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + content_type = kwargs.pop("content_type", "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'] = 'application/json' + + # Construct and send request + 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) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('TemplateHashResult', pipeline_response) + + if cls: + 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_async/_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/operations_async/_operations_async.py new file mode 100644 index 000000000000..e89e065f9815 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/operations_async/_operations_async.py @@ -0,0 +1,101 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import 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 ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class Operations: + """Operations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2019_07_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + **kwargs + ) -> AsyncIterable["models.OperationListResult"]: + """Lists all of the available Microsoft.Resources REST API operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of OperationListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('OperationListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.Resources/operations'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/operations_async/_providers_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/operations_async/_providers_operations_async.py new file mode 100644 index 000000000000..b965ac02c487 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/operations_async/_providers_operations_async.py @@ -0,0 +1,407 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import 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 ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ProvidersOperations: + """ProvidersOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2019_07_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def unregister( + self, + resource_provider_namespace: str, + **kwargs + ) -> "models.Provider": + """Unregisters a subscription from a resource provider. + + :param resource_provider_namespace: The namespace of the resource provider to unregister. + :type resource_provider_namespace: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Provider or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.Provider + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Provider"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + + # 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'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Provider', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + unregister.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister'} # type: ignore + + async def register( + self, + resource_provider_namespace: str, + **kwargs + ) -> "models.Provider": + """Registers a subscription with a resource provider. + + :param resource_provider_namespace: The namespace of the resource provider to register. + :type resource_provider_namespace: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Provider or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.Provider + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Provider"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + + # 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'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Provider', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + register.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register'} # type: ignore + + def list( + self, + top: Optional[int] = None, + expand: Optional[str] = None, + **kwargs + ) -> AsyncIterable["models.ProviderListResult"]: + """Gets all resource providers for a subscription. + + :param top: The number of results to return. If null is passed returns all deployments. + :type top: int + :param expand: The properties to include in the results. For example, use &$expand=metadata in + the query string to retrieve resource provider metadata. To include property aliases in + response, use $expand=resourceTypes/aliases. + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of ProviderListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ProviderListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers'} # type: ignore + + def list_at_tenant_scope( + self, + top: Optional[int] = None, + expand: Optional[str] = None, + **kwargs + ) -> AsyncIterable["models.ProviderListResult"]: + """Gets all resource providers for the tenant. + + :param top: The number of results to return. If null is passed returns all providers. + :type top: int + :param expand: The properties to include in the results. For example, use &$expand=metadata in + the query string to retrieve resource provider metadata. To include property aliases in + response, use $expand=resourceTypes/aliases. + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of ProviderListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ProviderListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_at_tenant_scope.metadata = {'url': '/providers'} # type: ignore + + async def get( + self, + resource_provider_namespace: str, + expand: Optional[str] = None, + **kwargs + ) -> "models.Provider": + """Gets the specified resource provider. + + :param resource_provider_namespace: The namespace of the resource provider. + :type resource_provider_namespace: str + :param expand: The $expand query parameter. For example, to include property aliases in + response, use $expand=resourceTypes/aliases. + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Provider or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.Provider + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Provider"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Provider', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}'} # type: ignore + + async def get_at_tenant_scope( + self, + resource_provider_namespace: str, + expand: Optional[str] = None, + **kwargs + ) -> "models.Provider": + """Gets the specified resource provider at the tenant level. + + :param resource_provider_namespace: The namespace of the resource provider. + :type resource_provider_namespace: str + :param expand: The $expand query parameter. For example, to include property aliases in + response, use $expand=resourceTypes/aliases. + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Provider or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.Provider + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Provider"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Provider', pipeline_response) + + if cls: + 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_async/_resource_groups_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/operations_async/_resource_groups_operations_async.py new file mode 100644 index 000000000000..a6555dddb2ac --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/operations_async/_resource_groups_operations_async.py @@ -0,0 +1,505 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, List, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.polling import AsyncNoPolling, AsyncPollingMethod, async_poller +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ResourceGroupsOperations: + """ResourceGroupsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2019_07_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def check_existence( + self, + resource_group_name: str, + **kwargs + ) -> None: + """Checks whether a resource group exists. + + :param resource_group_name: The name of the resource group to check. 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: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-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] + + # Construct and send request + 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 + + if response.status_code not in [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + async def create_or_update( + self, + resource_group_name: str, + parameters: "models.ResourceGroup", + **kwargs + ) -> "models.ResourceGroup": + """Creates or updates a resource group. + + :param resource_group_name: The name of the resource group to create or update. Can include + alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters + that match the allowed characters. + :type resource_group_name: str + :param parameters: Parameters supplied to the create or update a resource group. + :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.ResourceGroup + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.ResourceGroup + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceGroup"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ResourceGroup', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ResourceGroup', pipeline_response) + + if cls: + 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, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-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] + + # Construct and send request + 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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + async def delete( + self, + resource_group_name: str, + **kwargs + ) -> None: + """When you delete a resource group, all of its resources are also deleted. Deleting a resource group deletes all of its template deployments and currently stored operations. + + Deletes a resource group. + + :param resource_group_name: The name of the resource group to delete. 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 + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + async def get( + self, + resource_group_name: str, + **kwargs + ) -> "models.ResourceGroup": + """Gets a resource group. + + :param resource_group_name: The name of the resource group to get. 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: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.ResourceGroup + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceGroup"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + + # Construct URL + url = self.get.metadata['url'] # type: 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ResourceGroup', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + async def update( + self, + resource_group_name: str, + parameters: "models.ResourceGroupPatchable", + **kwargs + ) -> "models.ResourceGroup": + """Resource groups can be updated through a simple PATCH operation to a group address. The format of the request is the same as that for creating a resource group. If a field is unspecified, the current value is retained. + + Updates a resource group. + + :param resource_group_name: The name of the resource group to update. The name is case + insensitive. + :type resource_group_name: str + :param parameters: Parameters supplied to update a resource group. + :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.ResourceGroupPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.ResourceGroup + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceGroup"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ResourceGroup', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + async def export_template( + self, + resource_group_name: str, + resources: Optional[List[str]] = None, + options: Optional[str] = None, + **kwargs + ) -> "models.ResourceGroupExportResult": + """Captures the specified resource group as a template. + + :param resource_group_name: The name of the resource group to export as a template. + :type resource_group_name: str + :param 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', + 'SkipResourceNameParameterization', 'SkipAllParameterization'. + :type options: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroupExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.ResourceGroupExportResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceGroupExportResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.ExportTemplateRequest(resources=resources, options=options) + api_version = "2019-07-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ResourceGroupExportResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate'} # type: ignore + + def list( + self, + filter: Optional[str] = None, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.ResourceGroupListResult"]: + """Gets all the resource groups for a subscription. + + :param filter: The filter to apply on the operation.:code:`
`:code:`
`You can filter by + tag names and values. For example, to filter for a tag name and value, use $filter=tagName eq + 'tag1' and tagValue eq 'Value1'. + :type filter: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ResourceGroupListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/operations_async/_resources_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/operations_async/_resources_operations_async.py new file mode 100644 index 000000000000..33690af932c7 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/operations_async/_resources_operations_async.py @@ -0,0 +1,1308 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, List, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.polling import AsyncNoPolling, AsyncPollingMethod, async_poller +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ResourcesOperations: + """ResourcesOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2019_07_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list_by_resource_group( + self, + resource_group_name: str, + filter: Optional[str] = None, + expand: Optional[str] = None, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.ResourceListResult"]: + """Get all the resources for a resource group. + + :param resource_group_name: The resource group with the resources to get. + :type resource_group_name: str + :param filter: The filter to apply on the operation.:code:`
`:code:`
`The properties you + can use for eq (equals) or ne (not equals) are: location, resourceType, name, resourceGroup, + identity, identity/principalId, plan, plan/publisher, plan/product, plan/name, plan/version, + and plan/promotionCode.:code:`
`:code:`
`For example, to filter by a resource type, use: + $filter=resourceType eq 'Microsoft.Network/virtualNetworks':code:`
`:code:`
`You can use + substringof(value, property) in the filter. The properties you can use for substring are: name + and resourceGroup.:code:`
`:code:`
`For example, to get all resources with 'demo' + anywhere in the name, use: $filter=substringof('demo', name):code:`
`:code:`
`You can + link more than one substringof together by adding and/or operators.:code:`
`:code:`
`You + can filter by tag names and values. For example, to filter for a tag name and value, use + $filter=tagName eq 'tag1' and tagValue eq 'Value1':code:`
`:code:`
`You can use some + properties together when filtering. The combinations you can use are: substringof and/or + resourceType, plan and plan/publisher and plan/name, identity and identity/principalId. + :type filter: str + :param expand: Comma-separated list of additional properties to be included in the response. + Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, + ``$expand=createdTime,changedTime``. + :type expand: str + :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 ResourceListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ResourceListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources'} # type: ignore + + async def _move_resources_initial( + self, + source_resource_group_name: str, + resources: Optional[List[str]] = None, + target_resource_group: Optional[str] = None, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.ResourcesMoveInfo(resources=resources, target_resource_group=target_resource_group) + api_version = "2019-07-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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + + # Construct and send request + 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 + + if response.status_code not in [202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore + + async def move_resources( + self, + source_resource_group_name: str, + resources: Optional[List[str]] = None, + target_resource_group: Optional[str] = None, + **kwargs + ) -> None: + """The resources to move must be in the same source resource group. The target resource group may be in a different subscription. When moving resources, both the source group and the target group are locked for the duration of the operation. Write and delete operations are blocked on the groups until the move completes. + + Moves resources from one resource group to another resource group. + + :param source_resource_group_name: The name of the resource group containing the resources to + move. + :type source_resource_group_name: str + :param resources: The IDs of the resources. + :type resources: list[str] + :param target_resource_group: The target resource group. + :type target_resource_group: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._move_resources_initial( + source_resource_group_name=source_resource_group_name, + resources=resources, + target_resource_group=target_resource_group, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore + + async def _validate_move_resources_initial( + self, + source_resource_group_name: str, + resources: Optional[List[str]] = None, + target_resource_group: Optional[str] = None, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.ResourcesMoveInfo(resources=resources, target_resource_group=target_resource_group) + api_version = "2019-07-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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + + # Construct and send request + 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 + + if response.status_code not in [202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _validate_move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} # type: ignore + + async def validate_move_resources( + self, + source_resource_group_name: str, + resources: Optional[List[str]] = None, + target_resource_group: Optional[str] = None, + **kwargs + ) -> None: + """This operation checks whether the specified resources can be moved to the target. The resources to move must be in the same source resource group. The target resource group may be in a different subscription. If validation succeeds, it returns HTTP response code 204 (no content). If validation fails, it returns HTTP response code 409 (Conflict) with an error message. Retrieve the URL in the Location header value to check the result of the long-running operation. + + Validates whether resources can be moved from one resource group to another resource group. + + :param source_resource_group_name: The name of the resource group containing the resources to + validate for move. + :type source_resource_group_name: str + :param resources: The IDs of the resources. + :type resources: list[str] + :param target_resource_group: The target resource group. + :type target_resource_group: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._validate_move_resources_initial( + source_resource_group_name=source_resource_group_name, + resources=resources, + target_resource_group=target_resource_group, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + validate_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} # type: ignore + + def list( + self, + filter: Optional[str] = None, + expand: Optional[str] = None, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.ResourceListResult"]: + """Get all the resources in a subscription. + + :param filter: The filter to apply on the operation.:code:`
`:code:`
`The properties you + can use for eq (equals) or ne (not equals) are: location, resourceType, name, resourceGroup, + identity, identity/principalId, plan, plan/publisher, plan/product, plan/name, plan/version, + and plan/promotionCode.:code:`
`:code:`
`For example, to filter by a resource type, use: + $filter=resourceType eq 'Microsoft.Network/virtualNetworks':code:`
`:code:`
`You can use + substringof(value, property) in the filter. The properties you can use for substring are: name + and resourceGroup.:code:`
`:code:`
`For example, to get all resources with 'demo' + anywhere in the name, use: $filter=substringof('demo', name):code:`
`:code:`
`You can + link more than one substringof together by adding and/or operators.:code:`
`:code:`
`You + can filter by tag names and values. For example, to filter for a tag name and value, use + $filter=tagName eq 'tag1' and tagValue eq 'Value1':code:`
`:code:`
`You can use some + properties together when filtering. The combinations you can use are: substringof and/or + resourceType, plan and plan/publisher and plan/name, identity and identity/principalId. + :type filter: str + :param expand: Comma-separated list of additional properties to be included in the response. + Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, + ``$expand=createdTime,changedTime``. + :type expand: str + :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 ResourceListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ResourceListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resources'} # type: ignore + + async def check_existence( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + **kwargs + ) -> None: + """Checks whether a resource exists. + + :param resource_group_name: The name of the resource group containing the resource to check. + The name is case insensitive. + :type resource_group_name: str + :param resource_provider_namespace: The resource provider of the resource to check. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. + :type parent_resource_path: str + :param resource_type: The resource type. + :type resource_type: str + :param resource_name: The name of the resource to check whether it exists. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-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\._\(\)]+$'), + 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), + 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_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] + + # Construct and send request + 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 + + if response.status_code not in [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + 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, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-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\._\(\)]+$'), + 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), + 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + async def delete( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + **kwargs + ) -> None: + """Deletes a resource. + + :param resource_group_name: The name of the resource group that contains the resource to + delete. The name is case insensitive. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. + :type parent_resource_path: str + :param resource_type: The resource type. + :type resource_type: str + :param resource_name: The name of the resource to delete. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._delete_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, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + parameters: "models.GenericResource", + **kwargs + ) -> "models.GenericResource": + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + content_type = kwargs.pop("content_type", "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'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 201, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('GenericResource', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + async def create_or_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + parameters: "models.GenericResource", + **kwargs + ) -> "models.GenericResource": + """Creates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to create. + :type resource_type: str + :param resource_name: The name of the resource to create. + :type resource_name: str + :param parameters: Parameters for creating or updating the resource. + :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 polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: GenericResource + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._create_or_update_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, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + 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, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + parameters: "models.GenericResource", + **kwargs + ) -> "models.GenericResource": + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + content_type = kwargs.pop("content_type", "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'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + async def update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + parameters: "models.GenericResource", + **kwargs + ) -> "models.GenericResource": + """Updates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to update. + :type resource_type: str + :param resource_name: The name of the resource to update. + :type resource_name: str + :param parameters: Parameters for updating the resource. + :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 polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: GenericResource + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._update_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, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + async def get( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + **kwargs + ) -> "models.GenericResource": + """Gets a resource. + + :param resource_group_name: The name of the resource group containing the resource to get. The + name is case insensitive. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. + :type parent_resource_path: str + :param resource_type: The resource type of the resource. + :type resource_type: str + :param resource_name: The name of the resource to get. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GenericResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + + # Construct URL + url = self.get.metadata['url'] # type: 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + async def check_existence_by_id( + self, + resource_id: str, + **kwargs + ) -> None: + """Checks by ID whether a resource exists. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + :type resource_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + + # 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] + + # Construct and send request + 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 + + if response.status_code not in [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + 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, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + + # 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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + async def delete_by_id( + self, + resource_id: str, + **kwargs + ) -> None: + """Deletes a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + :type resource_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._delete_by_id_initial( + resource_id=resource_id, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + delete_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + + async def _create_or_update_by_id_initial( + self, + resource_id: str, + parameters: "models.GenericResource", + **kwargs + ) -> "models.GenericResource": + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + content_type = kwargs.pop("content_type", "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) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 201, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('GenericResource', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + async def create_or_update_by_id( + self, + resource_id: str, + parameters: "models.GenericResource", + **kwargs + ) -> "models.GenericResource": + """Create a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + :type resource_id: str + :param parameters: Create or update resource parameters. + :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 polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: GenericResource + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._create_or_update_by_id_initial( + resource_id=resource_id, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + create_or_update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + + async def _update_by_id_initial( + self, + resource_id: str, + parameters: "models.GenericResource", + **kwargs + ) -> "models.GenericResource": + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + content_type = kwargs.pop("content_type", "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) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + async def update_by_id( + self, + resource_id: str, + parameters: "models.GenericResource", + **kwargs + ) -> "models.GenericResource": + """Updates a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + :type resource_id: str + :param parameters: Update resource parameters. + :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 polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: GenericResource + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._update_by_id_initial( + resource_id=resource_id, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + + async def get_by_id( + self, + resource_id: str, + **kwargs + ) -> "models.GenericResource": + """Gets a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + :type resource_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GenericResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + 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_async/_tags_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/operations_async/_tags_operations_async.py new file mode 100644 index 000000000000..48af63d0293a --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/aio/operations_async/_tags_operations_async.py @@ -0,0 +1,327 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import 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 ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class TagsOperations: + """TagsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2019_07_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def delete_value( + self, + tag_name: str, + tag_value: str, + **kwargs + ) -> None: + """Deletes a tag value. + + :param tag_name: The name of the tag. + :type tag_name: str + :param tag_value: The value of the tag to delete. + :type tag_value: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore + + async def create_or_update_value( + self, + tag_name: str, + tag_value: str, + **kwargs + ) -> "models.TagValue": + """Creates a tag value. The name of the tag must already exist. + + :param tag_name: The name of the tag. + :type tag_name: str + :param tag_value: The value of the tag to create. + :type tag_value: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagValue or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.TagValue + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TagValue"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + + # 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'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('TagValue', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('TagValue', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore + + async def create_or_update( + self, + tag_name: str, + **kwargs + ) -> "models.TagDetails": + """The tag name can have a maximum of 512 characters and is case insensitive. Tag names created by Azure have prefixes of microsoft, azure, or windows. You cannot create tags with one of these prefixes. + + Creates a tag in the subscription. + + :param tag_name: The name of the tag to create. + :type tag_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagDetails or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.TagDetails + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TagDetails"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + + # 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'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('TagDetails', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('TagDetails', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore + + async def delete( + self, + tag_name: str, + **kwargs + ) -> None: + """You must remove all values from a resource tag before you can delete it. + + Deletes a tag from the subscription. + + :param tag_name: The name of the tag. + :type tag_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore + + def list( + self, + **kwargs + ) -> AsyncIterable["models.TagsListResult"]: + """Gets the names and values of all resource tags that are defined in a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of TagsListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('TagsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/models/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/models/__init__.py index 2f02c0c85ca9..7870a791c7fd 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/models/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/models/__init__.py @@ -1,26 +1,26 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- try: from ._models_py3 import AliasPathType from ._models_py3 import AliasType from ._models_py3 import BasicDependency + from ._models_py3 import ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties from ._models_py3 import DebugSetting from ._models_py3 import Dependency from ._models_py3 import Deployment from ._models_py3 import DeploymentExportResult from ._models_py3 import DeploymentExtended from ._models_py3 import DeploymentExtendedFilter + from ._models_py3 import DeploymentListResult from ._models_py3 import DeploymentOperation from ._models_py3 import DeploymentOperationProperties + from ._models_py3 import DeploymentOperationsListResult from ._models_py3 import DeploymentProperties from ._models_py3 import DeploymentPropertiesExtended from ._models_py3 import DeploymentValidateResult @@ -35,21 +35,24 @@ from ._models_py3 import GenericResourceFilter from ._models_py3 import HttpMessage from ._models_py3 import Identity - from ._models_py3 import IdentityUserAssignedIdentitiesValue from ._models_py3 import OnErrorDeployment from ._models_py3 import OnErrorDeploymentExtended from ._models_py3 import Operation from ._models_py3 import OperationDisplay + from ._models_py3 import OperationListResult from ._models_py3 import ParametersLink from ._models_py3 import Plan from ._models_py3 import Provider + from ._models_py3 import ProviderListResult from ._models_py3 import ProviderResourceType from ._models_py3 import Resource from ._models_py3 import ResourceGroup from ._models_py3 import ResourceGroupExportResult from ._models_py3 import ResourceGroupFilter + from ._models_py3 import ResourceGroupListResult from ._models_py3 import ResourceGroupPatchable from ._models_py3 import ResourceGroupProperties + from ._models_py3 import ResourceListResult from ._models_py3 import ResourceProviderOperationDisplayProperties from ._models_py3 import ResourcesMoveInfo from ._models_py3 import Sku @@ -57,6 +60,7 @@ from ._models_py3 import TagCount from ._models_py3 import TagDetails from ._models_py3 import TagValue + from ._models_py3 import TagsListResult from ._models_py3 import TargetResource from ._models_py3 import TemplateHashResult from ._models_py3 import TemplateLink @@ -64,87 +68,91 @@ from ._models_py3 import WhatIfOperationResult from ._models_py3 import WhatIfPropertyChange except (SyntaxError, ImportError): - from ._models import AliasPathType - from ._models import AliasType - from ._models import BasicDependency - from ._models import DebugSetting - from ._models import Dependency - from ._models import Deployment - from ._models import DeploymentExportResult - from ._models import DeploymentExtended - from ._models import DeploymentExtendedFilter - from ._models import DeploymentOperation - from ._models import DeploymentOperationProperties - from ._models import DeploymentProperties - from ._models import DeploymentPropertiesExtended - from ._models import DeploymentValidateResult - from ._models import DeploymentWhatIf - from ._models import DeploymentWhatIfProperties - from ._models import DeploymentWhatIfSettings - from ._models import ErrorAdditionalInfo - from ._models import ErrorResponse - from ._models import ExportTemplateRequest - from ._models import GenericResource - from ._models import GenericResourceExpanded - from ._models import GenericResourceFilter - from ._models import HttpMessage - from ._models import Identity - from ._models import IdentityUserAssignedIdentitiesValue - from ._models import OnErrorDeployment - from ._models import OnErrorDeploymentExtended - from ._models import Operation - from ._models import OperationDisplay - from ._models import ParametersLink - from ._models import Plan - from ._models import Provider - from ._models import ProviderResourceType - from ._models import Resource - from ._models import ResourceGroup - from ._models import ResourceGroupExportResult - from ._models import ResourceGroupFilter - from ._models import ResourceGroupPatchable - from ._models import ResourceGroupProperties - from ._models import ResourceProviderOperationDisplayProperties - from ._models import ResourcesMoveInfo - from ._models import Sku - from ._models import SubResource - from ._models import TagCount - from ._models import TagDetails - from ._models import TagValue - from ._models import TargetResource - from ._models import TemplateHashResult - from ._models import TemplateLink - from ._models import WhatIfChange - from ._models import WhatIfOperationResult - from ._models import WhatIfPropertyChange -from ._paged_models import DeploymentExtendedPaged -from ._paged_models import DeploymentOperationPaged -from ._paged_models import GenericResourceExpandedPaged -from ._paged_models import OperationPaged -from ._paged_models import ProviderPaged -from ._paged_models import ResourceGroupPaged -from ._paged_models import TagDetailsPaged + from ._models import AliasPathType # type: ignore + from ._models import AliasType # type: ignore + from ._models import BasicDependency # type: ignore + from ._models import ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties # type: ignore + from ._models import DebugSetting # type: ignore + from ._models import Dependency # type: ignore + from ._models import Deployment # type: ignore + from ._models import DeploymentExportResult # type: ignore + from ._models import DeploymentExtended # type: ignore + from ._models import DeploymentExtendedFilter # type: ignore + from ._models import DeploymentListResult # type: ignore + from ._models import DeploymentOperation # type: ignore + from ._models import DeploymentOperationProperties # type: ignore + from ._models import DeploymentOperationsListResult # type: ignore + from ._models import DeploymentProperties # type: ignore + from ._models import DeploymentPropertiesExtended # type: ignore + from ._models import DeploymentValidateResult # type: ignore + from ._models import DeploymentWhatIf # type: ignore + from ._models import DeploymentWhatIfProperties # type: ignore + from ._models import DeploymentWhatIfSettings # type: ignore + from ._models import ErrorAdditionalInfo # type: ignore + from ._models import ErrorResponse # type: ignore + from ._models import ExportTemplateRequest # type: ignore + from ._models import GenericResource # type: ignore + from ._models import GenericResourceExpanded # type: ignore + from ._models import GenericResourceFilter # type: ignore + from ._models import HttpMessage # type: ignore + from ._models import Identity # type: ignore + from ._models import OnErrorDeployment # type: ignore + from ._models import OnErrorDeploymentExtended # type: ignore + from ._models import Operation # type: ignore + from ._models import OperationDisplay # type: ignore + from ._models import OperationListResult # type: ignore + from ._models import ParametersLink # type: ignore + from ._models import Plan # type: ignore + from ._models import Provider # type: ignore + from ._models import ProviderListResult # type: ignore + from ._models import ProviderResourceType # type: ignore + from ._models import Resource # type: ignore + from ._models import ResourceGroup # type: ignore + from ._models import ResourceGroupExportResult # type: ignore + from ._models import ResourceGroupFilter # type: ignore + from ._models import ResourceGroupListResult # type: ignore + from ._models import ResourceGroupPatchable # type: ignore + from ._models import ResourceGroupProperties # type: ignore + from ._models import ResourceListResult # type: ignore + from ._models import ResourceProviderOperationDisplayProperties # type: ignore + from ._models import ResourcesMoveInfo # type: ignore + from ._models import Sku # type: ignore + from ._models import SubResource # type: ignore + from ._models import TagCount # type: ignore + from ._models import TagDetails # type: ignore + from ._models import TagValue # type: ignore + from ._models import TagsListResult # type: ignore + from ._models import TargetResource # type: ignore + from ._models import TemplateHashResult # type: ignore + from ._models import TemplateLink # type: ignore + from ._models import WhatIfChange # type: ignore + from ._models import WhatIfOperationResult # type: ignore + from ._models import WhatIfPropertyChange # type: ignore + from ._resource_management_client_enums import ( + ChangeType, DeploymentMode, OnErrorDeploymentType, - WhatIfResultFormat, - ResourceIdentityType, PropertyChangeType, - ChangeType, + ResourceIdentityType, + WhatIfResultFormat, ) __all__ = [ 'AliasPathType', 'AliasType', 'BasicDependency', + 'ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties', 'DebugSetting', 'Dependency', 'Deployment', 'DeploymentExportResult', 'DeploymentExtended', 'DeploymentExtendedFilter', + 'DeploymentListResult', 'DeploymentOperation', 'DeploymentOperationProperties', + 'DeploymentOperationsListResult', 'DeploymentProperties', 'DeploymentPropertiesExtended', 'DeploymentValidateResult', @@ -159,21 +167,24 @@ 'GenericResourceFilter', 'HttpMessage', 'Identity', - 'IdentityUserAssignedIdentitiesValue', 'OnErrorDeployment', 'OnErrorDeploymentExtended', 'Operation', 'OperationDisplay', + 'OperationListResult', 'ParametersLink', 'Plan', 'Provider', + 'ProviderListResult', 'ProviderResourceType', 'Resource', 'ResourceGroup', 'ResourceGroupExportResult', 'ResourceGroupFilter', + 'ResourceGroupListResult', 'ResourceGroupPatchable', 'ResourceGroupProperties', + 'ResourceListResult', 'ResourceProviderOperationDisplayProperties', 'ResourcesMoveInfo', 'Sku', @@ -181,23 +192,17 @@ 'TagCount', 'TagDetails', 'TagValue', + 'TagsListResult', 'TargetResource', 'TemplateHashResult', 'TemplateLink', 'WhatIfChange', 'WhatIfOperationResult', 'WhatIfPropertyChange', - 'OperationPaged', - 'DeploymentExtendedPaged', - 'ProviderPaged', - 'GenericResourceExpandedPaged', - 'ResourceGroupPaged', - 'TagDetailsPaged', - 'DeploymentOperationPaged', + 'ChangeType', 'DeploymentMode', 'OnErrorDeploymentType', - 'WhatIfResultFormat', - 'ResourceIdentityType', 'PropertyChangeType', - 'ChangeType', + 'ResourceIdentityType', + 'WhatIfResultFormat', ] 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 a90e7c58d108..f148c36a7ca0 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 @@ -1,20 +1,16 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.serialization import Model -from msrest.exceptions import HttpOperationError +import msrest.serialization -class AliasPathType(Model): - """The type of the paths for alias. . +class AliasPathType(msrest.serialization.Model): + """The type of the paths for alias. :param path: The path of an alias. :type path: str @@ -27,20 +23,22 @@ class AliasPathType(Model): 'api_versions': {'key': 'apiVersions', 'type': '[str]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(AliasPathType, self).__init__(**kwargs) self.path = kwargs.get('path', None) self.api_versions = kwargs.get('api_versions', None) -class AliasType(Model): - """The alias type. . +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] + :type paths: list[~azure.mgmt.resource.resources.v2019_07_01.models.AliasPathType] """ _attribute_map = { @@ -48,13 +46,16 @@ class AliasType(Model): 'paths': {'key': 'paths', 'type': '[AliasPathType]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(AliasType, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.paths = kwargs.get('paths', None) -class BasicDependency(Model): +class BasicDependency(msrest.serialization.Model): """Deployment dependency information. :param id: The ID of the dependency. @@ -71,52 +72,55 @@ class BasicDependency(Model): 'resource_name': {'key': 'resourceName', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(BasicDependency, self).__init__(**kwargs) self.id = kwargs.get('id', None) self.resource_type = kwargs.get('resource_type', None) self.resource_name = kwargs.get('resource_name', None) -class CloudError(Model): - """An error response for a resource management request. +class ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties(msrest.serialization.Model): + """ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties. - :param error: - :type error: - ~azure.mgmt.resource.resources.v2019_07_01.models.ErrorResponse + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar principal_id: The principal id of user assigned identity. + :vartype principal_id: str + :ivar client_id: The client id of user assigned identity. + :vartype client_id: str """ - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorResponse'}, + _validation = { + 'principal_id': {'readonly': True}, + 'client_id': {'readonly': True}, } - def __init__(self, **kwargs): - super(CloudError, self).__init__(**kwargs) - self.error = kwargs.get('error', None) - - -class CloudErrorException(HttpOperationError): - """Server responsed with exception of type: 'CloudError'. - - :param deserialize: A deserializer - :param response: Server response to be deserialized. - """ - - def __init__(self, deserialize, response, *args): + _attribute_map = { + 'principal_id': {'key': 'principalId', 'type': 'str'}, + 'client_id': {'key': 'clientId', 'type': 'str'}, + } - super(CloudErrorException, self).__init__(deserialize, response, 'CloudError', *args) + def __init__( + self, + **kwargs + ): + super(ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties, self).__init__(**kwargs) + self.principal_id = None + self.client_id = None -class DebugSetting(Model): +class DebugSetting(msrest.serialization.Model): """The debug setting. - :param 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. + :param 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 """ @@ -124,17 +128,19 @@ class DebugSetting(Model): 'detail_level': {'key': 'detailLevel', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DebugSetting, self).__init__(**kwargs) self.detail_level = kwargs.get('detail_level', None) -class Dependency(Model): +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] + :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. @@ -150,7 +156,10 @@ class Dependency(Model): 'resource_name': {'key': 'resourceName', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Dependency, self).__init__(**kwargs) self.depends_on = kwargs.get('depends_on', None) self.id = kwargs.get('id', None) @@ -158,7 +167,7 @@ def __init__(self, **kwargs): self.resource_name = kwargs.get('resource_name', None) -class Deployment(Model): +class Deployment(msrest.serialization.Model): """Deployment operation parameters. All required parameters must be populated in order to send to Azure. @@ -166,8 +175,7 @@ class Deployment(Model): :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 + :type properties: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentProperties """ _validation = { @@ -179,14 +187,17 @@ class Deployment(Model): 'properties': {'key': 'properties', 'type': 'DeploymentProperties'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Deployment, self).__init__(**kwargs) self.location = kwargs.get('location', None) - self.properties = kwargs.get('properties', None) + self.properties = kwargs['properties'] -class DeploymentExportResult(Model): - """The deployment export result. . +class DeploymentExportResult(msrest.serialization.Model): + """The deployment export result. :param template: The template content. :type template: object @@ -196,16 +207,18 @@ class DeploymentExportResult(Model): 'template': {'key': 'template', 'type': 'object'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentExportResult, self).__init__(**kwargs) self.template = kwargs.get('template', None) -class DeploymentExtended(Model): +class DeploymentExtended(msrest.serialization.Model): """Deployment information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The ID of the deployment. :vartype id: str @@ -234,7 +247,10 @@ class DeploymentExtended(Model): 'properties': {'key': 'properties', 'type': 'DeploymentPropertiesExtended'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentExtended, self).__init__(**kwargs) self.id = None self.name = None @@ -243,7 +259,7 @@ def __init__(self, **kwargs): self.properties = kwargs.get('properties', None) -class DeploymentExtendedFilter(Model): +class DeploymentExtendedFilter(msrest.serialization.Model): """Deployment filter. :param provisioning_state: The provisioning state. @@ -254,16 +270,47 @@ class DeploymentExtendedFilter(Model): 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentExtendedFilter, self).__init__(**kwargs) self.provisioning_state = kwargs.get('provisioning_state', None) -class DeploymentOperation(Model): +class DeploymentListResult(msrest.serialization.Model): + """List of deployments. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[DeploymentExtended]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(DeploymentListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = None + + +class DeploymentOperation(msrest.serialization.Model): """Deployment operation information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Full deployment operation ID. :vartype id: str @@ -285,23 +332,25 @@ class DeploymentOperation(Model): 'properties': {'key': 'properties', 'type': 'DeploymentOperationProperties'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentOperation, self).__init__(**kwargs) self.id = None self.operation_id = None self.properties = kwargs.get('properties', None) -class DeploymentOperationProperties(Model): +class DeploymentOperationProperties(msrest.serialization.Model): """Deployment operation properties. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar provisioning_state: The state of the provisioning. :vartype provisioning_state: str :ivar timestamp: The date and time of the operation. - :vartype timestamp: datetime + :vartype timestamp: ~datetime.datetime :ivar duration: The duration of the operation. :vartype duration: str :ivar service_request_id: Deployment operation service request id. @@ -311,14 +360,11 @@ class DeploymentOperationProperties(Model): :ivar status_message: Operation status message. :vartype status_message: object :ivar target_resource: The target resource. - :vartype target_resource: - ~azure.mgmt.resource.resources.v2019_07_01.models.TargetResource + :vartype target_resource: ~azure.mgmt.resource.resources.v2019_07_01.models.TargetResource :ivar request: The HTTP request message. - :vartype request: - ~azure.mgmt.resource.resources.v2019_07_01.models.HttpMessage + :vartype request: ~azure.mgmt.resource.resources.v2019_07_01.models.HttpMessage :ivar response: The HTTP response message. - :vartype response: - ~azure.mgmt.resource.resources.v2019_07_01.models.HttpMessage + :vartype response: ~azure.mgmt.resource.resources.v2019_07_01.models.HttpMessage """ _validation = { @@ -345,7 +391,10 @@ class DeploymentOperationProperties(Model): 'response': {'key': 'response', 'type': 'HttpMessage'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentOperationProperties, self).__init__(**kwargs) self.provisioning_state = None self.timestamp = None @@ -358,48 +407,68 @@ def __init__(self, **kwargs): self.response = None -class DeploymentProperties(Model): +class DeploymentOperationsListResult(msrest.serialization.Model): + """List of deployment operations. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[DeploymentOperation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(DeploymentOperationsListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = None + + +class DeploymentProperties(msrest.serialization.Model): """Deployment properties. 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 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. + :param 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: object - :param 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. 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. + :param 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. + 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: object - :param 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 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 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 + 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 + :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 + :type on_error_deployment: ~azure.mgmt.resource.resources.v2019_07_01.models.OnErrorDeployment """ _validation = { @@ -411,66 +480,59 @@ class DeploymentProperties(Model): 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, 'parameters': {'key': 'parameters', 'type': 'object'}, 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, - 'mode': {'key': 'mode', 'type': 'DeploymentMode'}, + 'mode': {'key': 'mode', 'type': 'str'}, 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, 'on_error_deployment': {'key': 'onErrorDeployment', 'type': 'OnErrorDeployment'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentProperties, self).__init__(**kwargs) self.template = kwargs.get('template', None) self.template_link = kwargs.get('template_link', None) self.parameters = kwargs.get('parameters', None) self.parameters_link = kwargs.get('parameters_link', None) - self.mode = kwargs.get('mode', None) + self.mode = kwargs['mode'] self.debug_setting = kwargs.get('debug_setting', None) self.on_error_deployment = kwargs.get('on_error_deployment', None) -class DeploymentPropertiesExtended(Model): +class DeploymentPropertiesExtended(msrest.serialization.Model): """Deployment properties with additional details. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :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 + :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: object - :param providers: The list of resource providers needed for the - deployment. - :type providers: - list[~azure.mgmt.resource.resources.v2019_07_01.models.Provider] + :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 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: object - :param 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. + :param 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: object - :param 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 include: 'Incremental', 'Complete' - :type mode: str or - ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentMode + :param 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 + 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 + :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.OnErrorDeploymentExtended @@ -495,12 +557,15 @@ class DeploymentPropertiesExtended(Model): 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, 'parameters': {'key': 'parameters', 'type': 'object'}, 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, - 'mode': {'key': 'mode', 'type': 'DeploymentMode'}, + 'mode': {'key': 'mode', 'type': 'str'}, 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, 'on_error_deployment': {'key': 'onErrorDeployment', 'type': 'OnErrorDeploymentExtended'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentPropertiesExtended, self).__init__(**kwargs) self.provisioning_state = None self.correlation_id = None @@ -518,12 +583,11 @@ def __init__(self, **kwargs): self.on_error_deployment = kwargs.get('on_error_deployment', None) -class DeploymentValidateResult(Model): +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 + :type error: ~azure.mgmt.resource.resources.v2019_07_01.models.ErrorResponse :param properties: The template deployment properties. :type properties: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentPropertiesExtended @@ -534,13 +598,16 @@ class DeploymentValidateResult(Model): 'properties': {'key': 'properties', 'type': 'DeploymentPropertiesExtended'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentValidateResult, self).__init__(**kwargs) self.error = kwargs.get('error', None) self.properties = kwargs.get('properties', None) -class DeploymentWhatIf(Model): +class DeploymentWhatIf(msrest.serialization.Model): """Deployment What-if operation parameters. All required parameters must be populated in order to send to Azure. @@ -548,8 +615,7 @@ class DeploymentWhatIf(Model): :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 + :type properties: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentWhatIfProperties """ _validation = { @@ -561,10 +627,13 @@ class DeploymentWhatIf(Model): 'properties': {'key': 'properties', 'type': 'DeploymentWhatIfProperties'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentWhatIf, self).__init__(**kwargs) self.location = kwargs.get('location', None) - self.properties = kwargs.get('properties', None) + self.properties = kwargs['properties'] class DeploymentWhatIfProperties(DeploymentProperties): @@ -572,43 +641,34 @@ 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 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. + :param 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: object - :param 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. 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. + :param 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. + 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: object - :param 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 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 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 + 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 + :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 + :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: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentWhatIfSettings @@ -623,40 +683,45 @@ class DeploymentWhatIfProperties(DeploymentProperties): 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, 'parameters': {'key': 'parameters', 'type': 'object'}, 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, - 'mode': {'key': 'mode', 'type': 'DeploymentMode'}, + 'mode': {'key': 'mode', 'type': 'str'}, 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, 'on_error_deployment': {'key': 'onErrorDeployment', 'type': 'OnErrorDeployment'}, 'what_if_settings': {'key': 'whatIfSettings', 'type': 'DeploymentWhatIfSettings'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentWhatIfProperties, self).__init__(**kwargs) self.what_if_settings = kwargs.get('what_if_settings', None) -class DeploymentWhatIfSettings(Model): +class DeploymentWhatIfSettings(msrest.serialization.Model): """Deployment What-If operation settings. - :param result_format: The format of the What-If results. Possible values - include: 'ResourceIdOnly', 'FullResourcePayloads' + :param result_format: The format of the What-If results. Possible values include: + "ResourceIdOnly", "FullResourcePayloads". :type result_format: str or ~azure.mgmt.resource.resources.v2019_07_01.models.WhatIfResultFormat """ _attribute_map = { - 'result_format': {'key': 'resultFormat', 'type': 'WhatIfResultFormat'}, + 'result_format': {'key': 'resultFormat', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentWhatIfSettings, self).__init__(**kwargs) self.result_format = kwargs.get('result_format', None) -class ErrorAdditionalInfo(Model): +class ErrorAdditionalInfo(msrest.serialization.Model): """The resource management error additional info. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar type: The additional info type. :vartype type: str @@ -674,17 +739,19 @@ class ErrorAdditionalInfo(Model): 'info': {'key': 'info', 'type': 'object'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None -class ErrorResponse(Model): +class ErrorResponse(msrest.serialization.Model): """The resource management error response. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar code: The error code. :vartype code: str @@ -693,8 +760,7 @@ class ErrorResponse(Model): :ivar target: The error target. :vartype target: str :ivar details: The error details. - :vartype details: - list[~azure.mgmt.resource.resources.v2019_07_01.models.ErrorResponse] + :vartype details: list[~azure.mgmt.resource.resources.v2019_07_01.models.ErrorResponse] :ivar additional_info: The error additional info. :vartype additional_info: list[~azure.mgmt.resource.resources.v2019_07_01.models.ErrorAdditionalInfo] @@ -716,7 +782,10 @@ class ErrorResponse(Model): 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ErrorResponse, self).__init__(**kwargs) self.code = None self.message = None @@ -725,16 +794,15 @@ def __init__(self, **kwargs): self.additional_info = None -class ExportTemplateRequest(Model): +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, supply an array with single entry '*'. + :param 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', 'SkipResourceNameParameterization', - 'SkipAllParameterization' + :param options: The export template options. A CSV-formatted list containing zero or more of + the following: 'IncludeParameterDefaultValue', 'IncludeComments', + 'SkipResourceNameParameterization', 'SkipAllParameterization'. :type options: str """ @@ -743,27 +811,29 @@ class ExportTemplateRequest(Model): 'options': {'key': 'options', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ExportTemplateRequest, self).__init__(**kwargs) self.resources = kwargs.get('resources', None) self.options = kwargs.get('options', None) -class Resource(Model): +class Resource(msrest.serialization.Model): """Specified resource. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID + :ivar id: Resource ID. :vartype id: str - :ivar name: Resource name + :ivar name: Resource name. :vartype name: str - :ivar type: Resource type + :ivar type: Resource type. :vartype type: str - :param location: Resource location + :param location: Resource location. :type location: str - :param tags: Resource tags + :param tags: A set of tags. Resource tags. :type tags: dict[str, str] """ @@ -781,7 +851,10 @@ class Resource(Model): 'tags': {'key': 'tags', 'type': '{str}'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -793,18 +866,17 @@ def __init__(self, **kwargs): class GenericResource(Resource): """Resource information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID + :ivar id: Resource ID. :vartype id: str - :ivar name: Resource name + :ivar name: Resource name. :vartype name: str - :ivar type: Resource type + :ivar type: Resource type. :vartype type: str - :param location: Resource location + :param location: Resource location. :type location: str - :param tags: Resource tags + :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 @@ -841,7 +913,10 @@ class GenericResource(Resource): 'identity': {'key': 'identity', 'type': 'Identity'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(GenericResource, self).__init__(**kwargs) self.plan = kwargs.get('plan', None) self.properties = kwargs.get('properties', None) @@ -854,18 +929,17 @@ def __init__(self, **kwargs): class GenericResourceExpanded(GenericResource): """Resource information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID + :ivar id: Resource ID. :vartype id: str - :ivar name: Resource name + :ivar name: Resource name. :vartype name: str - :ivar type: Resource type + :ivar type: Resource type. :vartype type: str - :param location: Resource location + :param location: Resource location. :type location: str - :param tags: Resource tags + :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 @@ -879,14 +953,14 @@ class GenericResourceExpanded(GenericResource): :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 created_time: The created time of the resource. This is only present - if requested via the $expand query parameter. - :vartype created_time: datetime - :ivar changed_time: The changed time of the resource. This is only present - if requested via the $expand query parameter. - :vartype changed_time: datetime - :ivar provisioning_state: The provisioning state of the resource. This is - only present if requested via the $expand query parameter. + :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 + :ivar changed_time: The changed time of the resource. This is only present if requested via the + $expand query parameter. + :vartype changed_time: ~datetime.datetime + :ivar provisioning_state: The provisioning state of the resource. This is only present if + requested via the $expand query parameter. :vartype provisioning_state: str """ @@ -917,14 +991,17 @@ class GenericResourceExpanded(GenericResource): 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(GenericResourceExpanded, self).__init__(**kwargs) self.created_time = None self.changed_time = None self.provisioning_state = None -class GenericResourceFilter(Model): +class GenericResourceFilter(msrest.serialization.Model): """Resource filter. :param resource_type: The resource type. @@ -941,14 +1018,17 @@ class GenericResourceFilter(Model): 'tagvalue': {'key': 'tagvalue', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(GenericResourceFilter, self).__init__(**kwargs) self.resource_type = kwargs.get('resource_type', None) self.tagname = kwargs.get('tagname', None) self.tagvalue = kwargs.get('tagvalue', None) -class HttpMessage(Model): +class HttpMessage(msrest.serialization.Model): """HTTP message. :param content: HTTP message content. @@ -959,31 +1039,31 @@ class HttpMessage(Model): 'content': {'key': 'content', 'type': 'object'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(HttpMessage, self).__init__(**kwargs) self.content = kwargs.get('content', None) -class Identity(Model): +class Identity(msrest.serialization.Model): """Identity for the resource. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar principal_id: The principal ID of resource identity. :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :param 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 user identity dictionary key references will be ARM - resource ids in the form: + :param 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 + 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, - ~azure.mgmt.resource.resources.v2019_07_01.models.IdentityUserAssignedIdentitiesValue] + ~azure.mgmt.resource.resources.v2019_07_01.models.ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties] """ _validation = { @@ -994,11 +1074,14 @@ class Identity(Model): _attribute_map = { 'principal_id': {'key': 'principalId', 'type': 'str'}, 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'ResourceIdentityType'}, - 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{IdentityUserAssignedIdentitiesValue}'}, + 'type': {'key': 'type', 'type': 'str'}, + 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties}'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Identity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None @@ -1006,71 +1089,40 @@ def __init__(self, **kwargs): self.user_assigned_identities = kwargs.get('user_assigned_identities', None) -class IdentityUserAssignedIdentitiesValue(Model): - """IdentityUserAssignedIdentitiesValue. - - Variables are only populated by the server, and will be ignored when - sending a request. - - :ivar principal_id: The principal id of user assigned identity. - :vartype principal_id: str - :ivar client_id: The client id of user assigned identity. - :vartype client_id: str - """ - - _validation = { - 'principal_id': {'readonly': True}, - 'client_id': {'readonly': True}, - } - - _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'client_id': {'key': 'clientId', 'type': 'str'}, - } - - def __init__(self, **kwargs): - super(IdentityUserAssignedIdentitiesValue, self).__init__(**kwargs) - self.principal_id = None - self.client_id = None - - -class OnErrorDeployment(Model): +class OnErrorDeployment(msrest.serialization.Model): """Deployment on error behavior. - :param 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 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 """ _attribute_map = { - 'type': {'key': 'type', 'type': 'OnErrorDeploymentType'}, + 'type': {'key': 'type', 'type': 'str'}, 'deployment_name': {'key': 'deploymentName', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(OnErrorDeployment, self).__init__(**kwargs) self.type = kwargs.get('type', None) self.deployment_name = kwargs.get('deployment_name', None) -class OnErrorDeploymentExtended(Model): +class OnErrorDeploymentExtended(msrest.serialization.Model): """Deployment on error behavior with additional details. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar provisioning_state: The state of the provisioning for the on error - deployment. + :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 SpecificDeployment. Possible values include: - 'LastSuccessful', 'SpecificDeployment' - :type type: str or - ~azure.mgmt.resource.resources.v2019_07_01.models.OnErrorDeploymentType + :param 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 """ @@ -1081,25 +1133,27 @@ class OnErrorDeploymentExtended(Model): _attribute_map = { 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'OnErrorDeploymentType'}, + 'type': {'key': 'type', 'type': 'str'}, 'deployment_name': {'key': 'deploymentName', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(OnErrorDeploymentExtended, self).__init__(**kwargs) self.provisioning_state = None self.type = kwargs.get('type', None) self.deployment_name = kwargs.get('deployment_name', None) -class Operation(Model): +class Operation(msrest.serialization.Model): """Microsoft.Resources operation. - :param name: Operation name: {provider}/{resource}/{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 + :type display: ~azure.mgmt.resource.resources.v2019_07_01.models.OperationDisplay """ _attribute_map = { @@ -1107,19 +1161,21 @@ class Operation(Model): 'display': {'key': 'display', 'type': 'OperationDisplay'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Operation, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.display = kwargs.get('display', None) -class OperationDisplay(Model): +class OperationDisplay(msrest.serialization.Model): """The object that represents the operation. - :param provider: Service provider: Microsoft.Resources + :param provider: Service provider: Microsoft.Resources. :type provider: str - :param resource: Resource on which the operation is performed: Profile, - endpoint, etc. + :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 @@ -1134,7 +1190,10 @@ class OperationDisplay(Model): 'description': {'key': 'description', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(OperationDisplay, self).__init__(**kwargs) self.provider = kwargs.get('provider', None) self.resource = kwargs.get('resource', None) @@ -1142,15 +1201,37 @@ def __init__(self, **kwargs): self.description = kwargs.get('description', None) -class ParametersLink(Model): +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 + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Operation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(OperationListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class ParametersLink(msrest.serialization.Model): """Entity representing the reference to the deployment parameters. 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. + :param content_version: If included, must match the ContentVersion in the template. :type content_version: str """ @@ -1163,13 +1244,16 @@ class ParametersLink(Model): 'content_version': {'key': 'contentVersion', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ParametersLink, self).__init__(**kwargs) - self.uri = kwargs.get('uri', None) + self.uri = kwargs['uri'] self.content_version = kwargs.get('content_version', None) -class Plan(Model): +class Plan(msrest.serialization.Model): """Plan for the resource. :param name: The plan ID. @@ -1192,7 +1276,10 @@ class Plan(Model): 'version': {'key': 'version', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Plan, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.publisher = kwargs.get('publisher', None) @@ -1201,11 +1288,10 @@ def __init__(self, **kwargs): self.version = kwargs.get('version', None) -class Provider(Model): +class Provider(msrest.serialization.Model): """Resource provider information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The provider ID. :vartype id: str @@ -1213,8 +1299,7 @@ class Provider(Model): :type 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. + :ivar registration_policy: The registration policy of the resource provider. :vartype registration_policy: str :ivar resource_types: The collection of provider resource types. :vartype resource_types: @@ -1236,7 +1321,10 @@ class Provider(Model): 'resource_types': {'key': 'resourceTypes', 'type': '[ProviderResourceType]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Provider, self).__init__(**kwargs) self.id = None self.namespace = kwargs.get('namespace', None) @@ -1245,21 +1333,47 @@ def __init__(self, **kwargs): self.resource_types = None -class ProviderResourceType(Model): +class ProviderListResult(msrest.serialization.Model): + """List of resource providers. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Provider]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ProviderListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = None + + +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. + :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] + :type aliases: list[~azure.mgmt.resource.resources.v2019_07_01.models.AliasType] :param api_versions: The API version. :type api_versions: list[str] - :param capabilities: The additional capabilities offered by this resource - type. + :param capabilities: The additional capabilities offered by this resource type. :type capabilities: str :param properties: The properties. :type properties: dict[str, str] @@ -1274,7 +1388,10 @@ class ProviderResourceType(Model): 'properties': {'key': 'properties', 'type': '{str}'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ProviderResourceType, self).__init__(**kwargs) self.resource_type = kwargs.get('resource_type', None) self.locations = kwargs.get('locations', None) @@ -1284,11 +1401,10 @@ def __init__(self, **kwargs): self.properties = kwargs.get('properties', None) -class ResourceGroup(Model): +class ResourceGroup(msrest.serialization.Model): """Resource group information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. @@ -1299,16 +1415,13 @@ class ResourceGroup(Model): :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 resource group has been created. It must be one of - the supported Azure locations. + :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 + 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. + :param managed_by: The ID of the resource that manages this resource group. :type managed_by: str - :param tags: The tags attached to the resource group. + :param tags: A set of tags. The tags attached to the resource group. :type tags: dict[str, str] """ @@ -1329,25 +1442,27 @@ class ResourceGroup(Model): 'tags': {'key': 'tags', 'type': '{str}'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ResourceGroup, self).__init__(**kwargs) self.id = None self.name = None self.type = None self.properties = kwargs.get('properties', None) - self.location = kwargs.get('location', None) + self.location = kwargs['location'] self.managed_by = kwargs.get('managed_by', None) self.tags = kwargs.get('tags', None) -class ResourceGroupExportResult(Model): +class ResourceGroupExportResult(msrest.serialization.Model): """Resource group export result. :param template: The template content. :type template: object :param error: The template export error. - :type error: - ~azure.mgmt.resource.resources.v2019_07_01.models.ErrorResponse + :type error: ~azure.mgmt.resource.resources.v2019_07_01.models.ErrorResponse """ _attribute_map = { @@ -1355,13 +1470,16 @@ class ResourceGroupExportResult(Model): 'error': {'key': 'error', 'type': 'ErrorResponse'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ResourceGroupExportResult, self).__init__(**kwargs) self.template = kwargs.get('template', None) self.error = kwargs.get('error', None) -class ResourceGroupFilter(Model): +class ResourceGroupFilter(msrest.serialization.Model): """Resource group filter. :param tag_name: The tag name. @@ -1375,24 +1493,54 @@ class ResourceGroupFilter(Model): 'tag_value': {'key': 'tagValue', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ResourceGroupFilter, self).__init__(**kwargs) self.tag_name = kwargs.get('tag_name', None) self.tag_value = kwargs.get('tag_value', None) -class ResourceGroupPatchable(Model): +class ResourceGroupListResult(msrest.serialization.Model): + """List of resource groups. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ResourceGroup]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ResourceGroupListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = None + + +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 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: The tags attached to the resource group. + :param tags: A set of tags. The tags attached to the resource group. :type tags: dict[str, str] """ @@ -1403,7 +1551,10 @@ class ResourceGroupPatchable(Model): 'tags': {'key': 'tags', 'type': '{str}'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ResourceGroupPatchable, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.properties = kwargs.get('properties', None) @@ -1411,11 +1562,10 @@ def __init__(self, **kwargs): self.tags = kwargs.get('tags', None) -class ResourceGroupProperties(Model): +class ResourceGroupProperties(msrest.serialization.Model): """The resource group properties. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar provisioning_state: The provisioning state. :vartype provisioning_state: str @@ -1429,12 +1579,44 @@ class ResourceGroupProperties(Model): 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ResourceGroupProperties, self).__init__(**kwargs) self.provisioning_state = None -class ResourceProviderOperationDisplayProperties(Model): +class ResourceListResult(msrest.serialization.Model): + """List of resource groups. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[GenericResourceExpanded]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ResourceListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = None + + +class ResourceProviderOperationDisplayProperties(msrest.serialization.Model): """Resource provider operation's display properties. :param publisher: Operation description. @@ -1457,7 +1639,10 @@ class ResourceProviderOperationDisplayProperties(Model): 'description': {'key': 'description', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ResourceProviderOperationDisplayProperties, self).__init__(**kwargs) self.publisher = kwargs.get('publisher', None) self.provider = kwargs.get('provider', None) @@ -1466,7 +1651,7 @@ def __init__(self, **kwargs): self.description = kwargs.get('description', None) -class ResourcesMoveInfo(Model): +class ResourcesMoveInfo(msrest.serialization.Model): """Parameters of move resources. :param resources: The IDs of the resources. @@ -1480,13 +1665,16 @@ class ResourcesMoveInfo(Model): 'target_resource_group': {'key': 'targetResourceGroup', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ResourcesMoveInfo, self).__init__(**kwargs) self.resources = kwargs.get('resources', None) self.target_resource_group = kwargs.get('target_resource_group', None) -class Sku(Model): +class Sku(msrest.serialization.Model): """SKU for the resource. :param name: The SKU name. @@ -1512,7 +1700,10 @@ class Sku(Model): 'capacity': {'key': 'capacity', 'type': 'int'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Sku, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.tier = kwargs.get('tier', None) @@ -1522,10 +1713,10 @@ def __init__(self, **kwargs): self.capacity = kwargs.get('capacity', None) -class SubResource(Model): +class SubResource(msrest.serialization.Model): """Sub-resource. - :param id: Resource ID + :param id: Resource ID. :type id: str """ @@ -1533,12 +1724,15 @@ class SubResource(Model): 'id': {'key': 'id', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(SubResource, self).__init__(**kwargs) self.id = kwargs.get('id', None) -class TagCount(Model): +class TagCount(msrest.serialization.Model): """Tag count. :param type: Type of count. @@ -1552,29 +1746,29 @@ class TagCount(Model): 'value': {'key': 'value', 'type': 'int'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(TagCount, self).__init__(**kwargs) self.type = kwargs.get('type', None) self.value = kwargs.get('value', None) -class TagDetails(Model): +class TagDetails(msrest.serialization.Model): """Tag details. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :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 created and has no associated resources, the value - is 0. + :param 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] + :type values: list[~azure.mgmt.resource.resources.v2019_07_01.models.TagValue] """ _validation = { @@ -1588,7 +1782,10 @@ class TagDetails(Model): 'values': {'key': 'values', 'type': '[TagValue]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(TagDetails, self).__init__(**kwargs) self.id = None self.tag_name = kwargs.get('tag_name', None) @@ -1596,11 +1793,39 @@ def __init__(self, **kwargs): self.values = kwargs.get('values', None) -class TagValue(Model): +class TagsListResult(msrest.serialization.Model): + """List of subscription tags. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[TagDetails]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(TagsListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = None + + +class TagValue(msrest.serialization.Model): """Tag information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The tag ID. :vartype id: str @@ -1620,14 +1845,17 @@ class TagValue(Model): 'count': {'key': 'count', 'type': 'TagCount'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(TagValue, self).__init__(**kwargs) self.id = None self.tag_value = kwargs.get('tag_value', None) self.count = kwargs.get('count', None) -class TargetResource(Model): +class TargetResource(msrest.serialization.Model): """Target resource. :param id: The ID of the resource. @@ -1644,16 +1872,18 @@ class TargetResource(Model): 'resource_type': {'key': 'resourceType', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(TargetResource, self).__init__(**kwargs) self.id = kwargs.get('id', None) self.resource_name = kwargs.get('resource_name', None) self.resource_type = kwargs.get('resource_type', None) -class TemplateHashResult(Model): - """Result of the request to calculate template hash. It contains a string of - minified template and its hash. +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 @@ -1666,21 +1896,23 @@ class TemplateHashResult(Model): 'template_hash': {'key': 'templateHash', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(TemplateHashResult, self).__init__(**kwargs) self.minified_template = kwargs.get('minified_template', None) self.template_hash = kwargs.get('template_hash', None) -class TemplateLink(Model): +class TemplateLink(msrest.serialization.Model): """Entity representing the reference to the template. 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. + :param content_version: If included, must match the ContentVersion in the template. :type content_version: str """ @@ -1693,33 +1925,32 @@ class TemplateLink(Model): 'content_version': {'key': 'contentVersion', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(TemplateLink, self).__init__(**kwargs) - self.uri = kwargs.get('uri', None) + self.uri = kwargs['uri'] self.content_version = kwargs.get('content_version', None) -class WhatIfChange(Model): +class WhatIfChange(msrest.serialization.Model): """Information about a single resource change predicted by What-If operation. All required parameters must be populated in order to send to Azure. - :param resource_id: Required. Resource ID + :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 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. + :param 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: object - :param after: The predicted snapshot of the resource after the deployment - is executed. + :param after: The predicted snapshot of the resource after the deployment is executed. :type after: object :param delta: The predicted changes to resource properties. - :type delta: - list[~azure.mgmt.resource.resources.v2019_07_01.models.WhatIfPropertyChange] + :type delta: list[~azure.mgmt.resource.resources.v2019_07_01.models.WhatIfPropertyChange] """ _validation = { @@ -1729,67 +1960,68 @@ class WhatIfChange(Model): _attribute_map = { 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'change_type': {'key': 'changeType', 'type': 'ChangeType'}, + 'change_type': {'key': 'changeType', 'type': 'str'}, 'before': {'key': 'before', 'type': 'object'}, 'after': {'key': 'after', 'type': 'object'}, 'delta': {'key': 'delta', 'type': '[WhatIfPropertyChange]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(WhatIfChange, self).__init__(**kwargs) - self.resource_id = kwargs.get('resource_id', None) - self.change_type = kwargs.get('change_type', None) + self.resource_id = kwargs['resource_id'] + self.change_type = kwargs['change_type'] self.before = kwargs.get('before', None) self.after = kwargs.get('after', None) self.delta = kwargs.get('delta', None) -class WhatIfOperationResult(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. +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 changes: List of resource changes predicted by What-If operation. - :type changes: - list[~azure.mgmt.resource.resources.v2019_07_01.models.WhatIfChange] :param error: Error when What-If operation fails. - :type error: - ~azure.mgmt.resource.resources.v2019_07_01.models.ErrorResponse + :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] """ _attribute_map = { 'status': {'key': 'status', 'type': 'str'}, - 'changes': {'key': 'properties.changes', 'type': '[WhatIfChange]'}, 'error': {'key': 'error', 'type': 'ErrorResponse'}, + 'changes': {'key': 'properties.changes', 'type': '[WhatIfChange]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(WhatIfOperationResult, self).__init__(**kwargs) self.status = kwargs.get('status', None) - self.changes = kwargs.get('changes', None) self.error = kwargs.get('error', None) + self.changes = kwargs.get('changes', None) -class WhatIfPropertyChange(Model): +class WhatIfPropertyChange(msrest.serialization.Model): """The predicted change to the resource property. 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: 'Create', 'Delete', 'Modify', 'Array' + :param property_change_type: Required. The type of property change. Possible values include: + "Create", "Delete", "Modify", "Array". :type 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. + :param before: The value of the property before the deployment is executed. :type before: object :param after: The value of the property after the deployment is executed. :type after: object :param children: Nested property changes. - :type children: - list[~azure.mgmt.resource.resources.v2019_07_01.models.WhatIfPropertyChange] + :type children: list[~azure.mgmt.resource.resources.v2019_07_01.models.WhatIfPropertyChange] """ _validation = { @@ -1799,16 +2031,19 @@ class WhatIfPropertyChange(Model): _attribute_map = { 'path': {'key': 'path', 'type': 'str'}, - 'property_change_type': {'key': 'propertyChangeType', 'type': 'PropertyChangeType'}, + 'property_change_type': {'key': 'propertyChangeType', 'type': 'str'}, 'before': {'key': 'before', 'type': 'object'}, 'after': {'key': 'after', 'type': 'object'}, 'children': {'key': 'children', 'type': '[WhatIfPropertyChange]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(WhatIfPropertyChange, self).__init__(**kwargs) - self.path = kwargs.get('path', None) - self.property_change_type = kwargs.get('property_change_type', None) + 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) 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 496b687ba762..e7cc866df312 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 @@ -1,20 +1,20 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.serialization import Model -from msrest.exceptions import HttpOperationError +from typing import Dict, List, Optional, Union +import msrest.serialization -class AliasPathType(Model): - """The type of the paths for alias. . +from ._resource_management_client_enums import * + + +class AliasPathType(msrest.serialization.Model): + """The type of the paths for alias. :param path: The path of an alias. :type path: str @@ -27,20 +27,25 @@ class AliasPathType(Model): 'api_versions': {'key': 'apiVersions', 'type': '[str]'}, } - def __init__(self, *, path: str=None, api_versions=None, **kwargs) -> None: + def __init__( + self, + *, + path: Optional[str] = None, + api_versions: Optional[List[str]] = None, + **kwargs + ): super(AliasPathType, self).__init__(**kwargs) self.path = path self.api_versions = api_versions -class AliasType(Model): - """The alias type. . +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] + :type paths: list[~azure.mgmt.resource.resources.v2019_07_01.models.AliasPathType] """ _attribute_map = { @@ -48,13 +53,19 @@ class AliasType(Model): 'paths': {'key': 'paths', 'type': '[AliasPathType]'}, } - def __init__(self, *, name: str=None, paths=None, **kwargs) -> None: + def __init__( + self, + *, + name: Optional[str] = None, + paths: Optional[List["AliasPathType"]] = None, + **kwargs + ): super(AliasType, self).__init__(**kwargs) self.name = name self.paths = paths -class BasicDependency(Model): +class BasicDependency(msrest.serialization.Model): """Deployment dependency information. :param id: The ID of the dependency. @@ -71,52 +82,59 @@ class BasicDependency(Model): 'resource_name': {'key': 'resourceName', 'type': 'str'}, } - def __init__(self, *, id: str=None, resource_type: str=None, resource_name: str=None, **kwargs) -> None: + def __init__( + self, + *, + id: Optional[str] = None, + resource_type: Optional[str] = None, + resource_name: Optional[str] = None, + **kwargs + ): super(BasicDependency, self).__init__(**kwargs) self.id = id self.resource_type = resource_type self.resource_name = resource_name -class CloudError(Model): - """An error response for a resource management request. +class ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties(msrest.serialization.Model): + """ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties. + + Variables are only populated by the server, and will be ignored when sending a request. - :param error: - :type error: - ~azure.mgmt.resource.resources.v2019_07_01.models.ErrorResponse + :ivar principal_id: The principal id of user assigned identity. + :vartype principal_id: str + :ivar client_id: The client id of user assigned identity. + :vartype client_id: str """ - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorResponse'}, + _validation = { + 'principal_id': {'readonly': True}, + 'client_id': {'readonly': True}, } - def __init__(self, *, error=None, **kwargs) -> None: - super(CloudError, self).__init__(**kwargs) - self.error = error - - -class CloudErrorException(HttpOperationError): - """Server responsed with exception of type: 'CloudError'. - - :param deserialize: A deserializer - :param response: Server response to be deserialized. - """ - - def __init__(self, deserialize, response, *args): + _attribute_map = { + 'principal_id': {'key': 'principalId', 'type': 'str'}, + 'client_id': {'key': 'clientId', 'type': 'str'}, + } - super(CloudErrorException, self).__init__(deserialize, response, 'CloudError', *args) + def __init__( + self, + **kwargs + ): + super(ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties, self).__init__(**kwargs) + self.principal_id = None + self.client_id = None -class DebugSetting(Model): +class DebugSetting(msrest.serialization.Model): """The debug setting. - :param 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. + :param 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 """ @@ -124,17 +142,21 @@ class DebugSetting(Model): 'detail_level': {'key': 'detailLevel', 'type': 'str'}, } - def __init__(self, *, detail_level: str=None, **kwargs) -> None: + def __init__( + self, + *, + detail_level: Optional[str] = None, + **kwargs + ): super(DebugSetting, self).__init__(**kwargs) self.detail_level = detail_level -class Dependency(Model): +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] + :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. @@ -150,7 +172,15 @@ class Dependency(Model): 'resource_name': {'key': 'resourceName', 'type': 'str'}, } - def __init__(self, *, depends_on=None, id: str=None, resource_type: str=None, resource_name: str=None, **kwargs) -> None: + def __init__( + self, + *, + depends_on: Optional[List["BasicDependency"]] = None, + id: Optional[str] = None, + resource_type: Optional[str] = None, + resource_name: Optional[str] = None, + **kwargs + ): super(Dependency, self).__init__(**kwargs) self.depends_on = depends_on self.id = id @@ -158,7 +188,7 @@ def __init__(self, *, depends_on=None, id: str=None, resource_type: str=None, re self.resource_name = resource_name -class Deployment(Model): +class Deployment(msrest.serialization.Model): """Deployment operation parameters. All required parameters must be populated in order to send to Azure. @@ -166,8 +196,7 @@ class Deployment(Model): :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 + :type properties: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentProperties """ _validation = { @@ -179,14 +208,20 @@ class Deployment(Model): 'properties': {'key': 'properties', 'type': 'DeploymentProperties'}, } - def __init__(self, *, properties, location: str=None, **kwargs) -> None: + def __init__( + self, + *, + properties: "DeploymentProperties", + location: Optional[str] = None, + **kwargs + ): super(Deployment, self).__init__(**kwargs) self.location = location self.properties = properties -class DeploymentExportResult(Model): - """The deployment export result. . +class DeploymentExportResult(msrest.serialization.Model): + """The deployment export result. :param template: The template content. :type template: object @@ -196,16 +231,20 @@ class DeploymentExportResult(Model): 'template': {'key': 'template', 'type': 'object'}, } - def __init__(self, *, template=None, **kwargs) -> None: + def __init__( + self, + *, + template: Optional[object] = None, + **kwargs + ): super(DeploymentExportResult, self).__init__(**kwargs) self.template = template -class DeploymentExtended(Model): +class DeploymentExtended(msrest.serialization.Model): """Deployment information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The ID of the deployment. :vartype id: str @@ -234,7 +273,13 @@ class DeploymentExtended(Model): 'properties': {'key': 'properties', 'type': 'DeploymentPropertiesExtended'}, } - def __init__(self, *, location: str=None, properties=None, **kwargs) -> None: + def __init__( + self, + *, + location: Optional[str] = None, + properties: Optional["DeploymentPropertiesExtended"] = None, + **kwargs + ): super(DeploymentExtended, self).__init__(**kwargs) self.id = None self.name = None @@ -243,7 +288,7 @@ def __init__(self, *, location: str=None, properties=None, **kwargs) -> None: self.properties = properties -class DeploymentExtendedFilter(Model): +class DeploymentExtendedFilter(msrest.serialization.Model): """Deployment filter. :param provisioning_state: The provisioning state. @@ -254,16 +299,51 @@ class DeploymentExtendedFilter(Model): 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, } - def __init__(self, *, provisioning_state: str=None, **kwargs) -> None: + def __init__( + self, + *, + provisioning_state: Optional[str] = None, + **kwargs + ): super(DeploymentExtendedFilter, self).__init__(**kwargs) self.provisioning_state = provisioning_state -class DeploymentOperation(Model): +class DeploymentListResult(msrest.serialization.Model): + """List of deployments. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[DeploymentExtended]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["DeploymentExtended"]] = None, + **kwargs + ): + super(DeploymentListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class DeploymentOperation(msrest.serialization.Model): """Deployment operation information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Full deployment operation ID. :vartype id: str @@ -285,23 +365,27 @@ class DeploymentOperation(Model): 'properties': {'key': 'properties', 'type': 'DeploymentOperationProperties'}, } - def __init__(self, *, properties=None, **kwargs) -> None: + def __init__( + self, + *, + properties: Optional["DeploymentOperationProperties"] = None, + **kwargs + ): super(DeploymentOperation, self).__init__(**kwargs) self.id = None self.operation_id = None self.properties = properties -class DeploymentOperationProperties(Model): +class DeploymentOperationProperties(msrest.serialization.Model): """Deployment operation properties. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar provisioning_state: The state of the provisioning. :vartype provisioning_state: str :ivar timestamp: The date and time of the operation. - :vartype timestamp: datetime + :vartype timestamp: ~datetime.datetime :ivar duration: The duration of the operation. :vartype duration: str :ivar service_request_id: Deployment operation service request id. @@ -311,14 +395,11 @@ class DeploymentOperationProperties(Model): :ivar status_message: Operation status message. :vartype status_message: object :ivar target_resource: The target resource. - :vartype target_resource: - ~azure.mgmt.resource.resources.v2019_07_01.models.TargetResource + :vartype target_resource: ~azure.mgmt.resource.resources.v2019_07_01.models.TargetResource :ivar request: The HTTP request message. - :vartype request: - ~azure.mgmt.resource.resources.v2019_07_01.models.HttpMessage + :vartype request: ~azure.mgmt.resource.resources.v2019_07_01.models.HttpMessage :ivar response: The HTTP response message. - :vartype response: - ~azure.mgmt.resource.resources.v2019_07_01.models.HttpMessage + :vartype response: ~azure.mgmt.resource.resources.v2019_07_01.models.HttpMessage """ _validation = { @@ -345,7 +426,10 @@ class DeploymentOperationProperties(Model): 'response': {'key': 'response', 'type': 'HttpMessage'}, } - def __init__(self, **kwargs) -> None: + def __init__( + self, + **kwargs + ): super(DeploymentOperationProperties, self).__init__(**kwargs) self.provisioning_state = None self.timestamp = None @@ -358,48 +442,70 @@ def __init__(self, **kwargs) -> None: self.response = None -class DeploymentProperties(Model): +class DeploymentOperationsListResult(msrest.serialization.Model): + """List of deployment operations. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[DeploymentOperation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["DeploymentOperation"]] = None, + **kwargs + ): + super(DeploymentOperationsListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class DeploymentProperties(msrest.serialization.Model): """Deployment properties. 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 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. + :param 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: object - :param 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. 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. + :param 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. + 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: object - :param 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 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 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 + 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 + :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 + :type on_error_deployment: ~azure.mgmt.resource.resources.v2019_07_01.models.OnErrorDeployment """ _validation = { @@ -411,12 +517,23 @@ class DeploymentProperties(Model): 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, 'parameters': {'key': 'parameters', 'type': 'object'}, 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, - 'mode': {'key': 'mode', 'type': 'DeploymentMode'}, + 'mode': {'key': 'mode', 'type': 'str'}, 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, 'on_error_deployment': {'key': 'onErrorDeployment', 'type': 'OnErrorDeployment'}, } - def __init__(self, *, mode, template=None, template_link=None, parameters=None, parameters_link=None, debug_setting=None, on_error_deployment=None, **kwargs) -> None: + def __init__( + self, + *, + mode: Union[str, "DeploymentMode"], + template: Optional[object] = None, + template_link: Optional["TemplateLink"] = None, + parameters: Optional[object] = None, + parameters_link: Optional["ParametersLink"] = None, + debug_setting: Optional["DebugSetting"] = None, + on_error_deployment: Optional["OnErrorDeployment"] = None, + **kwargs + ): super(DeploymentProperties, self).__init__(**kwargs) self.template = template self.template_link = template_link @@ -427,50 +544,40 @@ def __init__(self, *, mode, template=None, template_link=None, parameters=None, self.on_error_deployment = on_error_deployment -class DeploymentPropertiesExtended(Model): +class DeploymentPropertiesExtended(msrest.serialization.Model): """Deployment properties with additional details. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :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 + :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: object - :param providers: The list of resource providers needed for the - deployment. - :type providers: - list[~azure.mgmt.resource.resources.v2019_07_01.models.Provider] + :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 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: object - :param 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. + :param 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: object - :param 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 include: 'Incremental', 'Complete' - :type mode: str or - ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentMode + :param 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 + 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 + :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.OnErrorDeploymentExtended @@ -495,12 +602,26 @@ class DeploymentPropertiesExtended(Model): 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, 'parameters': {'key': 'parameters', 'type': 'object'}, 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, - 'mode': {'key': 'mode', 'type': 'DeploymentMode'}, + 'mode': {'key': 'mode', 'type': 'str'}, 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, 'on_error_deployment': {'key': 'onErrorDeployment', 'type': 'OnErrorDeploymentExtended'}, } - def __init__(self, *, outputs=None, providers=None, dependencies=None, template=None, template_link=None, parameters=None, parameters_link=None, mode=None, debug_setting=None, on_error_deployment=None, **kwargs) -> None: + def __init__( + self, + *, + outputs: Optional[object] = None, + providers: Optional[List["Provider"]] = None, + dependencies: Optional[List["Dependency"]] = None, + template: Optional[object] = None, + template_link: Optional["TemplateLink"] = None, + parameters: Optional[object] = None, + parameters_link: Optional["ParametersLink"] = None, + mode: Optional[Union[str, "DeploymentMode"]] = None, + debug_setting: Optional["DebugSetting"] = None, + on_error_deployment: Optional["OnErrorDeploymentExtended"] = None, + **kwargs + ): super(DeploymentPropertiesExtended, self).__init__(**kwargs) self.provisioning_state = None self.correlation_id = None @@ -518,12 +639,11 @@ def __init__(self, *, outputs=None, providers=None, dependencies=None, template= self.on_error_deployment = on_error_deployment -class DeploymentValidateResult(Model): +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 + :type error: ~azure.mgmt.resource.resources.v2019_07_01.models.ErrorResponse :param properties: The template deployment properties. :type properties: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentPropertiesExtended @@ -534,13 +654,19 @@ class DeploymentValidateResult(Model): 'properties': {'key': 'properties', 'type': 'DeploymentPropertiesExtended'}, } - def __init__(self, *, error=None, properties=None, **kwargs) -> None: + def __init__( + self, + *, + error: Optional["ErrorResponse"] = None, + properties: Optional["DeploymentPropertiesExtended"] = None, + **kwargs + ): super(DeploymentValidateResult, self).__init__(**kwargs) self.error = error self.properties = properties -class DeploymentWhatIf(Model): +class DeploymentWhatIf(msrest.serialization.Model): """Deployment What-if operation parameters. All required parameters must be populated in order to send to Azure. @@ -548,8 +674,7 @@ class DeploymentWhatIf(Model): :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 + :type properties: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentWhatIfProperties """ _validation = { @@ -561,7 +686,13 @@ class DeploymentWhatIf(Model): 'properties': {'key': 'properties', 'type': 'DeploymentWhatIfProperties'}, } - def __init__(self, *, properties, location: str=None, **kwargs) -> None: + def __init__( + self, + *, + properties: "DeploymentWhatIfProperties", + location: Optional[str] = None, + **kwargs + ): super(DeploymentWhatIf, self).__init__(**kwargs) self.location = location self.properties = properties @@ -572,43 +703,34 @@ 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 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. + :param 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: object - :param 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. 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. + :param 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. + 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: object - :param 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 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 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 + 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 + :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 + :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: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentWhatIfSettings @@ -623,40 +745,56 @@ class DeploymentWhatIfProperties(DeploymentProperties): 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, 'parameters': {'key': 'parameters', 'type': 'object'}, 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, - 'mode': {'key': 'mode', 'type': 'DeploymentMode'}, + 'mode': {'key': 'mode', 'type': 'str'}, 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, 'on_error_deployment': {'key': 'onErrorDeployment', 'type': 'OnErrorDeployment'}, 'what_if_settings': {'key': 'whatIfSettings', 'type': 'DeploymentWhatIfSettings'}, } - def __init__(self, *, mode, template=None, template_link=None, parameters=None, parameters_link=None, debug_setting=None, on_error_deployment=None, what_if_settings=None, **kwargs) -> None: + def __init__( + self, + *, + mode: Union[str, "DeploymentMode"], + template: Optional[object] = None, + template_link: Optional["TemplateLink"] = None, + parameters: Optional[object] = None, + parameters_link: Optional["ParametersLink"] = None, + debug_setting: Optional["DebugSetting"] = None, + on_error_deployment: Optional["OnErrorDeployment"] = None, + what_if_settings: Optional["DeploymentWhatIfSettings"] = None, + **kwargs + ): 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 -class DeploymentWhatIfSettings(Model): +class DeploymentWhatIfSettings(msrest.serialization.Model): """Deployment What-If operation settings. - :param result_format: The format of the What-If results. Possible values - include: 'ResourceIdOnly', 'FullResourcePayloads' + :param result_format: The format of the What-If results. Possible values include: + "ResourceIdOnly", "FullResourcePayloads". :type result_format: str or ~azure.mgmt.resource.resources.v2019_07_01.models.WhatIfResultFormat """ _attribute_map = { - 'result_format': {'key': 'resultFormat', 'type': 'WhatIfResultFormat'}, + 'result_format': {'key': 'resultFormat', 'type': 'str'}, } - def __init__(self, *, result_format=None, **kwargs) -> None: + def __init__( + self, + *, + result_format: Optional[Union[str, "WhatIfResultFormat"]] = None, + **kwargs + ): super(DeploymentWhatIfSettings, self).__init__(**kwargs) self.result_format = result_format -class ErrorAdditionalInfo(Model): +class ErrorAdditionalInfo(msrest.serialization.Model): """The resource management error additional info. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar type: The additional info type. :vartype type: str @@ -674,17 +812,19 @@ class ErrorAdditionalInfo(Model): 'info': {'key': 'info', 'type': 'object'}, } - def __init__(self, **kwargs) -> None: + def __init__( + self, + **kwargs + ): super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None -class ErrorResponse(Model): +class ErrorResponse(msrest.serialization.Model): """The resource management error response. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar code: The error code. :vartype code: str @@ -693,8 +833,7 @@ class ErrorResponse(Model): :ivar target: The error target. :vartype target: str :ivar details: The error details. - :vartype details: - list[~azure.mgmt.resource.resources.v2019_07_01.models.ErrorResponse] + :vartype details: list[~azure.mgmt.resource.resources.v2019_07_01.models.ErrorResponse] :ivar additional_info: The error additional info. :vartype additional_info: list[~azure.mgmt.resource.resources.v2019_07_01.models.ErrorAdditionalInfo] @@ -716,7 +855,10 @@ class ErrorResponse(Model): 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, } - def __init__(self, **kwargs) -> None: + def __init__( + self, + **kwargs + ): super(ErrorResponse, self).__init__(**kwargs) self.code = None self.message = None @@ -725,16 +867,15 @@ def __init__(self, **kwargs) -> None: self.additional_info = None -class ExportTemplateRequest(Model): +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, supply an array with single entry '*'. + :param 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', 'SkipResourceNameParameterization', - 'SkipAllParameterization' + :param options: The export template options. A CSV-formatted list containing zero or more of + the following: 'IncludeParameterDefaultValue', 'IncludeComments', + 'SkipResourceNameParameterization', 'SkipAllParameterization'. :type options: str """ @@ -743,27 +884,32 @@ class ExportTemplateRequest(Model): 'options': {'key': 'options', 'type': 'str'}, } - def __init__(self, *, resources=None, options: str=None, **kwargs) -> None: + def __init__( + self, + *, + resources: Optional[List[str]] = None, + options: Optional[str] = None, + **kwargs + ): super(ExportTemplateRequest, self).__init__(**kwargs) self.resources = resources self.options = options -class Resource(Model): +class Resource(msrest.serialization.Model): """Specified resource. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID + :ivar id: Resource ID. :vartype id: str - :ivar name: Resource name + :ivar name: Resource name. :vartype name: str - :ivar type: Resource type + :ivar type: Resource type. :vartype type: str - :param location: Resource location + :param location: Resource location. :type location: str - :param tags: Resource tags + :param tags: A set of tags. Resource tags. :type tags: dict[str, str] """ @@ -781,7 +927,13 @@ class Resource(Model): 'tags': {'key': 'tags', 'type': '{str}'}, } - def __init__(self, *, location: str=None, tags=None, **kwargs) -> None: + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -793,18 +945,17 @@ def __init__(self, *, location: str=None, tags=None, **kwargs) -> None: class GenericResource(Resource): """Resource information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID + :ivar id: Resource ID. :vartype id: str - :ivar name: Resource name + :ivar name: Resource name. :vartype name: str - :ivar type: Resource type + :ivar type: Resource type. :vartype type: str - :param location: Resource location + :param location: Resource location. :type location: str - :param tags: Resource tags + :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 @@ -841,7 +992,19 @@ class GenericResource(Resource): 'identity': {'key': 'identity', 'type': 'Identity'}, } - def __init__(self, *, location: str=None, tags=None, plan=None, properties=None, kind: str=None, managed_by: str=None, sku=None, identity=None, **kwargs) -> None: + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + plan: Optional["Plan"] = None, + properties: Optional[object] = None, + kind: Optional[str] = None, + managed_by: Optional[str] = None, + sku: Optional["Sku"] = None, + identity: Optional["Identity"] = None, + **kwargs + ): super(GenericResource, self).__init__(location=location, tags=tags, **kwargs) self.plan = plan self.properties = properties @@ -854,18 +1017,17 @@ def __init__(self, *, location: str=None, tags=None, plan=None, properties=None, class GenericResourceExpanded(GenericResource): """Resource information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID + :ivar id: Resource ID. :vartype id: str - :ivar name: Resource name + :ivar name: Resource name. :vartype name: str - :ivar type: Resource type + :ivar type: Resource type. :vartype type: str - :param location: Resource location + :param location: Resource location. :type location: str - :param tags: Resource tags + :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 @@ -879,14 +1041,14 @@ class GenericResourceExpanded(GenericResource): :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 created_time: The created time of the resource. This is only present - if requested via the $expand query parameter. - :vartype created_time: datetime - :ivar changed_time: The changed time of the resource. This is only present - if requested via the $expand query parameter. - :vartype changed_time: datetime - :ivar provisioning_state: The provisioning state of the resource. This is - only present if requested via the $expand query parameter. + :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 + :ivar changed_time: The changed time of the resource. This is only present if requested via the + $expand query parameter. + :vartype changed_time: ~datetime.datetime + :ivar provisioning_state: The provisioning state of the resource. This is only present if + requested via the $expand query parameter. :vartype provisioning_state: str """ @@ -917,14 +1079,26 @@ class GenericResourceExpanded(GenericResource): 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, } - def __init__(self, *, location: str=None, tags=None, plan=None, properties=None, kind: str=None, managed_by: str=None, sku=None, identity=None, **kwargs) -> None: + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + plan: Optional["Plan"] = None, + properties: Optional[object] = None, + kind: Optional[str] = None, + managed_by: Optional[str] = None, + sku: Optional["Sku"] = None, + identity: Optional["Identity"] = None, + **kwargs + ): 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 self.provisioning_state = None -class GenericResourceFilter(Model): +class GenericResourceFilter(msrest.serialization.Model): """Resource filter. :param resource_type: The resource type. @@ -941,14 +1115,21 @@ class GenericResourceFilter(Model): 'tagvalue': {'key': 'tagvalue', 'type': 'str'}, } - def __init__(self, *, resource_type: str=None, tagname: str=None, tagvalue: str=None, **kwargs) -> None: + def __init__( + self, + *, + resource_type: Optional[str] = None, + tagname: Optional[str] = None, + tagvalue: Optional[str] = None, + **kwargs + ): super(GenericResourceFilter, self).__init__(**kwargs) self.resource_type = resource_type self.tagname = tagname self.tagvalue = tagvalue -class HttpMessage(Model): +class HttpMessage(msrest.serialization.Model): """HTTP message. :param content: HTTP message content. @@ -959,31 +1140,33 @@ class HttpMessage(Model): 'content': {'key': 'content', 'type': 'object'}, } - def __init__(self, *, content=None, **kwargs) -> None: + def __init__( + self, + *, + content: Optional[object] = None, + **kwargs + ): super(HttpMessage, self).__init__(**kwargs) self.content = content -class Identity(Model): +class Identity(msrest.serialization.Model): """Identity for the resource. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar principal_id: The principal ID of resource identity. :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :param 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 user identity dictionary key references will be ARM - resource ids in the form: + :param 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 + 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, - ~azure.mgmt.resource.resources.v2019_07_01.models.IdentityUserAssignedIdentitiesValue] + ~azure.mgmt.resource.resources.v2019_07_01.models.ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties] """ _validation = { @@ -994,11 +1177,17 @@ class Identity(Model): _attribute_map = { 'principal_id': {'key': 'principalId', 'type': 'str'}, 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'ResourceIdentityType'}, - 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{IdentityUserAssignedIdentitiesValue}'}, + 'type': {'key': 'type', 'type': 'str'}, + 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties}'}, } - def __init__(self, *, type=None, user_assigned_identities=None, **kwargs) -> None: + def __init__( + self, + *, + type: Optional[Union[str, "ResourceIdentityType"]] = None, + user_assigned_identities: Optional[Dict[str, "ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties"]] = None, + **kwargs + ): super(Identity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None @@ -1006,71 +1195,43 @@ def __init__(self, *, type=None, user_assigned_identities=None, **kwargs) -> Non self.user_assigned_identities = user_assigned_identities -class IdentityUserAssignedIdentitiesValue(Model): - """IdentityUserAssignedIdentitiesValue. - - Variables are only populated by the server, and will be ignored when - sending a request. - - :ivar principal_id: The principal id of user assigned identity. - :vartype principal_id: str - :ivar client_id: The client id of user assigned identity. - :vartype client_id: str - """ - - _validation = { - 'principal_id': {'readonly': True}, - 'client_id': {'readonly': True}, - } - - _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'client_id': {'key': 'clientId', 'type': 'str'}, - } - - def __init__(self, **kwargs) -> None: - super(IdentityUserAssignedIdentitiesValue, self).__init__(**kwargs) - self.principal_id = None - self.client_id = None - - -class OnErrorDeployment(Model): +class OnErrorDeployment(msrest.serialization.Model): """Deployment on error behavior. - :param 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 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 """ _attribute_map = { - 'type': {'key': 'type', 'type': 'OnErrorDeploymentType'}, + 'type': {'key': 'type', 'type': 'str'}, 'deployment_name': {'key': 'deploymentName', 'type': 'str'}, } - def __init__(self, *, type=None, deployment_name: str=None, **kwargs) -> None: + def __init__( + self, + *, + type: Optional[Union[str, "OnErrorDeploymentType"]] = None, + deployment_name: Optional[str] = None, + **kwargs + ): super(OnErrorDeployment, self).__init__(**kwargs) self.type = type self.deployment_name = deployment_name -class OnErrorDeploymentExtended(Model): +class OnErrorDeploymentExtended(msrest.serialization.Model): """Deployment on error behavior with additional details. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar provisioning_state: The state of the provisioning for the on error - deployment. + :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 SpecificDeployment. Possible values include: - 'LastSuccessful', 'SpecificDeployment' - :type type: str or - ~azure.mgmt.resource.resources.v2019_07_01.models.OnErrorDeploymentType + :param 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 """ @@ -1081,25 +1242,30 @@ class OnErrorDeploymentExtended(Model): _attribute_map = { 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'OnErrorDeploymentType'}, + 'type': {'key': 'type', 'type': 'str'}, 'deployment_name': {'key': 'deploymentName', 'type': 'str'}, } - def __init__(self, *, type=None, deployment_name: str=None, **kwargs) -> None: + def __init__( + self, + *, + type: Optional[Union[str, "OnErrorDeploymentType"]] = None, + deployment_name: Optional[str] = None, + **kwargs + ): super(OnErrorDeploymentExtended, self).__init__(**kwargs) self.provisioning_state = None self.type = type self.deployment_name = deployment_name -class Operation(Model): +class Operation(msrest.serialization.Model): """Microsoft.Resources operation. - :param name: Operation name: {provider}/{resource}/{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 + :type display: ~azure.mgmt.resource.resources.v2019_07_01.models.OperationDisplay """ _attribute_map = { @@ -1107,19 +1273,24 @@ class Operation(Model): 'display': {'key': 'display', 'type': 'OperationDisplay'}, } - def __init__(self, *, name: str=None, display=None, **kwargs) -> None: + def __init__( + self, + *, + name: Optional[str] = None, + display: Optional["OperationDisplay"] = None, + **kwargs + ): super(Operation, self).__init__(**kwargs) self.name = name self.display = display -class OperationDisplay(Model): +class OperationDisplay(msrest.serialization.Model): """The object that represents the operation. - :param provider: Service provider: Microsoft.Resources + :param provider: Service provider: Microsoft.Resources. :type provider: str - :param resource: Resource on which the operation is performed: Profile, - endpoint, etc. + :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 @@ -1134,7 +1305,15 @@ class OperationDisplay(Model): 'description': {'key': 'description', 'type': 'str'}, } - def __init__(self, *, provider: str=None, resource: str=None, operation: str=None, description: str=None, **kwargs) -> None: + def __init__( + self, + *, + provider: Optional[str] = None, + resource: Optional[str] = None, + operation: Optional[str] = None, + description: Optional[str] = None, + **kwargs + ): super(OperationDisplay, self).__init__(**kwargs) self.provider = provider self.resource = resource @@ -1142,15 +1321,40 @@ def __init__(self, *, provider: str=None, resource: str=None, operation: str=Non self.description = description -class ParametersLink(Model): +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 + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Operation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["Operation"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(OperationListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ParametersLink(msrest.serialization.Model): """Entity representing the reference to the deployment parameters. 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. + :param content_version: If included, must match the ContentVersion in the template. :type content_version: str """ @@ -1163,13 +1367,19 @@ class ParametersLink(Model): 'content_version': {'key': 'contentVersion', 'type': 'str'}, } - def __init__(self, *, uri: str, content_version: str=None, **kwargs) -> None: + def __init__( + self, + *, + uri: str, + content_version: Optional[str] = None, + **kwargs + ): super(ParametersLink, self).__init__(**kwargs) self.uri = uri self.content_version = content_version -class Plan(Model): +class Plan(msrest.serialization.Model): """Plan for the resource. :param name: The plan ID. @@ -1192,7 +1402,16 @@ class Plan(Model): 'version': {'key': 'version', 'type': 'str'}, } - def __init__(self, *, name: str=None, publisher: str=None, product: str=None, promotion_code: str=None, version: str=None, **kwargs) -> None: + def __init__( + self, + *, + name: Optional[str] = None, + publisher: Optional[str] = None, + product: Optional[str] = None, + promotion_code: Optional[str] = None, + version: Optional[str] = None, + **kwargs + ): super(Plan, self).__init__(**kwargs) self.name = name self.publisher = publisher @@ -1201,11 +1420,10 @@ def __init__(self, *, name: str=None, publisher: str=None, product: str=None, pr self.version = version -class Provider(Model): +class Provider(msrest.serialization.Model): """Resource provider information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The provider ID. :vartype id: str @@ -1213,8 +1431,7 @@ class Provider(Model): :type 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. + :ivar registration_policy: The registration policy of the resource provider. :vartype registration_policy: str :ivar resource_types: The collection of provider resource types. :vartype resource_types: @@ -1236,7 +1453,12 @@ class Provider(Model): 'resource_types': {'key': 'resourceTypes', 'type': '[ProviderResourceType]'}, } - def __init__(self, *, namespace: str=None, **kwargs) -> None: + def __init__( + self, + *, + namespace: Optional[str] = None, + **kwargs + ): super(Provider, self).__init__(**kwargs) self.id = None self.namespace = namespace @@ -1245,21 +1467,49 @@ def __init__(self, *, namespace: str=None, **kwargs) -> None: self.resource_types = None -class ProviderResourceType(Model): +class ProviderListResult(msrest.serialization.Model): + """List of resource providers. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Provider]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["Provider"]] = None, + **kwargs + ): + super(ProviderListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +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. + :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] + :type aliases: list[~azure.mgmt.resource.resources.v2019_07_01.models.AliasType] :param api_versions: The API version. :type api_versions: list[str] - :param capabilities: The additional capabilities offered by this resource - type. + :param capabilities: The additional capabilities offered by this resource type. :type capabilities: str :param properties: The properties. :type properties: dict[str, str] @@ -1274,7 +1524,17 @@ class ProviderResourceType(Model): 'properties': {'key': 'properties', 'type': '{str}'}, } - def __init__(self, *, resource_type: str=None, locations=None, aliases=None, api_versions=None, capabilities: str=None, properties=None, **kwargs) -> None: + def __init__( + self, + *, + resource_type: Optional[str] = None, + locations: Optional[List[str]] = None, + aliases: Optional[List["AliasType"]] = None, + api_versions: Optional[List[str]] = None, + capabilities: Optional[str] = None, + properties: Optional[Dict[str, str]] = None, + **kwargs + ): super(ProviderResourceType, self).__init__(**kwargs) self.resource_type = resource_type self.locations = locations @@ -1284,11 +1544,10 @@ def __init__(self, *, resource_type: str=None, locations=None, aliases=None, api self.properties = properties -class ResourceGroup(Model): +class ResourceGroup(msrest.serialization.Model): """Resource group information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. @@ -1299,16 +1558,13 @@ class ResourceGroup(Model): :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 resource group has been created. It must be one of - the supported Azure locations. + :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 + 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. + :param managed_by: The ID of the resource that manages this resource group. :type managed_by: str - :param tags: The tags attached to the resource group. + :param tags: A set of tags. The tags attached to the resource group. :type tags: dict[str, str] """ @@ -1329,7 +1585,15 @@ class ResourceGroup(Model): 'tags': {'key': 'tags', 'type': '{str}'}, } - def __init__(self, *, location: str, properties=None, managed_by: str=None, tags=None, **kwargs) -> None: + def __init__( + self, + *, + location: str, + properties: Optional["ResourceGroupProperties"] = None, + managed_by: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): super(ResourceGroup, self).__init__(**kwargs) self.id = None self.name = None @@ -1340,14 +1604,13 @@ def __init__(self, *, location: str, properties=None, managed_by: str=None, tags self.tags = tags -class ResourceGroupExportResult(Model): +class ResourceGroupExportResult(msrest.serialization.Model): """Resource group export result. :param template: The template content. :type template: object :param error: The template export error. - :type error: - ~azure.mgmt.resource.resources.v2019_07_01.models.ErrorResponse + :type error: ~azure.mgmt.resource.resources.v2019_07_01.models.ErrorResponse """ _attribute_map = { @@ -1355,13 +1618,19 @@ class ResourceGroupExportResult(Model): 'error': {'key': 'error', 'type': 'ErrorResponse'}, } - def __init__(self, *, template=None, error=None, **kwargs) -> None: + def __init__( + self, + *, + template: Optional[object] = None, + error: Optional["ErrorResponse"] = None, + **kwargs + ): super(ResourceGroupExportResult, self).__init__(**kwargs) self.template = template self.error = error -class ResourceGroupFilter(Model): +class ResourceGroupFilter(msrest.serialization.Model): """Resource group filter. :param tag_name: The tag name. @@ -1375,24 +1644,59 @@ class ResourceGroupFilter(Model): 'tag_value': {'key': 'tagValue', 'type': 'str'}, } - def __init__(self, *, tag_name: str=None, tag_value: str=None, **kwargs) -> None: + def __init__( + self, + *, + tag_name: Optional[str] = None, + tag_value: Optional[str] = None, + **kwargs + ): super(ResourceGroupFilter, self).__init__(**kwargs) self.tag_name = tag_name self.tag_value = tag_value -class ResourceGroupPatchable(Model): +class ResourceGroupListResult(msrest.serialization.Model): + """List of resource groups. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ResourceGroup]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["ResourceGroup"]] = None, + **kwargs + ): + super(ResourceGroupListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +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 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: The tags attached to the resource group. + :param tags: A set of tags. The tags attached to the resource group. :type tags: dict[str, str] """ @@ -1403,7 +1707,15 @@ class ResourceGroupPatchable(Model): 'tags': {'key': 'tags', 'type': '{str}'}, } - def __init__(self, *, name: str=None, properties=None, managed_by: str=None, tags=None, **kwargs) -> None: + def __init__( + self, + *, + name: Optional[str] = None, + properties: Optional["ResourceGroupProperties"] = None, + managed_by: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): super(ResourceGroupPatchable, self).__init__(**kwargs) self.name = name self.properties = properties @@ -1411,11 +1723,10 @@ def __init__(self, *, name: str=None, properties=None, managed_by: str=None, tag self.tags = tags -class ResourceGroupProperties(Model): +class ResourceGroupProperties(msrest.serialization.Model): """The resource group properties. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar provisioning_state: The provisioning state. :vartype provisioning_state: str @@ -1429,12 +1740,46 @@ class ResourceGroupProperties(Model): 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, } - def __init__(self, **kwargs) -> None: + def __init__( + self, + **kwargs + ): super(ResourceGroupProperties, self).__init__(**kwargs) self.provisioning_state = None -class ResourceProviderOperationDisplayProperties(Model): +class ResourceListResult(msrest.serialization.Model): + """List of resource groups. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[GenericResourceExpanded]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["GenericResourceExpanded"]] = None, + **kwargs + ): + super(ResourceListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class ResourceProviderOperationDisplayProperties(msrest.serialization.Model): """Resource provider operation's display properties. :param publisher: Operation description. @@ -1457,7 +1802,16 @@ class ResourceProviderOperationDisplayProperties(Model): 'description': {'key': 'description', 'type': 'str'}, } - def __init__(self, *, publisher: str=None, provider: str=None, resource: str=None, operation: str=None, description: str=None, **kwargs) -> None: + def __init__( + self, + *, + publisher: Optional[str] = None, + provider: Optional[str] = None, + resource: Optional[str] = None, + operation: Optional[str] = None, + description: Optional[str] = None, + **kwargs + ): super(ResourceProviderOperationDisplayProperties, self).__init__(**kwargs) self.publisher = publisher self.provider = provider @@ -1466,7 +1820,7 @@ def __init__(self, *, publisher: str=None, provider: str=None, resource: str=Non self.description = description -class ResourcesMoveInfo(Model): +class ResourcesMoveInfo(msrest.serialization.Model): """Parameters of move resources. :param resources: The IDs of the resources. @@ -1480,13 +1834,19 @@ class ResourcesMoveInfo(Model): 'target_resource_group': {'key': 'targetResourceGroup', 'type': 'str'}, } - def __init__(self, *, resources=None, target_resource_group: str=None, **kwargs) -> None: + def __init__( + self, + *, + resources: Optional[List[str]] = None, + target_resource_group: Optional[str] = None, + **kwargs + ): super(ResourcesMoveInfo, self).__init__(**kwargs) self.resources = resources self.target_resource_group = target_resource_group -class Sku(Model): +class Sku(msrest.serialization.Model): """SKU for the resource. :param name: The SKU name. @@ -1512,7 +1872,17 @@ class Sku(Model): 'capacity': {'key': 'capacity', 'type': 'int'}, } - def __init__(self, *, name: str=None, tier: str=None, size: str=None, family: str=None, model: str=None, capacity: int=None, **kwargs) -> None: + def __init__( + self, + *, + name: Optional[str] = None, + tier: Optional[str] = None, + size: Optional[str] = None, + family: Optional[str] = None, + model: Optional[str] = None, + capacity: Optional[int] = None, + **kwargs + ): super(Sku, self).__init__(**kwargs) self.name = name self.tier = tier @@ -1522,10 +1892,10 @@ def __init__(self, *, name: str=None, tier: str=None, size: str=None, family: st self.capacity = capacity -class SubResource(Model): +class SubResource(msrest.serialization.Model): """Sub-resource. - :param id: Resource ID + :param id: Resource ID. :type id: str """ @@ -1533,12 +1903,17 @@ class SubResource(Model): 'id': {'key': 'id', 'type': 'str'}, } - def __init__(self, *, id: str=None, **kwargs) -> None: + def __init__( + self, + *, + id: Optional[str] = None, + **kwargs + ): super(SubResource, self).__init__(**kwargs) self.id = id -class TagCount(Model): +class TagCount(msrest.serialization.Model): """Tag count. :param type: Type of count. @@ -1552,29 +1927,32 @@ class TagCount(Model): 'value': {'key': 'value', 'type': 'int'}, } - def __init__(self, *, type: str=None, value: int=None, **kwargs) -> None: + def __init__( + self, + *, + type: Optional[str] = None, + value: Optional[int] = None, + **kwargs + ): super(TagCount, self).__init__(**kwargs) self.type = type self.value = value -class TagDetails(Model): +class TagDetails(msrest.serialization.Model): """Tag details. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :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 created and has no associated resources, the value - is 0. + :param 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] + :type values: list[~azure.mgmt.resource.resources.v2019_07_01.models.TagValue] """ _validation = { @@ -1588,7 +1966,14 @@ class TagDetails(Model): 'values': {'key': 'values', 'type': '[TagValue]'}, } - def __init__(self, *, tag_name: str=None, count=None, values=None, **kwargs) -> None: + def __init__( + self, + *, + tag_name: Optional[str] = None, + count: Optional["TagCount"] = None, + values: Optional[List["TagValue"]] = None, + **kwargs + ): super(TagDetails, self).__init__(**kwargs) self.id = None self.tag_name = tag_name @@ -1596,11 +1981,41 @@ def __init__(self, *, tag_name: str=None, count=None, values=None, **kwargs) -> self.values = values -class TagValue(Model): +class TagsListResult(msrest.serialization.Model): + """List of subscription tags. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[TagDetails]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["TagDetails"]] = None, + **kwargs + ): + super(TagsListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class TagValue(msrest.serialization.Model): """Tag information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The tag ID. :vartype id: str @@ -1620,14 +2035,20 @@ class TagValue(Model): 'count': {'key': 'count', 'type': 'TagCount'}, } - def __init__(self, *, tag_value: str=None, count=None, **kwargs) -> None: + def __init__( + self, + *, + tag_value: Optional[str] = None, + count: Optional["TagCount"] = None, + **kwargs + ): super(TagValue, self).__init__(**kwargs) self.id = None self.tag_value = tag_value self.count = count -class TargetResource(Model): +class TargetResource(msrest.serialization.Model): """Target resource. :param id: The ID of the resource. @@ -1644,16 +2065,22 @@ class TargetResource(Model): 'resource_type': {'key': 'resourceType', 'type': 'str'}, } - def __init__(self, *, id: str=None, resource_name: str=None, resource_type: str=None, **kwargs) -> None: + def __init__( + self, + *, + id: Optional[str] = None, + resource_name: Optional[str] = None, + resource_type: Optional[str] = None, + **kwargs + ): super(TargetResource, self).__init__(**kwargs) self.id = id self.resource_name = resource_name self.resource_type = resource_type -class TemplateHashResult(Model): - """Result of the request to calculate template hash. It contains a string of - minified template and its hash. +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 @@ -1666,21 +2093,26 @@ class TemplateHashResult(Model): 'template_hash': {'key': 'templateHash', 'type': 'str'}, } - def __init__(self, *, minified_template: str=None, template_hash: str=None, **kwargs) -> None: + def __init__( + self, + *, + minified_template: Optional[str] = None, + template_hash: Optional[str] = None, + **kwargs + ): super(TemplateHashResult, self).__init__(**kwargs) self.minified_template = minified_template self.template_hash = template_hash -class TemplateLink(Model): +class TemplateLink(msrest.serialization.Model): """Entity representing the reference to the template. 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. + :param content_version: If included, must match the ContentVersion in the template. :type content_version: str """ @@ -1693,33 +2125,35 @@ class TemplateLink(Model): 'content_version': {'key': 'contentVersion', 'type': 'str'}, } - def __init__(self, *, uri: str, content_version: str=None, **kwargs) -> None: + def __init__( + self, + *, + uri: str, + content_version: Optional[str] = None, + **kwargs + ): super(TemplateLink, self).__init__(**kwargs) self.uri = uri self.content_version = content_version -class WhatIfChange(Model): +class WhatIfChange(msrest.serialization.Model): """Information about a single resource change predicted by What-If operation. All required parameters must be populated in order to send to Azure. - :param resource_id: Required. Resource ID + :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 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. + :param 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: object - :param after: The predicted snapshot of the resource after the deployment - is executed. + :param after: The predicted snapshot of the resource after the deployment is executed. :type after: object :param delta: The predicted changes to resource properties. - :type delta: - list[~azure.mgmt.resource.resources.v2019_07_01.models.WhatIfPropertyChange] + :type delta: list[~azure.mgmt.resource.resources.v2019_07_01.models.WhatIfPropertyChange] """ _validation = { @@ -1729,13 +2163,22 @@ class WhatIfChange(Model): _attribute_map = { 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'change_type': {'key': 'changeType', 'type': 'ChangeType'}, + 'change_type': {'key': 'changeType', 'type': 'str'}, 'before': {'key': 'before', 'type': 'object'}, 'after': {'key': 'after', 'type': 'object'}, 'delta': {'key': 'delta', 'type': '[WhatIfPropertyChange]'}, } - def __init__(self, *, resource_id: str, change_type, before=None, after=None, delta=None, **kwargs) -> None: + def __init__( + self, + *, + resource_id: str, + change_type: Union[str, "ChangeType"], + before: Optional[object] = None, + after: Optional[object] = None, + delta: Optional[List["WhatIfPropertyChange"]] = None, + **kwargs + ): super(WhatIfChange, self).__init__(**kwargs) self.resource_id = resource_id self.change_type = change_type @@ -1744,52 +2187,54 @@ def __init__(self, *, resource_id: str, change_type, before=None, after=None, de self.delta = delta -class WhatIfOperationResult(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. +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 changes: List of resource changes predicted by What-If operation. - :type changes: - list[~azure.mgmt.resource.resources.v2019_07_01.models.WhatIfChange] :param error: Error when What-If operation fails. - :type error: - ~azure.mgmt.resource.resources.v2019_07_01.models.ErrorResponse + :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] """ _attribute_map = { 'status': {'key': 'status', 'type': 'str'}, - 'changes': {'key': 'properties.changes', 'type': '[WhatIfChange]'}, 'error': {'key': 'error', 'type': 'ErrorResponse'}, + 'changes': {'key': 'properties.changes', 'type': '[WhatIfChange]'}, } - def __init__(self, *, status: str=None, changes=None, error=None, **kwargs) -> None: + def __init__( + self, + *, + status: Optional[str] = None, + error: Optional["ErrorResponse"] = None, + changes: Optional[List["WhatIfChange"]] = None, + **kwargs + ): super(WhatIfOperationResult, self).__init__(**kwargs) self.status = status - self.changes = changes self.error = error + self.changes = changes -class WhatIfPropertyChange(Model): +class WhatIfPropertyChange(msrest.serialization.Model): """The predicted change to the resource property. 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: 'Create', 'Delete', 'Modify', 'Array' + :param property_change_type: Required. The type of property change. Possible values include: + "Create", "Delete", "Modify", "Array". :type 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. + :param before: The value of the property before the deployment is executed. :type before: object :param after: The value of the property after the deployment is executed. :type after: object :param children: Nested property changes. - :type children: - list[~azure.mgmt.resource.resources.v2019_07_01.models.WhatIfPropertyChange] + :type children: list[~azure.mgmt.resource.resources.v2019_07_01.models.WhatIfPropertyChange] """ _validation = { @@ -1799,13 +2244,22 @@ class WhatIfPropertyChange(Model): _attribute_map = { 'path': {'key': 'path', 'type': 'str'}, - 'property_change_type': {'key': 'propertyChangeType', 'type': 'PropertyChangeType'}, + 'property_change_type': {'key': 'propertyChangeType', 'type': 'str'}, 'before': {'key': 'before', 'type': 'object'}, 'after': {'key': 'after', 'type': 'object'}, 'children': {'key': 'children', 'type': '[WhatIfPropertyChange]'}, } - def __init__(self, *, path: str, property_change_type, before=None, after=None, children=None, **kwargs) -> None: + def __init__( + self, + *, + path: str, + property_change_type: Union[str, "PropertyChangeType"], + before: Optional[object] = None, + after: Optional[object] = None, + children: Optional[List["WhatIfPropertyChange"]] = None, + **kwargs + ): super(WhatIfPropertyChange, self).__init__(**kwargs) self.path = path self.property_change_type = property_change_type diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/models/_paged_models.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/models/_paged_models.py deleted file mode 100644 index dc02350ae2bb..000000000000 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/models/_paged_models.py +++ /dev/null @@ -1,105 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.paging import Paged - - -class OperationPaged(Paged): - """ - A paging container for iterating over a list of :class:`Operation ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[Operation]'} - } - - def __init__(self, *args, **kwargs): - - super(OperationPaged, self).__init__(*args, **kwargs) -class DeploymentExtendedPaged(Paged): - """ - A paging container for iterating over a list of :class:`DeploymentExtended ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[DeploymentExtended]'} - } - - def __init__(self, *args, **kwargs): - - super(DeploymentExtendedPaged, self).__init__(*args, **kwargs) -class ProviderPaged(Paged): - """ - A paging container for iterating over a list of :class:`Provider ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[Provider]'} - } - - def __init__(self, *args, **kwargs): - - super(ProviderPaged, self).__init__(*args, **kwargs) -class GenericResourceExpandedPaged(Paged): - """ - A paging container for iterating over a list of :class:`GenericResourceExpanded ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[GenericResourceExpanded]'} - } - - def __init__(self, *args, **kwargs): - - super(GenericResourceExpandedPaged, self).__init__(*args, **kwargs) -class ResourceGroupPaged(Paged): - """ - A paging container for iterating over a list of :class:`ResourceGroup ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[ResourceGroup]'} - } - - def __init__(self, *args, **kwargs): - - super(ResourceGroupPaged, self).__init__(*args, **kwargs) -class TagDetailsPaged(Paged): - """ - A paging container for iterating over a list of :class:`TagDetails ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[TagDetails]'} - } - - def __init__(self, *args, **kwargs): - - super(TagDetailsPaged, self).__init__(*args, **kwargs) -class DeploymentOperationPaged(Paged): - """ - A paging container for iterating over a list of :class:`DeploymentOperation ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[DeploymentOperation]'} - } - - def __init__(self, *args, **kwargs): - - super(DeploymentOperationPaged, self).__init__(*args, **kwargs) 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 7306f86842bf..cb5967865b4f 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 @@ -1,56 +1,64 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from enum import Enum +class ChangeType(str, Enum): + """Type of change that will be made to the resource when the deployment is executed. + """ + + create = "Create" #: The resource does not exist in the current state but is present in the desired state. The resource will be created when the deployment is executed. + delete = "Delete" #: The resource exists in the current state and is missing from the desired state. The resource will be deleted when the deployment is executed. + ignore = "Ignore" #: The resource exists in the current state and is missing from the desired state. The resource will not be deployed or modified when the deployment is executed. + deploy = "Deploy" #: The resource exists in the current state and the desired state and will be redeployed when the deployment is executed. The properties of the resource may or may not change. + no_change = "NoChange" #: The resource exists in the current state and the desired state and will be redeployed when the deployment is executed. The properties of the resource will not change. + modify = "Modify" #: The resource exists in the current state and the desired state and will be redeployed when the deployment is executed. The properties of the resource will change. class DeploymentMode(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 + the resource group that are not included in the template are deleted. Be careful when using + Complete mode as you may unintentionally delete resources. + """ incremental = "Incremental" complete = "Complete" - class OnErrorDeploymentType(str, Enum): + """The deployment on error behavior type. Possible values are LastSuccessful and + SpecificDeployment. + """ last_successful = "LastSuccessful" specific_deployment = "SpecificDeployment" +class PropertyChangeType(str, Enum): + """The type of property change. + """ -class WhatIfResultFormat(str, Enum): - - resource_id_only = "ResourceIdOnly" - full_resource_payloads = "FullResourcePayloads" - + create = "Create" #: The property does not exist in the current state but is present in the desired state. The property will be created when the deployment is executed. + delete = "Delete" #: The property exists in the current state and is missing from the desired state. It will be deleted when the deployment is executed. + modify = "Modify" #: The property exists in both current and desired state and is different. The value of the property will change when the deployment is executed. + array = "Array" #: The property is an array and contains nested changes. class ResourceIdentityType(str, Enum): + """The identity type. + """ system_assigned = "SystemAssigned" user_assigned = "UserAssigned" system_assigned_user_assigned = "SystemAssigned, UserAssigned" none = "None" +class WhatIfResultFormat(str, Enum): + """The format of the What-If results + """ -class PropertyChangeType(str, Enum): - - create = "Create" #: The property does not exist in the current state but is present in the desired state. The property will be created when the deployment is executed. - delete = "Delete" #: The property exists in the current state and is missing from the desired state. It will be deleted when the deployment is executed. - modify = "Modify" #: The property exists in both current and desired state and is different. The value of the property will change when the deployment is executed. - array = "Array" #: The property is an array and contains nested changes. - - -class ChangeType(str, Enum): - - create = "Create" #: The resource does not exist in the current state but is present in the desired state. The resource will be created when the deployment is executed. - delete = "Delete" #: The resource exists in the current state and is missing from the desired state. The resource will be deleted when the deployment is executed. - ignore = "Ignore" #: The resource exists in the current state and is missing from the desired state. The resource will not be deployed or modified when the deployment is executed. - deploy = "Deploy" #: The resource exists in the current state and the desired state and will be redeployed when the deployment is executed. The properties of the resource may or may not change. - no_change = "NoChange" #: The resource exists in the current state and the desired state and will be redeployed when the deployment is executed. The properties of the resource will not change. - modify = "Modify" #: The resource exists in the current state and the desired state and will be redeployed when the deployment is executed. The properties of the resource will change. + resource_id_only = "ResourceIdOnly" + full_resource_payloads = "FullResourcePayloads" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/operations/__init__.py index 41027cf11028..a6f5fa20e792 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/operations/__init__.py @@ -1,12 +1,9 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from ._operations import Operations @@ -15,7 +12,7 @@ from ._resources_operations import ResourcesOperations from ._resource_groups_operations import ResourceGroupsOperations from ._tags_operations import TagsOperations -from ._deployment_operations import DeploymentOperations +from ._deployment_operations_operations import DeploymentOperationsOperations __all__ = [ 'Operations', @@ -24,5 +21,5 @@ 'ResourcesOperations', 'ResourceGroupsOperations', 'TagsOperations', - 'DeploymentOperations', + 'DeploymentOperationsOperations', ] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/operations/_deployment_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/operations/_deployment_operations.py deleted file mode 100644 index 8ed2970a1da3..000000000000 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/operations/_deployment_operations.py +++ /dev/null @@ -1,729 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError - -from .. import models - - -class DeploymentOperations(object): - """DeploymentOperations operations. - - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. - - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for this operation. Constant value: "2019-07-01". - """ - - models = models - - def __init__(self, client, config, serializer, deserializer): - - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self.api_version = "2019-07-01" - - self.config = config - - def get_at_scope( - self, scope, deployment_name, operation_id, custom_headers=None, raw=False, **operation_config): - """Gets a deployments operation. - - :param scope: The scope of a deployment. - :type scope: str - :param deployment_name: The name of the deployment. - :type deployment_name: str - :param operation_id: The ID of the operation to get. - :type operation_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentOperation or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentOperation - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` - """ - # Construct URL - url = self.get_at_scope.metadata['url'] - 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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) - - if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentOperation', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - - return deserialized - get_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} - - def list_at_scope( - self, scope, deployment_name, top=None, custom_headers=None, raw=False, **operation_config): - """Gets all deployments operations for a deployment. - - :param scope: The scope of a deployment. - :type scope: str - :param deployment_name: The name of the deployment. - :type deployment_name: str - :param top: The number of results to return. - :type top: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of DeploymentOperation - :rtype: - ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentOperationPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentOperation] - :raises: :class:`CloudError` - """ - def prepare_request(next_link=None): - if not next_link: - # Construct URL - url = self.list_at_scope.metadata['url'] - 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 = {} - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - else: - url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) - return request - - def internal_paging(next_link=None): - request = prepare_request(next_link) - - response = self._client.send(request, stream=False, **operation_config) - - if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response - - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.DeploymentOperationPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} - - def get_at_tenant_scope( - self, deployment_name, operation_id, custom_headers=None, raw=False, **operation_config): - """Gets a deployments operation. - - :param deployment_name: The name of the deployment. - :type deployment_name: str - :param operation_id: The ID of the operation to get. - :type operation_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentOperation or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentOperation - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` - """ - # Construct URL - url = self.get_at_tenant_scope.metadata['url'] - 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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) - - if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentOperation', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - - return deserialized - get_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} - - def list_at_tenant_scope( - self, deployment_name, top=None, custom_headers=None, raw=False, **operation_config): - """Gets all deployments operations for a deployment. - - :param deployment_name: The name of the deployment. - :type deployment_name: str - :param top: The number of results to return. - :type top: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of DeploymentOperation - :rtype: - ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentOperationPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentOperation] - :raises: :class:`CloudError` - """ - def prepare_request(next_link=None): - if not next_link: - # Construct URL - url = self.list_at_tenant_scope.metadata['url'] - 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 = {} - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - else: - url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) - return request - - def internal_paging(next_link=None): - request = prepare_request(next_link) - - response = self._client.send(request, stream=False, **operation_config) - - if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response - - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.DeploymentOperationPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} - - def get_at_management_group_scope( - self, group_id, deployment_name, operation_id, custom_headers=None, raw=False, **operation_config): - """Gets a deployments operation. - - :param group_id: The management group ID. - :type group_id: str - :param deployment_name: The name of the deployment. - :type deployment_name: str - :param operation_id: The ID of the operation to get. - :type operation_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentOperation or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentOperation - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` - """ - # Construct URL - url = self.get_at_management_group_scope.metadata['url'] - 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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) - - if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentOperation', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - - return deserialized - get_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} - - def list_at_management_group_scope( - self, group_id, deployment_name, top=None, custom_headers=None, raw=False, **operation_config): - """Gets all deployments operations for a deployment. - - :param group_id: The management group ID. - :type group_id: str - :param deployment_name: The name of the deployment. - :type deployment_name: str - :param top: The number of results to return. - :type top: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of DeploymentOperation - :rtype: - ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentOperationPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentOperation] - :raises: :class:`CloudError` - """ - def prepare_request(next_link=None): - if not next_link: - # Construct URL - url = self.list_at_management_group_scope.metadata['url'] - 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 = {} - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - else: - url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) - return request - - def internal_paging(next_link=None): - request = prepare_request(next_link) - - response = self._client.send(request, stream=False, **operation_config) - - if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response - - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.DeploymentOperationPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} - - def get_at_subscription_scope( - self, deployment_name, operation_id, custom_headers=None, raw=False, **operation_config): - """Gets a deployments operation. - - :param deployment_name: The name of the deployment. - :type deployment_name: str - :param operation_id: The ID of the operation to get. - :type operation_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentOperation or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentOperation - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` - """ - # Construct URL - url = self.get_at_subscription_scope.metadata['url'] - 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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) - - if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentOperation', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - - return deserialized - get_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} - - def list_at_subscription_scope( - self, deployment_name, top=None, custom_headers=None, raw=False, **operation_config): - """Gets all deployments operations for a deployment. - - :param deployment_name: The name of the deployment. - :type deployment_name: str - :param top: The number of results to return. - :type top: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of DeploymentOperation - :rtype: - ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentOperationPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentOperation] - :raises: :class:`CloudError` - """ - def prepare_request(next_link=None): - if not next_link: - # Construct URL - url = self.list_at_subscription_scope.metadata['url'] - 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 = {} - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - else: - url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) - return request - - def internal_paging(next_link=None): - request = prepare_request(next_link) - - response = self._client.send(request, stream=False, **operation_config) - - if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response - - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.DeploymentOperationPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} - - def get( - self, resource_group_name, deployment_name, operation_id, custom_headers=None, raw=False, **operation_config): - """Gets a deployments operation. - - :param resource_group_name: The name of the resource group. The name - is case insensitive. - :type resource_group_name: str - :param deployment_name: The name of the deployment. - :type deployment_name: str - :param operation_id: The ID of the operation to get. - :type operation_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentOperation or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentOperation - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` - """ - # Construct URL - url = self.get.metadata['url'] - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, 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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) - - if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentOperation', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}'} - - def list( - self, resource_group_name, deployment_name, top=None, custom_headers=None, raw=False, **operation_config): - """Gets all deployments operations for a deployment. - - :param resource_group_name: The name of the resource group. The name - is case insensitive. - :type resource_group_name: str - :param deployment_name: The name of the deployment. - :type deployment_name: str - :param top: The number of results to return. - :type top: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of DeploymentOperation - :rtype: - ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentOperationPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentOperation] - :raises: :class:`CloudError` - """ - def prepare_request(next_link=None): - if not next_link: - # Construct URL - url = self.list.metadata['url'] - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - else: - url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) - return request - - def internal_paging(next_link=None): - request = prepare_request(next_link) - - response = self._client.send(request, stream=False, **operation_config) - - if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response - - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.DeploymentOperationPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations'} 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 new file mode 100644 index 000000000000..e1e079434505 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/operations/_deployment_operations_operations.py @@ -0,0 +1,714 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class DeploymentOperationsOperations(object): + """DeploymentOperationsOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2019_07_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def get_at_scope( + self, + scope, # type: str + deployment_name, # type: str + operation_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentOperation" + """Gets a deployments operation. + + :param scope: The scope of a deployment. + :type scope: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param operation_id: The ID of the operation to get. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentOperation or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentOperation + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentOperation"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + + # 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'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentOperation', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + def list_at_scope( + self, + scope, # type: str + deployment_name, # type: str + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.DeploymentOperationsListResult"] + """Gets all deployments operations for a deployment. + + :param scope: The scope of a deployment. + :type scope: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentOperationsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} # type: ignore + + def get_at_tenant_scope( + self, + deployment_name, # type: str + operation_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentOperation" + """Gets a deployments operation. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param operation_id: The ID of the operation to get. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentOperation or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentOperation + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentOperation"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + + # 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'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentOperation', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + def list_at_tenant_scope( + self, + deployment_name, # type: str + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.DeploymentOperationsListResult"] + """Gets all deployments operations for a deployment. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentOperationsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} # type: ignore + + def get_at_management_group_scope( + self, + group_id, # type: str + deployment_name, # type: str + operation_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentOperation" + """Gets a deployments operation. + + :param group_id: The management group ID. + :type group_id: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param operation_id: The ID of the operation to get. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentOperation or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentOperation + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentOperation"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + + # 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'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentOperation', pipeline_response) + + if cls: + 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 + + def list_at_management_group_scope( + self, + group_id, # type: str + deployment_name, # type: str + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.DeploymentOperationsListResult"] + """Gets all deployments operations for a deployment. + + :param group_id: The management group ID. + :type group_id: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentOperationsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + 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 + + def get_at_subscription_scope( + self, + deployment_name, # type: str + operation_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentOperation" + """Gets a deployments operation. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param operation_id: The ID of the operation to get. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentOperation or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentOperation + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentOperation"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + + # 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'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentOperation', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + def list_at_subscription_scope( + self, + deployment_name, # type: str + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.DeploymentOperationsListResult"] + """Gets all deployments operations for a deployment. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentOperationsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + 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 + + def get( + self, + resource_group_name, # type: str + deployment_name, # type: str + operation_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentOperation" + """Gets a deployments operation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param operation_id: The ID of the operation to get. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentOperation or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentOperation + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentOperation"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + + # Construct URL + url = self.get.metadata['url'] # type: 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'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentOperation', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + def list( + self, + resource_group_name, # type: str + deployment_name, # type: str + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.DeploymentOperationsListResult"] + """Gets all deployments operations for a deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentOperationsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations'} # type: ignore 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 cce48e2940ff..f5ecd012720e 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 @@ -1,3234 +1,3171 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError -from msrest.polling import LROPoller, NoPolling -from msrestazure.polling.arm_polling import ARMPolling +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class DeploymentsOperations(object): """DeploymentsOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2019_07_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for this operation. Constant value: "2019-07-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-07-01" - - self.config = config - + self._config = config def _delete_at_scope_initial( - self, scope, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + scope, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + # Construct URL - url = self.delete_at_scope.metadata['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\._\(\)]+$') + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [202, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - - def delete_at_scope( - self, scope, deployment_name, custom_headers=None, raw=False, polling=True, **operation_config): - """Deletes a deployment from the deployment history. - - A template deployment that is currently running cannot be deleted. - Deleting a template deployment removes the associated deployment - operations. This is an asynchronous operation that returns a status of - 202 until the template deployment is successfully deleted. The Location - response header contains the URI that is used to obtain the status of - the process. While the process is running, a call to the URI in the - Location header returns a status of 202. When the process finishes, the - URI in the Location header returns a status of 204 on success. If the - asynchronous request failed, the URI in the Location header returns an - error-level status code. + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_at_scope_initial.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + def begin_delete_at_scope( + self, + scope, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """A template deployment that is currently running cannot be deleted. Deleting a template deployment removes the associated deployment operations. This is an asynchronous operation that returns a status of 202 until the template deployment is successfully deleted. The Location response header contains the URI that is used to obtain the status of the process. While the process is running, a call to the URI in the Location header returns a status of 202. When the process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. + + Deletes a deployment from the deployment history. :param scope: The scope of a deployment. :type scope: str :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns None or - ClientRawResponse if raw==True - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._delete_at_scope_initial( scope=scope, deployment_name=deployment_name, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - delete_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} + begin_delete_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore def check_existence_at_scope( - self, scope, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + scope, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Checks whether the deployment exists. :param scope: The scope of a deployment. :type scope: str :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: bool or ClientRawResponse if raw=true - :rtype: bool or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + # Construct URL - url = self.check_existence_at_scope.metadata['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\._\(\)]+$') + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204, 404]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = (response.status_code == 204) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - return deserialized - check_existence_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + 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, deployment_name, properties, location=None, custom_headers=None, raw=False, **operation_config): - parameters = models.Deployment(location=location, properties=properties) + self, + scope, # type: str + deployment_name, # type: str + properties, # type: "models.DeploymentProperties" + location=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentExtended" + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.Deployment(location=location, properties=properties) + api_version = "2019-07-01" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.create_or_update_at_scope.metadata['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\._\(\)]+$') + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'Deployment') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 201]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', response) + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', response) + deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_at_scope_initial.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore - def create_or_update_at_scope( - self, scope, deployment_name, properties, location=None, custom_headers=None, raw=False, polling=True, **operation_config): - """Deploys resources at a given scope. + def begin_create_or_update_at_scope( + self, + scope, # type: str + deployment_name, # type: str + properties, # type: "models.DeploymentProperties" + location=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """You can provide the template and parameters directly in the request or link to JSON files. - You can provide the template and parameters directly in the request or - link to JSON files. + Deploys resources at a given scope. :param scope: The scope of a deployment. :type scope: str :param deployment_name: The name of the deployment. :type deployment_name: str :param properties: The deployment properties. - :type properties: - ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentProperties + :type properties: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentProperties :param location: The location to store the deployment data. :type location: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns DeploymentExtended or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 DeploymentExtended + :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] + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._create_or_update_at_scope_initial( scope=scope, deployment_name=deployment_name, properties=properties, location=location, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - deserialized = self._deserialize('DeploymentExtended', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - create_or_update_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} + begin_create_or_update_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore def get_at_scope( - self, scope, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + scope, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentExtended" """Gets a deployment. :param scope: The scope of a deployment. :type scope: str :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentExtended or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExtended or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + # Construct URL - url = self.get_at_scope.metadata['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\._\(\)]+$') + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', response) + deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} + get_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore def cancel_at_scope( - self, scope, deployment_name, custom_headers=None, raw=False, **operation_config): - """Cancels a currently running template deployment. + self, + scope, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """You can cancel a deployment only if the provisioningState is Accepted or Running. After the deployment is canceled, the provisioningState is set to Canceled. Canceling a template deployment stops the currently running template deployment and leaves the resources partially deployed. - You can cancel a deployment only if the provisioningState is Accepted - or Running. After the deployment is canceled, the provisioningState is - set to Canceled. Canceling a template deployment stops the currently - running template deployment and leaves the resources partially - deployed. + Cancels a currently running template deployment. :param scope: The scope of a deployment. :type scope: str :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + # Construct URL - url = self.cancel_at_scope.metadata['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\._\(\)]+$') + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - cancel_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} + cancel_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore def validate_at_scope( - self, scope, deployment_name, properties, location=None, custom_headers=None, raw=False, **operation_config): - """Validates whether the specified template is syntactically correct and - will be accepted by Azure Resource Manager.. + self, + scope, # type: str + deployment_name, # type: str + properties, # type: "models.DeploymentProperties" + location=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentValidateResult" + """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. :param scope: The scope of a deployment. :type scope: str :param deployment_name: The name of the deployment. :type deployment_name: str :param properties: The deployment properties. - :type properties: - ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentProperties + :type properties: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentProperties :param location: The location to store the deployment data. :type location: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentValidateResult or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentValidateResult - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentValidateResult + :raises: ~azure.core.exceptions.HttpResponseError """ - parameters = models.Deployment(location=location, properties=properties) + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentValidateResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.Deployment(location=location, properties=properties) + api_version = "2019-07-01" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.validate_at_scope.metadata['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\._\(\)]+$') + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'Deployment') # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 400]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', response) + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', response) + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - validate_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} + validate_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore def export_template_at_scope( - self, scope, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + scope, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentExportResult" """Exports the template used for specified deployment. :param scope: The scope of a deployment. :type scope: str :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentExportResult or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExportResult - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExportResult + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExportResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + # Construct URL - url = self.export_template_at_scope.metadata['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\._\(\)]+$') + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentExportResult', response) + deserialized = self._deserialize('DeploymentExportResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - export_template_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} + export_template_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore def list_at_scope( - self, scope, filter=None, top=None, custom_headers=None, raw=False, **operation_config): + self, + scope, # type: str + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.DeploymentListResult"] """Get all the deployments at the given scope. :param scope: The scope of a deployment. :type scope: str - :param filter: The filter to apply on the operation. For example, you - can use $filter=provisioningState eq '{state}'. + :param filter: The filter to apply on the operation. For example, you can use + $filter=provisioningState eq '{state}'. :type filter: str - :param top: The number of results to get. If null is passed, returns - all deployments. + :param top: The number of results to get. If null is passed, returns all deployments. :type top: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of DeploymentExtended - :rtype: - ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtendedPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_at_scope.metadata['url'] + url = self.list_at_scope.metadata['url'] # type: ignore path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str') + 'scope': self._serialize.url("scope", scope, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.DeploymentExtendedPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/'} + return pipeline_response + return ItemPaged( + get_next, extract_data + ) + list_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/'} # type: ignore def _delete_at_tenant_scope_initial( - self, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + # Construct URL - url = self.delete_at_tenant_scope.metadata['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\._\(\)]+$') + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [202, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - - def delete_at_tenant_scope( - self, deployment_name, custom_headers=None, raw=False, polling=True, **operation_config): - """Deletes a deployment from the deployment history. - - A template deployment that is currently running cannot be deleted. - Deleting a template deployment removes the associated deployment - operations. This is an asynchronous operation that returns a status of - 202 until the template deployment is successfully deleted. The Location - response header contains the URI that is used to obtain the status of - the process. While the process is running, a call to the URI in the - Location header returns a status of 202. When the process finishes, the - URI in the Location header returns a status of 204 on success. If the - asynchronous request failed, the URI in the Location header returns an - error-level status code. + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_at_tenant_scope_initial.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + def begin_delete_at_tenant_scope( + self, + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """A template deployment that is currently running cannot be deleted. Deleting a template deployment removes the associated deployment operations. This is an asynchronous operation that returns a status of 202 until the template deployment is successfully deleted. The Location response header contains the URI that is used to obtain the status of the process. While the process is running, a call to the URI in the Location header returns a status of 202. When the process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. + + Deletes a deployment from the deployment history. :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns None or - ClientRawResponse if raw==True - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._delete_at_tenant_scope_initial( deployment_name=deployment_name, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - delete_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} + begin_delete_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore def check_existence_at_tenant_scope( - self, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Checks whether the deployment exists. :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: bool or ClientRawResponse if raw=true - :rtype: bool or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + # Construct URL - url = self.check_existence_at_tenant_scope.metadata['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\._\(\)]+$') + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204, 404]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = (response.status_code == 204) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - return deserialized - check_existence_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + 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, properties, location=None, custom_headers=None, raw=False, **operation_config): - parameters = models.Deployment(location=location, properties=properties) + self, + deployment_name, # type: str + properties, # type: "models.DeploymentProperties" + location=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentExtended" + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.Deployment(location=location, properties=properties) + api_version = "2019-07-01" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.create_or_update_at_tenant_scope.metadata['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\._\(\)]+$') + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'Deployment') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 201]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', response) + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', response) + deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_at_tenant_scope_initial.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore - def create_or_update_at_tenant_scope( - self, deployment_name, properties, location=None, custom_headers=None, raw=False, polling=True, **operation_config): - """Deploys resources at tenant scope. + def begin_create_or_update_at_tenant_scope( + self, + deployment_name, # type: str + properties, # type: "models.DeploymentProperties" + location=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """You can provide the template and parameters directly in the request or link to JSON files. - You can provide the template and parameters directly in the request or - link to JSON files. + Deploys resources at tenant scope. :param deployment_name: The name of the deployment. :type deployment_name: str :param properties: The deployment properties. - :type properties: - ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentProperties + :type properties: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentProperties :param location: The location to store the deployment data. :type location: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns DeploymentExtended or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 DeploymentExtended + :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] + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._create_or_update_at_tenant_scope_initial( deployment_name=deployment_name, properties=properties, location=location, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - deserialized = self._deserialize('DeploymentExtended', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - create_or_update_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} + begin_create_or_update_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore def get_at_tenant_scope( - self, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentExtended" """Gets a deployment. :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentExtended or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExtended or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + # Construct URL - url = self.get_at_tenant_scope.metadata['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\._\(\)]+$') + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', response) + deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} + get_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore def cancel_at_tenant_scope( - self, deployment_name, custom_headers=None, raw=False, **operation_config): - """Cancels a currently running template deployment. + self, + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """You can cancel a deployment only if the provisioningState is Accepted or Running. After the deployment is canceled, the provisioningState is set to Canceled. Canceling a template deployment stops the currently running template deployment and leaves the resources partially deployed. - You can cancel a deployment only if the provisioningState is Accepted - or Running. After the deployment is canceled, the provisioningState is - set to Canceled. Canceling a template deployment stops the currently - running template deployment and leaves the resources partially - deployed. + Cancels a currently running template deployment. :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + # Construct URL - url = self.cancel_at_tenant_scope.metadata['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\._\(\)]+$') + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - cancel_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} + cancel_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore def validate_at_tenant_scope( - self, deployment_name, properties, location=None, custom_headers=None, raw=False, **operation_config): - """Validates whether the specified template is syntactically correct and - will be accepted by Azure Resource Manager.. + self, + deployment_name, # type: str + properties, # type: "models.DeploymentProperties" + location=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentValidateResult" + """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. :param deployment_name: The name of the deployment. :type deployment_name: str :param properties: The deployment properties. - :type properties: - ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentProperties + :type properties: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentProperties :param location: The location to store the deployment data. :type location: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentValidateResult or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentValidateResult - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentValidateResult + :raises: ~azure.core.exceptions.HttpResponseError """ - parameters = models.Deployment(location=location, properties=properties) + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentValidateResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.Deployment(location=location, properties=properties) + api_version = "2019-07-01" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.validate_at_tenant_scope.metadata['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\._\(\)]+$') + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'Deployment') # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 400]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', response) + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', response) + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - validate_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} + validate_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore def export_template_at_tenant_scope( - self, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentExportResult" """Exports the template used for specified deployment. :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentExportResult or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExportResult - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExportResult + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExportResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + # Construct URL - url = self.export_template_at_tenant_scope.metadata['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\._\(\)]+$') + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentExportResult', response) + deserialized = self._deserialize('DeploymentExportResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - export_template_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} + export_template_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore def list_at_tenant_scope( - self, filter=None, top=None, custom_headers=None, raw=False, **operation_config): + self, + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.DeploymentListResult"] """Get all the deployments at the tenant scope. - :param filter: The filter to apply on the operation. For example, you - can use $filter=provisioningState eq '{state}'. + :param filter: The filter to apply on the operation. For example, you can use + $filter=provisioningState eq '{state}'. :type filter: str - :param top: The number of results to get. If null is passed, returns - all deployments. + :param top: The number of results to get. If null is passed, returns all deployments. :type top: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of DeploymentExtended - :rtype: - ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtendedPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_at_tenant_scope.metadata['url'] - + url = self.list_at_tenant_scope.metadata['url'] # type: ignore # Construct parameters - query_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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.DeploymentExtendedPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/'} + return pipeline_response + return ItemPaged( + get_next, extract_data + ) + list_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/'} # type: ignore def _delete_at_management_group_scope_initial( - self, group_id, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + # Construct URL - url = self.delete_at_management_group_scope.metadata['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\._\(\)]+$') + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [202, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - - def delete_at_management_group_scope( - self, group_id, deployment_name, custom_headers=None, raw=False, polling=True, **operation_config): - """Deletes a deployment from the deployment history. - - A template deployment that is currently running cannot be deleted. - Deleting a template deployment removes the associated deployment - operations. This is an asynchronous operation that returns a status of - 202 until the template deployment is successfully deleted. The Location - response header contains the URI that is used to obtain the status of - the process. While the process is running, a call to the URI in the - Location header returns a status of 202. When the process finishes, the - URI in the Location header returns a status of 204 on success. If the - asynchronous request failed, the URI in the Location header returns an - error-level status code. + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_at_management_group_scope_initial.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + def begin_delete_at_management_group_scope( + self, + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """A template deployment that is currently running cannot be deleted. Deleting a template deployment removes the associated deployment operations. This is an asynchronous operation that returns a status of 202 until the template deployment is successfully deleted. The Location response header contains the URI that is used to obtain the status of the process. While the process is running, a call to the URI in the Location header returns a status of 202. When the process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. + + Deletes a deployment from the deployment history. :param group_id: The management group ID. :type group_id: str :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns None or - ClientRawResponse if raw==True - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._delete_at_management_group_scope_initial( group_id=group_id, deployment_name=deployment_name, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - delete_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} + begin_delete_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore def check_existence_at_management_group_scope( - self, group_id, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Checks whether the deployment exists. :param group_id: The management group ID. :type group_id: str :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: bool or ClientRawResponse if raw=true - :rtype: bool or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + # Construct URL - url = self.check_existence_at_management_group_scope.metadata['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\._\(\)]+$') + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204, 404]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = (response.status_code == 204) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - return deserialized - check_existence_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + 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, deployment_name, properties, location=None, custom_headers=None, raw=False, **operation_config): - parameters = models.Deployment(location=location, properties=properties) + self, + group_id, # type: str + deployment_name, # type: str + properties, # type: "models.DeploymentProperties" + location=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentExtended" + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.Deployment(location=location, properties=properties) + api_version = "2019-07-01" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.create_or_update_at_management_group_scope.metadata['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\._\(\)]+$') + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'Deployment') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 201]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', response) + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', response) + deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + 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 - def create_or_update_at_management_group_scope( - self, group_id, deployment_name, properties, location=None, custom_headers=None, raw=False, polling=True, **operation_config): - """Deploys resources at management group scope. + def begin_create_or_update_at_management_group_scope( + self, + group_id, # type: str + deployment_name, # type: str + properties, # type: "models.DeploymentProperties" + location=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """You can provide the template and parameters directly in the request or link to JSON files. - You can provide the template and parameters directly in the request or - link to JSON files. + Deploys resources at management group scope. :param group_id: The management group ID. :type group_id: str :param deployment_name: The name of the deployment. :type deployment_name: str :param properties: The deployment properties. - :type properties: - ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentProperties + :type properties: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentProperties :param location: The location to store the deployment data. :type location: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns DeploymentExtended or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 DeploymentExtended + :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] + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._create_or_update_at_management_group_scope_initial( group_id=group_id, deployment_name=deployment_name, properties=properties, location=location, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - deserialized = self._deserialize('DeploymentExtended', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - create_or_update_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} + begin_create_or_update_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore def get_at_management_group_scope( - self, group_id, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentExtended" """Gets a deployment. :param group_id: The management group ID. :type group_id: str :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentExtended or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExtended or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + # Construct URL - url = self.get_at_management_group_scope.metadata['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\._\(\)]+$') + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', response) + deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} + get_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore def cancel_at_management_group_scope( - self, group_id, deployment_name, custom_headers=None, raw=False, **operation_config): - """Cancels a currently running template deployment. + self, + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """You can cancel a deployment only if the provisioningState is Accepted or Running. After the deployment is canceled, the provisioningState is set to Canceled. Canceling a template deployment stops the currently running template deployment and leaves the resources partially deployed. - You can cancel a deployment only if the provisioningState is Accepted - or Running. After the deployment is canceled, the provisioningState is - set to Canceled. Canceling a template deployment stops the currently - running template deployment and leaves the resources partially - deployed. + Cancels a currently running template deployment. :param group_id: The management group ID. :type group_id: str :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + # Construct URL - url = self.cancel_at_management_group_scope.metadata['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\._\(\)]+$') + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - cancel_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} + 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( - self, group_id, deployment_name, properties, location=None, custom_headers=None, raw=False, **operation_config): - """Validates whether the specified template is syntactically correct and - will be accepted by Azure Resource Manager.. + self, + group_id, # type: str + deployment_name, # type: str + properties, # type: "models.DeploymentProperties" + location=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentValidateResult" + """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. :param group_id: The management group ID. :type group_id: str :param deployment_name: The name of the deployment. :type deployment_name: str :param properties: The deployment properties. - :type properties: - ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentProperties + :type properties: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentProperties :param location: The location to store the deployment data. :type location: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentValidateResult or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentValidateResult - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentValidateResult + :raises: ~azure.core.exceptions.HttpResponseError """ - parameters = models.Deployment(location=location, properties=properties) + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentValidateResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.Deployment(location=location, properties=properties) + api_version = "2019-07-01" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.validate_at_management_group_scope.metadata['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\._\(\)]+$') + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'Deployment') # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 400]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', response) + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', response) + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + 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'} + validate_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore def export_template_at_management_group_scope( - self, group_id, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentExportResult" """Exports the template used for specified deployment. :param group_id: The management group ID. :type group_id: str :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentExportResult or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExportResult - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExportResult + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExportResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + # Construct URL - url = self.export_template_at_management_group_scope.metadata['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\._\(\)]+$') + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentExportResult', response) + deserialized = self._deserialize('DeploymentExportResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + 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'} + export_template_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore def list_at_management_group_scope( - self, group_id, filter=None, top=None, custom_headers=None, raw=False, **operation_config): + self, + group_id, # type: str + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.DeploymentListResult"] """Get all the deployments for a management group. :param group_id: The management group ID. :type group_id: str - :param filter: The filter to apply on the operation. For example, you - can use $filter=provisioningState eq '{state}'. + :param filter: The filter to apply on the operation. For example, you can use + $filter=provisioningState eq '{state}'. :type filter: str - :param top: The number of results to get. If null is passed, returns - all deployments. + :param top: The number of results to get. If null is passed, returns all deployments. :type top: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of DeploymentExtended - :rtype: - ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtendedPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_at_management_group_scope.metadata['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) + '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 = {} + 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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return response - - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.DeploymentExtendedPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/'} + 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/'} # type: ignore def _delete_at_subscription_scope_initial( - self, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + # Construct URL - url = self.delete_at_subscription_scope.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [202, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - - def delete_at_subscription_scope( - self, deployment_name, custom_headers=None, raw=False, polling=True, **operation_config): - """Deletes a deployment from the deployment history. - - A template deployment that is currently running cannot be deleted. - Deleting a template deployment removes the associated deployment - operations. This is an asynchronous operation that returns a status of - 202 until the template deployment is successfully deleted. The Location - response header contains the URI that is used to obtain the status of - the process. While the process is running, a call to the URI in the - Location header returns a status of 202. When the process finishes, the - URI in the Location header returns a status of 204 on success. If the - asynchronous request failed, the URI in the Location header returns an - error-level status code. + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + def begin_delete_at_subscription_scope( + self, + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """A template deployment that is currently running cannot be deleted. Deleting a template deployment removes the associated deployment operations. This is an asynchronous operation that returns a status of 202 until the template deployment is successfully deleted. The Location response header contains the URI that is used to obtain the status of the process. While the process is running, a call to the URI in the Location header returns a status of 202. When the process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. + + Deletes a deployment from the deployment history. :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns None or - ClientRawResponse if raw==True - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._delete_at_subscription_scope_initial( deployment_name=deployment_name, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - delete_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} + begin_delete_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore def check_existence_at_subscription_scope( - self, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Checks whether the deployment exists. :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: bool or ClientRawResponse if raw=true - :rtype: bool or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + # Construct URL - url = self.check_existence_at_subscription_scope.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204, 404]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = (response.status_code == 204) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - return deserialized - check_existence_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + if cls: + return cls(pipeline_response, None, {}) + + 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, properties, location=None, custom_headers=None, raw=False, **operation_config): - parameters = models.Deployment(location=location, properties=properties) + self, + deployment_name, # type: str + properties, # type: "models.DeploymentProperties" + location=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentExtended" + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.Deployment(location=location, properties=properties) + api_version = "2019-07-01" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.create_or_update_at_subscription_scope.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'Deployment') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 201]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', response) + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', response) + deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + 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 - def create_or_update_at_subscription_scope( - self, deployment_name, properties, location=None, custom_headers=None, raw=False, polling=True, **operation_config): - """Deploys resources at subscription scope. + def begin_create_or_update_at_subscription_scope( + self, + deployment_name, # type: str + properties, # type: "models.DeploymentProperties" + location=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """You can provide the template and parameters directly in the request or link to JSON files. - You can provide the template and parameters directly in the request or - link to JSON files. + Deploys resources at subscription scope. :param deployment_name: The name of the deployment. :type deployment_name: str :param properties: The deployment properties. - :type properties: - ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentProperties + :type properties: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentProperties :param location: The location to store the deployment data. :type location: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns DeploymentExtended or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 DeploymentExtended + :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] + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._create_or_update_at_subscription_scope_initial( deployment_name=deployment_name, properties=properties, location=location, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - deserialized = self._deserialize('DeploymentExtended', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - create_or_update_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} + begin_create_or_update_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore def get_at_subscription_scope( - self, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentExtended" """Gets a deployment. :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentExtended or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExtended or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + # Construct URL - url = self.get_at_subscription_scope.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', response) + deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} + get_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore def cancel_at_subscription_scope( - self, deployment_name, custom_headers=None, raw=False, **operation_config): - """Cancels a currently running template deployment. + self, + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """You can cancel a deployment only if the provisioningState is Accepted or Running. After the deployment is canceled, the provisioningState is set to Canceled. Canceling a template deployment stops the currently running template deployment and leaves the resources partially deployed. - You can cancel a deployment only if the provisioningState is Accepted - or Running. After the deployment is canceled, the provisioningState is - set to Canceled. Canceling a template deployment stops the currently - running template deployment and leaves the resources partially - deployed. + Cancels a currently running template deployment. :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + # Construct URL - url = self.cancel_at_subscription_scope.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - cancel_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} + cancel_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore def validate_at_subscription_scope( - self, deployment_name, properties, location=None, custom_headers=None, raw=False, **operation_config): - """Validates whether the specified template is syntactically correct and - will be accepted by Azure Resource Manager.. + self, + deployment_name, # type: str + properties, # type: "models.DeploymentProperties" + location=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentValidateResult" + """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. :param deployment_name: The name of the deployment. :type deployment_name: str :param properties: The deployment properties. - :type properties: - ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentProperties + :type properties: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentProperties :param location: The location to store the deployment data. :type location: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentValidateResult or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentValidateResult - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentValidateResult + :raises: ~azure.core.exceptions.HttpResponseError """ - parameters = models.Deployment(location=location, properties=properties) + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentValidateResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.Deployment(location=location, properties=properties) + api_version = "2019-07-01" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.validate_at_subscription_scope.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'Deployment') # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 400]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', response) + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', response) + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - validate_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} - + 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, properties, location=None, custom_headers=None, raw=False, **operation_config): - parameters = models.DeploymentWhatIf(location=location, properties=properties) + self, + deployment_name, # type: str + properties, # type: "models.DeploymentWhatIfProperties" + location=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.WhatIfOperationResult" + cls = kwargs.pop('cls', None) # type: ClsType["models.WhatIfOperationResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.DeploymentWhatIf(location=location, properties=properties) + api_version = "2019-07-01" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.what_if_at_subscription_scope.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'DeploymentWhatIf') # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 202]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} deserialized = None - header_dict = {} - if response.status_code == 200: - deserialized = self._deserialize('WhatIfOperationResult', response) - header_dict = { - 'Location': 'str', - 'Retry-After': 'str', - } + deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_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')) - return deserialized + if cls: + return cls(pipeline_response, deserialized, response_headers) - def what_if_at_subscription_scope( - self, deployment_name, properties, location=None, custom_headers=None, raw=False, polling=True, **operation_config): - """Returns changes that will be made by the deployment if executed at the - scope of the subscription. + return deserialized + _what_if_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + + def begin_what_if_at_subscription_scope( + self, + deployment_name, # type: str + properties, # type: "models.DeploymentWhatIfProperties" + location=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """Returns changes that will be made by the deployment if executed at the scope of the subscription. :param deployment_name: The name of the deployment. :type deployment_name: str :param properties: The deployment properties. - :type properties: - ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentWhatIfProperties + :type properties: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentWhatIfProperties :param location: The location to store the deployment data. :type location: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy + :paramtype polling: bool or ~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 WhatIfOperationResult - or ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.resource.resources.v2019_07_01.models.WhatIfOperationResult] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.resource.resources.v2019_07_01.models.WhatIfOperationResult]] - :raises: :class:`CloudError` + :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] + cls = kwargs.pop('cls', None) # type: ClsType["models.WhatIfOperationResult"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._what_if_at_subscription_scope_initial( deployment_name=deployment_name, properties=properties, location=location, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - header_dict = { - 'Location': 'str', - 'Retry-After': 'str', - } - deserialized = self._deserialize('WhatIfOperationResult', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **operation_config) + 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 return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - what_if_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} + begin_what_if_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore def export_template_at_subscription_scope( - self, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentExportResult" """Exports the template used for specified deployment. :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentExportResult or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExportResult - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExportResult + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExportResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + # Construct URL - url = self.export_template_at_subscription_scope.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentExportResult', response) + deserialized = self._deserialize('DeploymentExportResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - export_template_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} + export_template_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore def list_at_subscription_scope( - self, filter=None, top=None, custom_headers=None, raw=False, **operation_config): + self, + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.DeploymentListResult"] """Get all the deployments for a subscription. - :param filter: The filter to apply on the operation. For example, you - can use $filter=provisioningState eq '{state}'. + :param filter: The filter to apply on the operation. For example, you can use + $filter=provisioningState eq '{state}'. :type filter: str - :param top: The number of results to get. If null is passed, returns - all deployments. + :param top: The number of results to get. If null is passed, returns all deployments. :type top: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of DeploymentExtended - :rtype: - ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtendedPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_at_subscription_scope.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.DeploymentExtendedPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/'} + return pipeline_response + return ItemPaged( + get_next, extract_data + ) + list_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/'} # type: ignore def _delete_initial( - self, resource_group_name, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + # Construct URL - url = self.delete.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [202, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - - def delete( - self, resource_group_name, deployment_name, custom_headers=None, raw=False, polling=True, **operation_config): - """Deletes a deployment from the deployment history. - - A template deployment that is currently running cannot be deleted. - Deleting a template deployment removes the associated deployment - operations. Deleting a template deployment does not affect the state of - the resource group. This is an asynchronous operation that returns a - status of 202 until the template deployment is successfully deleted. - The Location response header contains the URI that is used to obtain - the status of the process. While the process is running, a call to the - URI in the Location header returns a status of 202. When the process - finishes, the URI in the Location header returns a status of 204 on - success. If the asynchronous request failed, the URI in the Location - header returns an error-level status code. - - :param resource_group_name: The name of the resource group with the - deployment to delete. The name is case insensitive. + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + def begin_delete( + self, + resource_group_name, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """A template deployment that is currently running cannot be deleted. Deleting a template deployment removes the associated deployment operations. Deleting a template deployment does not affect the state of the resource group. This is an asynchronous operation that returns a status of 202 until the template deployment is successfully deleted. The Location response header contains the URI that is used to obtain the status of the process. While the process is running, a call to the URI in the Location header returns a status of 202. When the process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. + + Deletes a deployment from the deployment history. + + :param resource_group_name: The name of the resource group with the deployment to delete. The + name is case insensitive. :type resource_group_name: str :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns None or - ClientRawResponse if raw==True - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._delete_initial( resource_group_name=resource_group_name, deployment_name=deployment_name, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore def check_existence( - self, resource_group_name, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Checks whether the deployment exists. - :param resource_group_name: The name of the resource group with the - deployment to check. The name is case insensitive. + :param resource_group_name: The name of the resource group with the deployment to check. The + name is case insensitive. :type resource_group_name: str :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: bool or ClientRawResponse if raw=true - :rtype: bool or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + # Construct URL - url = self.check_existence.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204, 404]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = (response.status_code == 204) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - return deserialized - check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + if cls: + return cls(pipeline_response, None, {}) + + 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, deployment_name, properties, location=None, custom_headers=None, raw=False, **operation_config): - parameters = models.Deployment(location=location, properties=properties) + self, + resource_group_name, # type: str + deployment_name, # type: str + properties, # type: "models.DeploymentProperties" + location=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentExtended" + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.Deployment(location=location, properties=properties) + api_version = "2019-07-01" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.create_or_update.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'Deployment') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 201]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', response) + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', response) + deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - - def create_or_update( - self, resource_group_name, deployment_name, properties, location=None, custom_headers=None, raw=False, polling=True, **operation_config): - """Deploys resources to a resource group. - - You can provide the template and parameters directly in the request or - link to JSON files. - - :param resource_group_name: The name of the resource group to deploy - the resources to. The name is case insensitive. The resource group - must already exist. + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + def begin_create_or_update( + self, + resource_group_name, # type: str + deployment_name, # type: str + properties, # type: "models.DeploymentProperties" + location=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """You can provide the template and parameters directly in the request or link to JSON files. + + Deploys resources to a resource group. + + :param resource_group_name: The name of the resource group to deploy the resources to. The name + is case insensitive. The resource group must already exist. :type resource_group_name: str :param deployment_name: The name of the deployment. :type deployment_name: str :param properties: The deployment properties. - :type properties: - ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentProperties + :type properties: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentProperties :param location: The location to store the deployment data. :type location: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns DeploymentExtended or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 DeploymentExtended + :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] + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._create_or_update_initial( resource_group_name=resource_group_name, deployment_name=deployment_name, properties=properties, location=location, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - deserialized = self._deserialize('DeploymentExtended', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore def get( - self, resource_group_name, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentExtended" """Gets a deployment. - :param resource_group_name: The name of the resource group. The name - is case insensitive. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentExtended or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExtended or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + # Construct URL - url = self.get.metadata['url'] + url = self.get.metadata['url'] # type: 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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', response) + deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore def cancel( - self, resource_group_name, deployment_name, custom_headers=None, raw=False, **operation_config): - """Cancels a currently running template deployment. + self, + resource_group_name, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """You can cancel a deployment only if the provisioningState is Accepted or Running. After the deployment is canceled, the provisioningState is set to Canceled. Canceling a template deployment stops the currently running template deployment and leaves the resource group partially deployed. - You can cancel a deployment only if the provisioningState is Accepted - or Running. After the deployment is canceled, the provisioningState is - set to Canceled. Canceling a template deployment stops the currently - running template deployment and leaves the resource group partially - deployed. + Cancels a currently running template deployment. - :param resource_group_name: The name of the resource group. The name - is case insensitive. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + # Construct URL - url = self.cancel.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - cancel.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} + if cls: + return cls(pipeline_response, None, {}) - def validate( - self, resource_group_name, deployment_name, properties, location=None, custom_headers=None, raw=False, **operation_config): - """Validates whether the specified template is syntactically correct and - will be accepted by Azure Resource Manager.. + cancel.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore - :param resource_group_name: The name of the resource group the - template will be deployed to. The name is case insensitive. + def validate( + self, + resource_group_name, # type: str + deployment_name, # type: str + properties, # type: "models.DeploymentProperties" + location=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentValidateResult" + """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. :type resource_group_name: str :param deployment_name: The name of the deployment. :type deployment_name: str :param properties: The deployment properties. - :type properties: - ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentProperties + :type properties: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentProperties :param location: The location to store the deployment data. :type location: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentValidateResult or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentValidateResult - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentValidateResult + :raises: ~azure.core.exceptions.HttpResponseError """ - parameters = models.Deployment(location=location, properties=properties) + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentValidateResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.Deployment(location=location, properties=properties) + api_version = "2019-07-01" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.validate.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'Deployment') # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 400]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', response) + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', response) + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - validate.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} - + validate.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore def _what_if_initial( - self, resource_group_name, deployment_name, properties, location=None, custom_headers=None, raw=False, **operation_config): - parameters = models.DeploymentWhatIf(location=location, properties=properties) + self, + resource_group_name, # type: str + deployment_name, # type: str + properties, # type: "models.DeploymentWhatIfProperties" + location=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.WhatIfOperationResult" + cls = kwargs.pop('cls', None) # type: ClsType["models.WhatIfOperationResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.DeploymentWhatIf(location=location, properties=properties) + api_version = "2019-07-01" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.what_if.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'DeploymentWhatIf') # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 202]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} deserialized = None - header_dict = {} - if response.status_code == 200: - deserialized = self._deserialize('WhatIfOperationResult', response) - header_dict = { - 'Location': 'str', - 'Retry-After': 'str', - } + deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_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')) - return deserialized - - def what_if( - self, resource_group_name, deployment_name, properties, location=None, custom_headers=None, raw=False, polling=True, **operation_config): - """Returns changes that will be made by the deployment if executed at the - scope of the resource group. + if cls: + return cls(pipeline_response, deserialized, response_headers) - :param resource_group_name: The name of the resource group the - template will be deployed to. The name is case insensitive. + return deserialized + _what_if_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + + def begin_what_if( + self, + resource_group_name, # type: str + deployment_name, # type: str + properties, # type: "models.DeploymentWhatIfProperties" + location=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """Returns changes that will be made by the deployment if executed at the scope of the resource group. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. :type resource_group_name: str :param deployment_name: The name of the deployment. :type deployment_name: str :param properties: The deployment properties. - :type properties: - ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentWhatIfProperties + :type properties: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentWhatIfProperties :param location: The location to store the deployment data. :type location: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy + :paramtype polling: bool or ~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 WhatIfOperationResult - or ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.resource.resources.v2019_07_01.models.WhatIfOperationResult] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.resource.resources.v2019_07_01.models.WhatIfOperationResult]] - :raises: :class:`CloudError` + :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] + cls = kwargs.pop('cls', None) # type: ClsType["models.WhatIfOperationResult"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._what_if_initial( resource_group_name=resource_group_name, deployment_name=deployment_name, properties=properties, location=location, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - header_dict = { - 'Location': 'str', - 'Retry-After': 'str', - } - deserialized = self._deserialize('WhatIfOperationResult', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **operation_config) + 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 return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - what_if.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} + begin_what_if.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore def export_template( - self, resource_group_name, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentExportResult" """Exports the template used for specified deployment. - :param resource_group_name: The name of the resource group. The name - is case insensitive. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentExportResult or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExportResult - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExportResult + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExportResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + # Construct URL - url = self.export_template.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentExportResult', response) + deserialized = self._deserialize('DeploymentExportResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} + export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore def list_by_resource_group( - self, resource_group_name, filter=None, top=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.DeploymentListResult"] """Get all the deployments for a resource group. - :param resource_group_name: The name of the resource group with the - deployments to get. The name is case insensitive. + :param resource_group_name: The name of the resource group with the deployments to get. The + name is case insensitive. :type resource_group_name: str - :param filter: The filter to apply on the operation. For example, you - can use $filter=provisioningState eq '{state}'. + :param filter: The filter to apply on the operation. For example, you can use + $filter=provisioningState eq '{state}'. :type filter: str - :param top: The number of results to get. If null is passed, returns - all deployments. + :param top: The number of results to get. If null is passed, returns all deployments. :type top: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of DeploymentExtended - :rtype: - ~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtendedPaged[~azure.mgmt.resource.resources.v2019_07_01.models.DeploymentExtended] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_by_resource_group.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.DeploymentExtendedPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/'} + return ItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/'} # type: ignore def calculate_template_hash( - self, template, custom_headers=None, raw=False, **operation_config): + self, + template, # type: object + **kwargs # type: Any + ): + # type: (...) -> "models.TemplateHashResult" """Calculate the hash of the given template. :param template: The template provided to calculate hash. :type template: object - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: TemplateHashResult or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_07_01.models.TemplateHashResult - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateHashResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.TemplateHashResult + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TemplateHashResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + content_type = kwargs.pop("content_type", "application/json") + # Construct URL - url = self.calculate_template_hash.metadata['url'] + url = self.calculate_template_hash.metadata['url'] # type: ignore # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(template, 'object') # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('TemplateHashResult', response) + deserialized = self._deserialize('TemplateHashResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - calculate_template_hash.metadata = {'url': '/providers/Microsoft.Resources/calculateTemplateHash'} + 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 9a0432e93554..3904c40513c9 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 @@ -1,102 +1,106 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class Operations(object): """Operations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2019_07_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for this operation. Constant value: "2019-07-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-07-01" - - self.config = config + self._config = config def list( - self, custom_headers=None, raw=False, **operation_config): + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.OperationListResult"] """Lists all of the available Microsoft.Resources REST API operations. - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of Operation - :rtype: - ~azure.mgmt.resource.resources.v2019_07_01.models.OperationPaged[~azure.mgmt.resource.resources.v2019_07_01.models.Operation] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of OperationListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['url'] - + url = self.list.metadata['url'] # type: ignore # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('OperationListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.OperationPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list.metadata = {'url': '/providers/Microsoft.Resources/operations'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.Resources/operations'} # type: ignore 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 17f960977e88..baa9cd2d0e19 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 @@ -1,437 +1,417 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class ProvidersOperations(object): """ProvidersOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2019_07_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for this operation. Constant value: "2019-07-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-07-01" - - self.config = config + self._config = config def unregister( - self, resource_provider_namespace, custom_headers=None, raw=False, **operation_config): + self, + resource_provider_namespace, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.Provider" """Unregisters a subscription from a resource provider. - :param resource_provider_namespace: The namespace of the resource - provider to unregister. + :param resource_provider_namespace: The namespace of the resource provider to unregister. :type resource_provider_namespace: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: Provider or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.Provider or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Provider or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.Provider + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Provider"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + # Construct URL - url = self.unregister.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('Provider', response) + deserialized = self._deserialize('Provider', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - unregister.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister'} + unregister.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister'} # type: ignore def register( - self, resource_provider_namespace, custom_headers=None, raw=False, **operation_config): + self, + resource_provider_namespace, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.Provider" """Registers a subscription with a resource provider. - :param resource_provider_namespace: The namespace of the resource - provider to register. + :param resource_provider_namespace: The namespace of the resource provider to register. :type resource_provider_namespace: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: Provider or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.Provider or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Provider or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.Provider + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Provider"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + # Construct URL - url = self.register.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('Provider', response) + deserialized = self._deserialize('Provider', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - register.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register'} + register.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register'} # type: ignore def list( - self, top=None, expand=None, custom_headers=None, raw=False, **operation_config): + self, + top=None, # type: Optional[int] + expand=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.ProviderListResult"] """Gets all resource providers for a subscription. - :param top: The number of results to return. If null is passed returns - all deployments. + :param top: The number of results to return. If null is passed returns all deployments. :type top: int - :param expand: The properties to include in the results. For example, - use &$expand=metadata in the query string to retrieve resource - provider metadata. To include property aliases in response, use - $expand=resourceTypes/aliases. + :param expand: The properties to include in the results. For example, use &$expand=metadata in + the query string to retrieve resource provider metadata. To include property aliases in + response, use $expand=resourceTypes/aliases. :type expand: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of Provider - :rtype: - ~azure.mgmt.resource.resources.v2019_07_01.models.ProviderPaged[~azure.mgmt.resource.resources.v2019_07_01.models.Provider] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of ProviderListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['url'] + url = self.list.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_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 = {} + 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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('ProviderListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.ProviderPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers'} # type: ignore def list_at_tenant_scope( - self, top=None, expand=None, custom_headers=None, raw=False, **operation_config): + self, + top=None, # type: Optional[int] + expand=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.ProviderListResult"] """Gets all resource providers for the tenant. - :param top: The number of results to return. If null is passed returns - all providers. + :param top: The number of results to return. If null is passed returns all providers. :type top: int - :param expand: The properties to include in the results. For example, - use &$expand=metadata in the query string to retrieve resource - provider metadata. To include property aliases in response, use - $expand=resourceTypes/aliases. + :param expand: The properties to include in the results. For example, use &$expand=metadata in + the query string to retrieve resource provider metadata. To include property aliases in + response, use $expand=resourceTypes/aliases. :type expand: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of Provider - :rtype: - ~azure.mgmt.resource.resources.v2019_07_01.models.ProviderPaged[~azure.mgmt.resource.resources.v2019_07_01.models.Provider] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of ProviderListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_at_tenant_scope.metadata['url'] - + url = self.list_at_tenant_scope.metadata['url'] # type: ignore # Construct parameters - query_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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('ProviderListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.ProviderPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_at_tenant_scope.metadata = {'url': '/providers'} + return ItemPaged( + get_next, extract_data + ) + list_at_tenant_scope.metadata = {'url': '/providers'} # type: ignore def get( - self, resource_provider_namespace, expand=None, custom_headers=None, raw=False, **operation_config): + self, + resource_provider_namespace, # type: str + expand=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.Provider" """Gets the specified resource provider. - :param resource_provider_namespace: The namespace of the resource - provider. + :param resource_provider_namespace: The namespace of the resource provider. :type resource_provider_namespace: str - :param expand: The $expand query parameter. For example, to include - property aliases in response, use $expand=resourceTypes/aliases. + :param expand: The $expand query parameter. For example, to include property aliases in + response, use $expand=resourceTypes/aliases. :type expand: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: Provider or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.Provider or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Provider or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.Provider + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Provider"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + # Construct URL - url = self.get.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('Provider', response) + deserialized = self._deserialize('Provider', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}'} # type: ignore def get_at_tenant_scope( - self, resource_provider_namespace, expand=None, custom_headers=None, raw=False, **operation_config): + self, + resource_provider_namespace, # type: str + expand=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.Provider" """Gets the specified resource provider at the tenant level. - :param resource_provider_namespace: The namespace of the resource - provider. + :param resource_provider_namespace: The namespace of the resource provider. :type resource_provider_namespace: str - :param expand: The $expand query parameter. For example, to include - property aliases in response, use $expand=resourceTypes/aliases. + :param expand: The $expand query parameter. For example, to include property aliases in + response, use $expand=resourceTypes/aliases. :type expand: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: Provider or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.Provider or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Provider or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.Provider + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Provider"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + # Construct URL - url = self.get_at_tenant_scope.metadata['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') + 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('Provider', response) + deserialized = self._deserialize('Provider', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get_at_tenant_scope.metadata = {'url': '/providers/{resourceProviderNamespace}'} + 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 c84f55a2f5d7..6c3126d97e5b 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 @@ -1,530 +1,517 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError -from msrest.polling import LROPoller, NoPolling -from msrestazure.polling.arm_polling import ARMPolling +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, List, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class ResourceGroupsOperations(object): """ResourceGroupsOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2019_07_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for this operation. Constant value: "2019-07-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-07-01" - - self.config = config + self._config = config def check_existence( - self, resource_group_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Checks whether a resource group exists. - :param resource_group_name: The name of the resource group to check. - The name is case insensitive. + :param resource_group_name: The name of the resource group to check. The name is case + insensitive. :type resource_group_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: bool or ClientRawResponse if raw=true - :rtype: bool or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + # Construct URL - url = self.check_existence.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204, 404]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = (response.status_code == 204) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - return deserialized - check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore def create_or_update( - self, resource_group_name, parameters, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + parameters, # type: "models.ResourceGroup" + **kwargs # type: Any + ): + # type: (...) -> "models.ResourceGroup" """Creates or updates a resource group. - :param resource_group_name: The name of the resource group to create - or update. Can include alphanumeric, underscore, parentheses, hyphen, - period (except at end), and Unicode characters that match the allowed - characters. + :param resource_group_name: The name of the resource group to create or update. Can include + alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters + that match the allowed characters. :type resource_group_name: str - :param parameters: Parameters supplied to the create or update a - resource group. - :type parameters: - ~azure.mgmt.resource.resources.v2019_07_01.models.ResourceGroup - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: ResourceGroup or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_07_01.models.ResourceGroup or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :param parameters: Parameters supplied to the create or update a resource group. + :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.ResourceGroup + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.ResourceGroup + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceGroup"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + content_type = kwargs.pop("content_type", "application/json") + # Construct URL - url = self.create_or_update.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'ResourceGroup') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 201]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ResourceGroup', response) + deserialized = self._deserialize('ResourceGroup', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('ResourceGroup', response) + deserialized = self._deserialize('ResourceGroup', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} - + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore def _delete_initial( - self, resource_group_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + # Construct URL - url = self.delete.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 202]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore - def delete( - self, resource_group_name, custom_headers=None, raw=False, polling=True, **operation_config): - """Deletes a resource group. + def begin_delete( + self, + resource_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """When you delete a resource group, all of its resources are also deleted. Deleting a resource group deletes all of its template deployments and currently stored operations. - When you delete a resource group, all of its resources are also - deleted. Deleting a resource group deletes all of its template - deployments and currently stored operations. + Deletes a resource group. - :param resource_group_name: The name of the resource group to delete. - The name is case insensitive. + :param resource_group_name: The name of the resource group to delete. The name is case + insensitive. :type resource_group_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns None or - ClientRawResponse if raw==True - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._delete_initial( resource_group_name=resource_group_name, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore def get( - self, resource_group_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.ResourceGroup" """Gets a resource group. - :param resource_group_name: The name of the resource group to get. The - name is case insensitive. + :param resource_group_name: The name of the resource group to get. The name is case + insensitive. :type resource_group_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: ResourceGroup or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_07_01.models.ResourceGroup or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.ResourceGroup + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceGroup"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + # Construct URL - url = self.get.metadata['url'] + url = self.get.metadata['url'] # type: 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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('ResourceGroup', response) + deserialized = self._deserialize('ResourceGroup', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore def update( - self, resource_group_name, parameters, custom_headers=None, raw=False, **operation_config): - """Updates a resource group. - - Resource groups can be updated through a simple PATCH operation to a - group address. The format of the request is the same as that for - creating a resource group. If a field is unspecified, the current value - is retained. - - :param resource_group_name: The name of the resource group to update. - The name is case insensitive. + self, + resource_group_name, # type: str + parameters, # type: "models.ResourceGroupPatchable" + **kwargs # type: Any + ): + # type: (...) -> "models.ResourceGroup" + """Resource groups can be updated through a simple PATCH operation to a group address. The format of the request is the same as that for creating a resource group. If a field is unspecified, the current value is retained. + + Updates a resource group. + + :param resource_group_name: The name of the resource group to update. The name is case + insensitive. :type resource_group_name: str :param parameters: Parameters supplied to update a resource group. - :type parameters: - ~azure.mgmt.resource.resources.v2019_07_01.models.ResourceGroupPatchable - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: ResourceGroup or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_07_01.models.ResourceGroup or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :type parameters: ~azure.mgmt.resource.resources.v2019_07_01.models.ResourceGroupPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.ResourceGroup + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceGroup"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + content_type = kwargs.pop("content_type", "application/json") + # Construct URL - url = self.update.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'ResourceGroupPatchable') # Construct and send request - request = self._client.patch(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('ResourceGroup', response) + deserialized = self._deserialize('ResourceGroup', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore def export_template( - self, resource_group_name, resources=None, options=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + resources=None, # type: Optional[List[str]] + options=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.ResourceGroupExportResult" """Captures the specified resource group as a template. - :param resource_group_name: The name of the resource group to export - as a template. + :param resource_group_name: The name of the resource group to export as a template. :type resource_group_name: str - :param resources: The IDs of the resources to filter the export by. To - export all resources, supply an array with single entry '*'. + :param 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', - 'SkipResourceNameParameterization', 'SkipAllParameterization' + :param options: The export template options. A CSV-formatted list containing zero or more of + the following: 'IncludeParameterDefaultValue', 'IncludeComments', + 'SkipResourceNameParameterization', 'SkipAllParameterization'. :type options: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: ResourceGroupExportResult or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_07_01.models.ResourceGroupExportResult - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroupExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.ResourceGroupExportResult + :raises: ~azure.core.exceptions.HttpResponseError """ - parameters = models.ExportTemplateRequest(resources=resources, options=options) + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceGroupExportResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.ExportTemplateRequest(resources=resources, options=options) + api_version = "2019-07-01" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.export_template.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'ExportTemplateRequest') # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('ResourceGroupExportResult', response) + deserialized = self._deserialize('ResourceGroupExportResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate'} + export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate'} # type: ignore def list( - self, filter=None, top=None, custom_headers=None, raw=False, **operation_config): + self, + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.ResourceGroupListResult"] """Gets all the resource groups for a subscription. - :param filter: The filter to apply on the operation.

You can - filter by tag names and values. For example, to filter for a tag name - and value, use $filter=tagName eq 'tag1' and tagValue eq 'Value1' + :param filter: The filter to apply on the operation.:code:`
`:code:`
`You can filter by + tag names and values. For example, to filter for a tag name and value, use $filter=tagName eq + 'tag1' and tagValue eq 'Value1'. :type filter: str - :param top: The number of results to return. If null is passed, - returns all resource groups. + :param top: The number of results to return. If null is passed, returns all resource groups. :type top: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of ResourceGroup - :rtype: - ~azure.mgmt.resource.resources.v2019_07_01.models.ResourceGroupPaged[~azure.mgmt.resource.resources.v2019_07_01.models.ResourceGroup] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['url'] + url = self.list.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_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 = {} + 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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('ResourceGroupListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.ResourceGroupPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups'} # type: ignore 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 855b603dc10a..ced0cb3521ab 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 @@ -1,558 +1,577 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError -from msrest.polling import LROPoller, NoPolling -from msrestazure.polling.arm_polling import ARMPolling +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, List, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class ResourcesOperations(object): """ResourcesOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2019_07_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for this operation. Constant value: "2019-07-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-07-01" - - self.config = config + self._config = config def list_by_resource_group( - self, resource_group_name, filter=None, expand=None, top=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + filter=None, # type: Optional[str] + expand=None, # type: Optional[str] + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.ResourceListResult"] """Get all the resources for a resource group. - :param resource_group_name: The resource group with the resources to - get. + :param resource_group_name: The resource group with the resources to get. :type resource_group_name: str - :param filter: The filter to apply on the operation.

The - properties you can use for eq (equals) or ne (not equals) are: - location, resourceType, name, resourceGroup, identity, - identity/principalId, plan, plan/publisher, plan/product, plan/name, - plan/version, and plan/promotionCode.

For example, to filter by - a resource type, use: $filter=resourceType eq - 'Microsoft.Network/virtualNetworks'

You can use - substringof(value, property) in the filter. The properties you can use - for substring are: name and resourceGroup.

For example, to get - all resources with 'demo' anywhere in the name, use: - $filter=substringof('demo', name)

You can link more than one - substringof together by adding and/or operators.

You can filter - by tag names and values. For example, to filter for a tag name and - value, use $filter=tagName eq 'tag1' and tagValue eq - 'Value1'

You can use some properties together when filtering. - The combinations you can use are: substringof and/or resourceType, - plan and plan/publisher and plan/name, identity and - identity/principalId. + :param filter: The filter to apply on the operation.:code:`
`:code:`
`The properties you + can use for eq (equals) or ne (not equals) are: location, resourceType, name, resourceGroup, + identity, identity/principalId, plan, plan/publisher, plan/product, plan/name, plan/version, + and plan/promotionCode.:code:`
`:code:`
`For example, to filter by a resource type, use: + $filter=resourceType eq 'Microsoft.Network/virtualNetworks':code:`
`:code:`
`You can use + substringof(value, property) in the filter. The properties you can use for substring are: name + and resourceGroup.:code:`
`:code:`
`For example, to get all resources with 'demo' + anywhere in the name, use: $filter=substringof('demo', name):code:`
`:code:`
`You can + link more than one substringof together by adding and/or operators.:code:`
`:code:`
`You + can filter by tag names and values. For example, to filter for a tag name and value, use + $filter=tagName eq 'tag1' and tagValue eq 'Value1':code:`
`:code:`
`You can use some + properties together when filtering. The combinations you can use are: substringof and/or + resourceType, plan and plan/publisher and plan/name, identity and identity/principalId. :type filter: str - :param expand: Comma-separated list of additional properties to be - included in the response. Valid values include `createdTime`, - `changedTime` and `provisioningState`. For example, - `$expand=createdTime,changedTime`. + :param expand: Comma-separated list of additional properties to be included in the response. + Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, + ``$expand=createdTime,changedTime``. :type expand: str - :param top: The 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 - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of GenericResourceExpanded - :rtype: - ~azure.mgmt.resource.resources.v2019_07_01.models.GenericResourceExpandedPaged[~azure.mgmt.resource.resources.v2019_07_01.models.GenericResourceExpanded] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of ResourceListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_by_resource_group.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('ResourceListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response - - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.GenericResourceExpandedPaged(internal_paging, self._deserialize.dependencies, header_dict) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return deserialized - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources'} + return pipeline_response + return ItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources'} # type: ignore def _move_resources_initial( - self, source_resource_group_name, resources=None, target_resource_group=None, custom_headers=None, raw=False, **operation_config): - parameters = models.ResourcesMoveInfo(resources=resources, target_resource_group=target_resource_group) + self, + source_resource_group_name, # type: str + resources=None, # type: Optional[List[str]] + target_resource_group=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.ResourcesMoveInfo(resources=resources, target_resource_group=target_resource_group) + api_version = "2019-07-01" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.move_resources.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'ResourcesMoveInfo') + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [202, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - - def move_resources( - self, source_resource_group_name, resources=None, target_resource_group=None, custom_headers=None, raw=False, polling=True, **operation_config): - """Moves resources from one resource group to another resource group. - - The resources to move must be in the same source resource group. The - target resource group may be in a different subscription. When moving - resources, both the source group and the target group are locked for - the duration of the operation. Write and delete operations are blocked - on the groups until the move completes. . - - :param source_resource_group_name: The name of the resource group - containing the resources to move. + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore + + def begin_move_resources( + self, + source_resource_group_name, # type: str + resources=None, # type: Optional[List[str]] + target_resource_group=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """The resources to move must be in the same source resource group. The target resource group may be in a different subscription. When moving resources, both the source group and the target group are locked for the duration of the operation. Write and delete operations are blocked on the groups until the move completes. + + Moves resources from one resource group to another resource group. + + :param source_resource_group_name: The name of the resource group containing the resources to + move. :type source_resource_group_name: str :param resources: The IDs of the resources. :type resources: list[str] :param target_resource_group: The target resource group. :type target_resource_group: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns None or - ClientRawResponse if raw==True - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._move_resources_initial( source_resource_group_name=source_resource_group_name, resources=resources, target_resource_group=target_resource_group, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} - + begin_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore def _validate_move_resources_initial( - self, source_resource_group_name, resources=None, target_resource_group=None, custom_headers=None, raw=False, **operation_config): - parameters = models.ResourcesMoveInfo(resources=resources, target_resource_group=target_resource_group) + self, + source_resource_group_name, # type: str + resources=None, # type: Optional[List[str]] + target_resource_group=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.ResourcesMoveInfo(resources=resources, target_resource_group=target_resource_group) + api_version = "2019-07-01" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.validate_move_resources.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'ResourcesMoveInfo') + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [202, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - - def validate_move_resources( - self, source_resource_group_name, resources=None, target_resource_group=None, custom_headers=None, raw=False, polling=True, **operation_config): - """Validates whether resources can be moved from one resource group to - another resource group. - - This operation checks whether the specified resources can be moved to - the target. The resources to move must be in the same source resource - group. The target resource group may be in a different subscription. If - validation succeeds, it returns HTTP response code 204 (no content). If - validation fails, it returns HTTP response code 409 (Conflict) with an - error message. Retrieve the URL in the Location header value to check - the result of the long-running operation. - - :param source_resource_group_name: The name of the resource group - containing the resources to validate for move. + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _validate_move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} # type: ignore + + def begin_validate_move_resources( + self, + source_resource_group_name, # type: str + resources=None, # type: Optional[List[str]] + target_resource_group=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """This operation checks whether the specified resources can be moved to the target. The resources to move must be in the same source resource group. The target resource group may be in a different subscription. If validation succeeds, it returns HTTP response code 204 (no content). If validation fails, it returns HTTP response code 409 (Conflict) with an error message. Retrieve the URL in the Location header value to check the result of the long-running operation. + + Validates whether resources can be moved from one resource group to another resource group. + + :param source_resource_group_name: The name of the resource group containing the resources to + validate for move. :type source_resource_group_name: str :param resources: The IDs of the resources. :type resources: list[str] :param target_resource_group: The target resource group. :type target_resource_group: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns None or - ClientRawResponse if raw==True - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._validate_move_resources_initial( source_resource_group_name=source_resource_group_name, resources=resources, target_resource_group=target_resource_group, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - validate_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} + begin_validate_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} # type: ignore def list( - self, filter=None, expand=None, top=None, custom_headers=None, raw=False, **operation_config): + self, + filter=None, # type: Optional[str] + expand=None, # type: Optional[str] + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.ResourceListResult"] """Get all the resources in a subscription. - :param filter: The filter to apply on the operation.

The - properties you can use for eq (equals) or ne (not equals) are: - location, resourceType, name, resourceGroup, identity, - identity/principalId, plan, plan/publisher, plan/product, plan/name, - plan/version, and plan/promotionCode.

For example, to filter by - a resource type, use: $filter=resourceType eq - 'Microsoft.Network/virtualNetworks'

You can use - substringof(value, property) in the filter. The properties you can use - for substring are: name and resourceGroup.

For example, to get - all resources with 'demo' anywhere in the name, use: - $filter=substringof('demo', name)

You can link more than one - substringof together by adding and/or operators.

You can filter - by tag names and values. For example, to filter for a tag name and - value, use $filter=tagName eq 'tag1' and tagValue eq - 'Value1'

You can use some properties together when filtering. - The combinations you can use are: substringof and/or resourceType, - plan and plan/publisher and plan/name, identity and - identity/principalId. + :param filter: The filter to apply on the operation.:code:`
`:code:`
`The properties you + can use for eq (equals) or ne (not equals) are: location, resourceType, name, resourceGroup, + identity, identity/principalId, plan, plan/publisher, plan/product, plan/name, plan/version, + and plan/promotionCode.:code:`
`:code:`
`For example, to filter by a resource type, use: + $filter=resourceType eq 'Microsoft.Network/virtualNetworks':code:`
`:code:`
`You can use + substringof(value, property) in the filter. The properties you can use for substring are: name + and resourceGroup.:code:`
`:code:`
`For example, to get all resources with 'demo' + anywhere in the name, use: $filter=substringof('demo', name):code:`
`:code:`
`You can + link more than one substringof together by adding and/or operators.:code:`
`:code:`
`You + can filter by tag names and values. For example, to filter for a tag name and value, use + $filter=tagName eq 'tag1' and tagValue eq 'Value1':code:`
`:code:`
`You can use some + properties together when filtering. The combinations you can use are: substringof and/or + resourceType, plan and plan/publisher and plan/name, identity and identity/principalId. :type filter: str - :param expand: Comma-separated list of additional properties to be - included in the response. Valid values include `createdTime`, - `changedTime` and `provisioningState`. For example, - `$expand=createdTime,changedTime`. + :param expand: Comma-separated list of additional properties to be included in the response. + Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, + ``$expand=createdTime,changedTime``. :type expand: str - :param top: The number of results to return. If null is passed, - returns all resource groups. + :param top: The number of results to return. If null is passed, returns all resource groups. :type top: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of GenericResourceExpanded - :rtype: - ~azure.mgmt.resource.resources.v2019_07_01.models.GenericResourceExpandedPaged[~azure.mgmt.resource.resources.v2019_07_01.models.GenericResourceExpanded] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of ResourceListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['url'] + url = self.list.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_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 = {} + 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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('ResourceListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.GenericResourceExpandedPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resources'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resources'} # type: ignore def check_existence( - self, resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, api_version, custom_headers=None, raw=False, **operation_config): + self, + 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: (...) -> None """Checks whether a resource exists. - :param resource_group_name: The name of the resource group containing - the resource to check. The name is case insensitive. + :param resource_group_name: The name of the resource group containing the resource to check. + The name is case insensitive. :type resource_group_name: str - :param resource_provider_namespace: The resource provider of the - resource to check. + :param resource_provider_namespace: The resource provider of the resource to check. :type resource_provider_namespace: str :param parent_resource_path: The parent resource identity. :type parent_resource_path: str :param resource_type: The resource type. :type resource_type: str - :param resource_name: The name of the resource to check whether it - exists. + :param resource_name: The name of the resource to check whether it exists. :type resource_name: str - :param api_version: The API version to use for the operation. - :type api_version: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: bool or ClientRawResponse if raw=true - :rtype: bool or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + # Construct URL - url = self.check_existence.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204, 404]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = (response.status_code == 204) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - return deserialized - check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + 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, resource_provider_namespace, parent_resource_path, resource_type, resource_name, api_version, custom_headers=None, raw=False, **operation_config): + self, + 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: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + # Construct URL - url = self.delete.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - - def delete( - self, resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, api_version, custom_headers=None, raw=False, polling=True, **operation_config): + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + def begin_delete( + self, + 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: (...) -> LROPoller """Deletes a resource. - :param resource_group_name: The name of the resource group that - contains the resource to delete. The name is case insensitive. + :param resource_group_name: The name of the resource group that contains the resource to + delete. The name is case insensitive. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource - provider. + :param resource_provider_namespace: The namespace of the resource provider. :type resource_provider_namespace: str :param parent_resource_path: The parent resource identity. :type parent_resource_path: str @@ -560,109 +579,122 @@ def delete( :type resource_type: str :param resource_name: The name of the resource to delete. :type resource_name: str - :param api_version: The API version to use for the operation. - :type api_version: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns None or - ClientRawResponse if raw==True - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._delete_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, - api_version=api_version, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} - + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore def _create_or_update_initial( - self, resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, api_version, parameters, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + parameters, # type: "models.GenericResource" + **kwargs # type: Any + ): + # type: (...) -> "models.GenericResource" + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + content_type = kwargs.pop("content_type", "application/json") + # Construct URL - url = self.create_or_update.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'GenericResource') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 201, 202]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('GenericResource', response) + deserialized = self._deserialize('GenericResource', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('GenericResource', response) + deserialized = self._deserialize('GenericResource', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - - def create_or_update( - self, resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, api_version, parameters, custom_headers=None, raw=False, polling=True, **operation_config): + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + def begin_create_or_update( + self, + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + parameters, # type: "models.GenericResource" + **kwargs # type: Any + ): + # type: (...) -> LROPoller """Creates a resource. - :param resource_group_name: The name of the resource group for the - resource. The name is case insensitive. + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource - provider. + :param resource_provider_namespace: The namespace of the resource provider. :type resource_provider_namespace: str :param parent_resource_path: The parent resource identity. :type parent_resource_path: str @@ -670,117 +702,125 @@ def create_or_update( :type resource_type: str :param resource_name: The name of the resource to create. :type resource_name: str - :param api_version: The API version to use for the operation. - :type api_version: str :param parameters: Parameters for creating or updating the resource. - :type parameters: - ~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :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 polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns GenericResource or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 GenericResource + :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] + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._create_or_update_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, - api_version=api_version, parameters=parameters, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - deserialized = self._deserialize('GenericResource', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('GenericResource', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} - + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore def _update_initial( - self, resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, api_version, parameters, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + parameters, # type: "models.GenericResource" + **kwargs # type: Any + ): + # type: (...) -> "models.GenericResource" + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + content_type = kwargs.pop("content_type", "application/json") + # Construct URL - url = self.update.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'GenericResource') # Construct and send request - request = self._client.patch(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 202]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('GenericResource', response) + deserialized = self._deserialize('GenericResource', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - - def update( - self, resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, api_version, parameters, custom_headers=None, raw=False, polling=True, **operation_config): + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + def begin_update( + self, + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + parameters, # type: "models.GenericResource" + **kwargs # type: Any + ): + # type: (...) -> LROPoller """Updates a resource. - :param resource_group_name: The name of the resource group for the - resource. The name is case insensitive. + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource - provider. + :param resource_provider_namespace: The namespace of the resource provider. :type resource_provider_namespace: str :param parent_resource_path: The parent resource identity. :type parent_resource_path: str @@ -788,64 +828,63 @@ def update( :type resource_type: str :param resource_name: The name of the resource to update. :type resource_name: str - :param api_version: The API version to use for the operation. - :type api_version: str :param parameters: Parameters for updating the resource. - :type parameters: - ~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :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 polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns GenericResource or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 GenericResource + :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] + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._update_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, - api_version=api_version, parameters=parameters, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - deserialized = self._deserialize('GenericResource', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('GenericResource', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore def get( - self, resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, api_version, custom_headers=None, raw=False, **operation_config): + self, + 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: (...) -> "models.GenericResource" """Gets a resource. - :param resource_group_name: The name of the resource group containing - the resource to get. The name is case insensitive. + :param resource_group_name: The name of the resource group containing the resource to get. The + name is case insensitive. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource - provider. + :param resource_provider_namespace: The namespace of the resource provider. :type resource_provider_namespace: str :param parent_resource_path: The parent resource identity. :type parent_resource_path: str @@ -853,461 +892,443 @@ def get( :type resource_type: str :param resource_name: The name of the resource to get. :type resource_name: str - :param api_version: The API version to use for the operation. - :type api_version: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: GenericResource or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GenericResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + # Construct URL - url = self.get.metadata['url'] + url = self.get.metadata['url'] # type: 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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('GenericResource', response) + deserialized = self._deserialize('GenericResource', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore def check_existence_by_id( - self, resource_id, api_version, custom_headers=None, raw=False, **operation_config): + self, + resource_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Checks by ID whether a resource exists. - :param resource_id: The fully qualified ID of the resource, including - the resource name and resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. :type resource_id: str - :param api_version: The API version to use for the operation. - :type api_version: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: bool or ClientRawResponse if raw=true - :rtype: bool or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + # Construct URL - url = self.check_existence_by_id.metadata['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) + '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 = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204, 404]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = (response.status_code == 204) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - return deserialized - check_existence_by_id.metadata = {'url': '/{resourceId}'} + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + return 200 <= response.status_code <= 299 + check_existence_by_id.metadata = {'url': '/{resourceId}'} # type: ignore def _delete_by_id_initial( - self, resource_id, api_version, custom_headers=None, raw=False, **operation_config): + self, + resource_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + # Construct URL - url = self.delete_by_id.metadata['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) + '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 = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + _delete_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore - def delete_by_id( - self, resource_id, api_version, custom_headers=None, raw=False, polling=True, **operation_config): + def begin_delete_by_id( + self, + resource_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> LROPoller """Deletes a resource by ID. - :param resource_id: The fully qualified ID of the resource, including - the resource name and resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. :type resource_id: str - :param api_version: The API version to use for the operation. - :type api_version: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns None or - ClientRawResponse if raw==True - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._delete_by_id_initial( resource_id=resource_id, - api_version=api_version, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - delete_by_id.metadata = {'url': '/{resourceId}'} - + begin_delete_by_id.metadata = {'url': '/{resourceId}'} # type: ignore def _create_or_update_by_id_initial( - self, resource_id, api_version, parameters, custom_headers=None, raw=False, **operation_config): + self, + resource_id, # type: str + parameters, # type: "models.GenericResource" + **kwargs # type: Any + ): + # type: (...) -> "models.GenericResource" + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + content_type = kwargs.pop("content_type", "application/json") + # Construct URL - url = self.create_or_update_by_id.metadata['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) + '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 = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'GenericResource') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 201, 202]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('GenericResource', response) + deserialized = self._deserialize('GenericResource', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('GenericResource', response) + deserialized = self._deserialize('GenericResource', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - - def create_or_update_by_id( - self, resource_id, api_version, parameters, custom_headers=None, raw=False, polling=True, **operation_config): + _create_or_update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + def begin_create_or_update_by_id( + self, + resource_id, # type: str + parameters, # type: "models.GenericResource" + **kwargs # type: Any + ): + # type: (...) -> LROPoller """Create a resource by ID. - :param resource_id: The fully qualified ID of the resource, including - the resource name and resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. :type resource_id: str - :param api_version: The API version to use for the operation. - :type api_version: str :param parameters: Create or update resource parameters. - :type parameters: - ~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :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 polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns GenericResource or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 GenericResource + :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] + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._create_or_update_by_id_initial( resource_id=resource_id, - api_version=api_version, parameters=parameters, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - deserialized = self._deserialize('GenericResource', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('GenericResource', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - create_or_update_by_id.metadata = {'url': '/{resourceId}'} - + begin_create_or_update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore def _update_by_id_initial( - self, resource_id, api_version, parameters, custom_headers=None, raw=False, **operation_config): + self, + resource_id, # type: str + parameters, # type: "models.GenericResource" + **kwargs # type: Any + ): + # type: (...) -> "models.GenericResource" + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + content_type = kwargs.pop("content_type", "application/json") + # Construct URL - url = self.update_by_id.metadata['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) + '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 = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'GenericResource') # Construct and send request - request = self._client.patch(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 202]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('GenericResource', response) + deserialized = self._deserialize('GenericResource', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - - def update_by_id( - self, resource_id, api_version, parameters, custom_headers=None, raw=False, polling=True, **operation_config): + _update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + def begin_update_by_id( + self, + resource_id, # type: str + parameters, # type: "models.GenericResource" + **kwargs # type: Any + ): + # type: (...) -> LROPoller """Updates a resource by ID. - :param resource_id: The fully qualified ID of the resource, including - the resource name and resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. :type resource_id: str - :param api_version: The API version to use for the operation. - :type api_version: str :param parameters: Update resource parameters. - :type parameters: - ~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :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 polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns GenericResource or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 GenericResource + :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] + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._update_by_id_initial( resource_id=resource_id, - api_version=api_version, parameters=parameters, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - deserialized = self._deserialize('GenericResource', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('GenericResource', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - update_by_id.metadata = {'url': '/{resourceId}'} + begin_update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore def get_by_id( - self, resource_id, api_version, custom_headers=None, raw=False, **operation_config): + self, + resource_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.GenericResource" """Gets a resource by ID. - :param resource_id: The fully qualified ID of the resource, including - the resource name and resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. :type resource_id: str - :param api_version: The API version to use for the operation. - :type api_version: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: GenericResource or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GenericResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.GenericResource + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + # Construct URL - url = self.get_by_id.metadata['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) + '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 = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('GenericResource', response) + deserialized = self._deserialize('GenericResource', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/{resourceId}'} + 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 9c01af7745f9..2ea4a9ef582b 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 @@ -1,340 +1,336 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class TagsOperations(object): """TagsOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2019_07_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for this operation. Constant value: "2019-07-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-07-01" - - self.config = config + self._config = config def delete_value( - self, tag_name, tag_value, custom_headers=None, raw=False, **operation_config): + self, + tag_name, # type: str + tag_value, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Deletes a tag value. :param tag_name: The name of the tag. :type tag_name: str :param tag_value: The value of the tag to delete. :type tag_value: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + # Construct URL - url = self.delete_value.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} + delete_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore def create_or_update_value( - self, tag_name, tag_value, custom_headers=None, raw=False, **operation_config): + self, + tag_name, # type: str + tag_value, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.TagValue" """Creates a tag value. The name of the tag must already exist. :param tag_name: The name of the tag. :type tag_name: str :param tag_value: The value of the tag to create. :type tag_value: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: TagValue or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.TagValue or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagValue or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.TagValue + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TagValue"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + # Construct URL - url = self.create_or_update_value.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.put(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 201]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('TagValue', response) + deserialized = self._deserialize('TagValue', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('TagValue', response) + deserialized = self._deserialize('TagValue', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} + create_or_update_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore def create_or_update( - self, tag_name, custom_headers=None, raw=False, **operation_config): - """Creates a tag in the subscription. + self, + tag_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.TagDetails" + """The tag name can have a maximum of 512 characters and is case insensitive. Tag names created by Azure have prefixes of microsoft, azure, or windows. You cannot create tags with one of these prefixes. - The tag name can have a maximum of 512 characters and is case - insensitive. Tag names created by Azure have prefixes of microsoft, - azure, or windows. You cannot create tags with one of these prefixes. + Creates a tag in the subscription. :param tag_name: The name of the tag to create. :type tag_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: TagDetails or ClientRawResponse if raw=true + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagDetails or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_07_01.models.TagDetails - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TagDetails"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + # Construct URL - url = self.create_or_update.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.put(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 201]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('TagDetails', response) + deserialized = self._deserialize('TagDetails', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('TagDetails', response) + deserialized = self._deserialize('TagDetails', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore def delete( - self, tag_name, custom_headers=None, raw=False, **operation_config): - """Deletes a tag from the subscription. + self, + tag_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """You must remove all values from a resource tag before you can delete it. - You must remove all values from a resource tag before you can delete - it. + Deletes a tag from the subscription. :param tag_name: The name of the tag. :type tag_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + # Construct URL - url = self.delete.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} + delete.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore def list( - self, custom_headers=None, raw=False, **operation_config): - """Gets the names and values of all resource tags that are defined in a - subscription. - - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of TagDetails - :rtype: - ~azure.mgmt.resource.resources.v2019_07_01.models.TagDetailsPaged[~azure.mgmt.resource.resources.v2019_07_01.models.TagDetails] - :raises: :class:`CloudError` + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.TagsListResult"] + """Gets the names and values of all resource tags that are defined in a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of TagsListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['url'] + url = self.list.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('TagsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.TagDetailsPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/py.typed b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file 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 deleted file mode 100644 index 6723e4244a39..000000000000 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_07_01/version.py +++ /dev/null @@ -1,13 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -VERSION = "2019-07-01" - 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 68bc897193ac..fde2ed4c3b83 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 @@ -1,19 +1,16 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._configuration import ResourceManagementClientConfiguration from ._resource_management_client import ResourceManagementClient -__all__ = ['ResourceManagementClient', 'ResourceManagementClientConfiguration'] - -from .version import VERSION - -__version__ = VERSION +__all__ = ['ResourceManagementClient'] +try: + from ._patch import patch_sdk + patch_sdk() +except ImportError: + pass 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 3b326f792363..743707f0195f 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 @@ -1,48 +1,69 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrestazure import AzureConfiguration -from .version import VERSION +from typing import TYPE_CHECKING +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + + from azure.core.credentials import TokenCredential + +VERSION = "unknown" + +class ResourceManagementClientConfiguration(Configuration): + """Configuration for ResourceManagementClient. -class ResourceManagementClientConfiguration(AzureConfiguration): - """Configuration for ResourceManagementClient Note that all parameters used to create this instance are saved as instance attributes. - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` + :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 """ def __init__( - self, credentials, subscription_id, base_url=None): - - if credentials is None: - raise ValueError("Parameter 'credentials' must not be None.") + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + 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.") - if not base_url: - base_url = 'https://management.azure.com' + super(ResourceManagementClientConfiguration, self).__init__(**kwargs) - super(ResourceManagementClientConfiguration, self).__init__(base_url) - - # Starting Autorest.Python 4.0.64, make connection pool activated by default - self.keep_alive = True - - self.add_user_agent('azure-mgmt-resource/{}'.format(VERSION)) - self.add_user_agent('Azure-SDK-For-Python') - - self.credentials = credentials + self.credential = credential self.subscription_id = subscription_id + self.api_version = "2019-08-01" + self.credential_scopes = ['https://management.azure.com/.default'] + self.credential_scopes.extend(kwargs.pop('credential_scopes', [])) + kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + 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) 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 new file mode 100644 index 000000000000..b1b5f8985fd7 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/_metadata.json @@ -0,0 +1,59 @@ +{ + "chosen_version": "2019-08-01", + "total_api_version_list": ["2019-08-01"], + "client": { + "name": "ResourceManagementClient", + "filename": "_resource_management_client", + "description": "Provides operations for working with resources and resource groups." + }, + "global_parameters": { + "sync_method": { + "credential": { + "method_signature": "credential, # type: \"TokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials.TokenCredential", + "required": true + }, + "subscription_id": { + "method_signature": "subscription_id, # type: str", + "description": "The ID of the target subscription.", + "docstring_type": "str", + "required": true + } + }, + "async_method": { + "credential": { + "method_signature": "credential, # type: \"AsyncTokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + }, + "subscription_id": { + "method_signature": "subscription_id, # type: str", + "description": "The ID of the target subscription.", + "docstring_type": "str", + "required": true + } + }, + "constant": { + }, + "call": "credential, subscription_id" + }, + "config": { + "credential": true, + "credential_scopes": ["https://management.azure.com/.default"] + }, + "operation_groups": { + "operations": "Operations", + "deployments": "DeploymentsOperations", + "providers": "ProvidersOperations", + "resources": "ResourcesOperations", + "resource_groups": "ResourceGroupsOperations", + "tags": "TagsOperations", + "deployment_operations": "DeploymentOperationsOperations" + }, + "operation_mixins": { + }, + "sync_imports": "None", + "async_imports": "None" +} \ 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 ac4b96643763..d9b428b8dabe 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 @@ -1,16 +1,19 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.service_client import SDKClient -from msrest import Serializer, Deserializer +from typing import TYPE_CHECKING + +from azure.mgmt.core import ARMPipelineClient +from msrest import Deserializer, Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional from ._configuration import ResourceManagementClientConfiguration from .operations import Operations @@ -19,61 +22,76 @@ from .operations import ResourcesOperations from .operations import ResourceGroupsOperations from .operations import TagsOperations -from .operations import DeploymentOperations +from .operations import DeploymentOperationsOperations from . import models -class ResourceManagementClient(SDKClient): +class ResourceManagementClient(object): """Provides operations for working with resources and resource groups. - :ivar config: Configuration for client. - :vartype config: ResourceManagementClientConfiguration - :ivar operations: Operations operations :vartype operations: azure.mgmt.resource.resources.v2019_08_01.operations.Operations - :ivar deployments: Deployments operations + :ivar deployments: DeploymentsOperations operations :vartype deployments: azure.mgmt.resource.resources.v2019_08_01.operations.DeploymentsOperations - :ivar providers: Providers operations + :ivar providers: ProvidersOperations operations :vartype providers: azure.mgmt.resource.resources.v2019_08_01.operations.ProvidersOperations - :ivar resources: Resources operations + :ivar resources: ResourcesOperations operations :vartype resources: azure.mgmt.resource.resources.v2019_08_01.operations.ResourcesOperations - :ivar resource_groups: ResourceGroups operations + :ivar resource_groups: ResourceGroupsOperations operations :vartype resource_groups: azure.mgmt.resource.resources.v2019_08_01.operations.ResourceGroupsOperations - :ivar tags: Tags operations + :ivar tags: TagsOperations operations :vartype tags: azure.mgmt.resource.resources.v2019_08_01.operations.TagsOperations - :ivar deployment_operations: DeploymentOperations operations - :vartype deployment_operations: azure.mgmt.resource.resources.v2019_08_01.operations.DeploymentOperations - - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` + :ivar deployment_operations: DeploymentOperationsOperations operations + :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. """ def __init__( - self, credentials, subscription_id, base_url=None): - - self.config = ResourceManagementClientConfiguration(credentials, subscription_id, base_url) - super(ResourceManagementClient, self).__init__(self.config.credentials, self.config) + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = 'https://management.azure.com' + self._config = ResourceManagementClientConfiguration(credential, 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.api_version = '2019-08-01' self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self.operations = Operations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.deployments = DeploymentsOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.providers = ProvidersOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.resources = ResourcesOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.resource_groups = ResourceGroupsOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.tags = TagsOperations( - self._client, self.config, self._serialize, self._deserialize) - self.deployment_operations = DeploymentOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) + self.deployment_operations = DeploymentOperationsOperations( + self._client, self._config, self._serialize, self._deserialize) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> ResourceManagementClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) 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 new file mode 100644 index 000000000000..7f9b1bac71c5 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/__init__.py @@ -0,0 +1,10 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._resource_management_client_async import ResourceManagementClient +__all__ = ['ResourceManagementClient'] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/_configuration_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/_configuration_async.py new file mode 100644 index 000000000000..4cc43be3bf38 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/_configuration_async.py @@ -0,0 +1,65 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + +VERSION = "unknown" + +class ResourceManagementClientConfiguration(Configuration): + """Configuration for ResourceManagementClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :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 + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + 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 + self.api_version = "2019-08-01" + self.credential_scopes = ['https://management.azure.com/.default'] + self.credential_scopes.extend(kwargs.pop('credential_scopes', [])) + kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs: Any + ) -> None: + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + 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) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/_resource_management_client_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/_resource_management_client_async.py new file mode 100644 index 000000000000..3f74d5da9222 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/_resource_management_client_async.py @@ -0,0 +1,89 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, Optional + +from azure.mgmt.core import AsyncARMPipelineClient +from msrest import Deserializer, Serializer + +from ._configuration_async import ResourceManagementClientConfiguration +from .operations_async import Operations +from .operations_async import DeploymentsOperations +from .operations_async import ProvidersOperations +from .operations_async import ResourcesOperations +from .operations_async import ResourceGroupsOperations +from .operations_async import TagsOperations +from .operations_async import DeploymentOperationsOperations +from .. import models + + +class ResourceManagementClient(object): + """Provides operations for working with resources and resource groups. + + :ivar operations: Operations operations + :vartype operations: azure.mgmt.resource.resources.v2019_08_01.aio.operations_async.Operations + :ivar deployments: DeploymentsOperations operations + :vartype deployments: azure.mgmt.resource.resources.v2019_08_01.aio.operations_async.DeploymentsOperations + :ivar providers: ProvidersOperations operations + :vartype providers: azure.mgmt.resource.resources.v2019_08_01.aio.operations_async.ProvidersOperations + :ivar resources: ResourcesOperations operations + :vartype resources: azure.mgmt.resource.resources.v2019_08_01.aio.operations_async.ResourcesOperations + :ivar resource_groups: ResourceGroupsOperations operations + :vartype resource_groups: azure.mgmt.resource.resources.v2019_08_01.aio.operations_async.ResourceGroupsOperations + :ivar tags: TagsOperations operations + :vartype tags: azure.mgmt.resource.resources.v2019_08_01.aio.operations_async.TagsOperations + :ivar deployment_operations: DeploymentOperationsOperations operations + :vartype deployment_operations: azure.mgmt.resource.resources.v2019_08_01.aio.operations_async.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. + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: Optional[str] = None, + **kwargs: 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) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + + self.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 close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "ResourceManagementClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/operations_async/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/operations_async/__init__.py new file mode 100644 index 000000000000..f1fd8637fa69 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/operations_async/__init__.py @@ -0,0 +1,25 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._operations_async import Operations +from ._deployments_operations_async import DeploymentsOperations +from ._providers_operations_async import ProvidersOperations +from ._resources_operations_async import ResourcesOperations +from ._resource_groups_operations_async import ResourceGroupsOperations +from ._tags_operations_async import TagsOperations +from ._deployment_operations_operations_async import DeploymentOperationsOperations + +__all__ = [ + 'Operations', + 'DeploymentsOperations', + 'ProvidersOperations', + 'ResourcesOperations', + 'ResourceGroupsOperations', + 'TagsOperations', + 'DeploymentOperationsOperations', +] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/operations_async/_deployment_operations_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/operations_async/_deployment_operations_operations_async.py new file mode 100644 index 000000000000..19ee24f91b03 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/operations_async/_deployment_operations_operations_async.py @@ -0,0 +1,700 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import 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 ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class DeploymentOperationsOperations: + """DeploymentOperationsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2019_08_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def get_at_scope( + self, + scope: str, + deployment_name: str, + operation_id: str, + **kwargs + ) -> "models.DeploymentOperation": + """Gets a deployments operation. + + :param scope: The scope of a deployment. + :type scope: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param operation_id: The ID of the operation to get. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentOperation or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentOperation + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentOperation"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentOperation', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + def list_at_scope( + self, + scope: str, + deployment_name: str, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.DeploymentOperationsListResult"]: + """Gets all deployments operations for a deployment. + + :param scope: The scope of a deployment. + :type scope: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentOperationsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} # type: ignore + + async def get_at_tenant_scope( + self, + deployment_name: str, + operation_id: str, + **kwargs + ) -> "models.DeploymentOperation": + """Gets a deployments operation. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param operation_id: The ID of the operation to get. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentOperation or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentOperation + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentOperation"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentOperation', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + def list_at_tenant_scope( + self, + deployment_name: str, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.DeploymentOperationsListResult"]: + """Gets all deployments operations for a deployment. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentOperationsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} # type: ignore + + async def get_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + operation_id: str, + **kwargs + ) -> "models.DeploymentOperation": + """Gets a deployments operation. + + :param group_id: The management group ID. + :type group_id: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param operation_id: The ID of the operation to get. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentOperation or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentOperation + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentOperation"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentOperation', pipeline_response) + + if cls: + 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 + + def list_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.DeploymentOperationsListResult"]: + """Gets all deployments operations for a deployment. + + :param group_id: The management group ID. + :type group_id: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentOperationsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + 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 + + async def get_at_subscription_scope( + self, + deployment_name: str, + operation_id: str, + **kwargs + ) -> "models.DeploymentOperation": + """Gets a deployments operation. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param operation_id: The ID of the operation to get. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentOperation or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentOperation + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentOperation"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentOperation', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + def list_at_subscription_scope( + self, + deployment_name: str, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.DeploymentOperationsListResult"]: + """Gets all deployments operations for a deployment. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentOperationsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + 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 + + async def get( + self, + resource_group_name: str, + deployment_name: str, + operation_id: str, + **kwargs + ) -> "models.DeploymentOperation": + """Gets a deployments operation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param operation_id: The ID of the operation to get. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentOperation or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentOperation + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentOperation"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + + # Construct URL + url = self.get.metadata['url'] # type: 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentOperation', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + def list( + self, + resource_group_name: str, + deployment_name: str, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.DeploymentOperationsListResult"]: + """Gets all deployments operations for a deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentOperationsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/operations_async/_deployments_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/operations_async/_deployments_operations_async.py new file mode 100644 index 000000000000..4de133a599bd --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/operations_async/_deployments_operations_async.py @@ -0,0 +1,3112 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.polling import AsyncNoPolling, AsyncPollingMethod, async_poller +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class DeploymentsOperations: + """DeploymentsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2019_08_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def _delete_at_scope_initial( + self, + scope: str, + deployment_name: str, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + + # 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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_at_scope_initial.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def delete_at_scope( + self, + scope: str, + deployment_name: str, + **kwargs + ) -> None: + """A template deployment that is currently running cannot be deleted. Deleting a template deployment removes the associated deployment operations. This is an asynchronous operation that returns a status of 202 until the template deployment is successfully deleted. The Location response header contains the URI that is used to obtain the status of the process. While the process is running, a call to the URI in the Location header returns a status of 202. When the process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. + + Deletes a deployment from the deployment history. + + :param scope: The scope of a deployment. + :type scope: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._delete_at_scope_initial( + scope=scope, + deployment_name=deployment_name, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + delete_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def check_existence_at_scope( + self, + scope: str, + deployment_name: str, + **kwargs + ) -> None: + """Checks whether the deployment exists. + + :param scope: The scope of a deployment. + :type scope: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + + # 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] + + # Construct and send request + 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 + + if response.status_code not in [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + 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, + deployment_name: str, + properties: "models.DeploymentProperties", + location: Optional[str] = None, + **kwargs + ) -> "models.DeploymentExtended": + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.Deployment(location=location, properties=properties) + api_version = "2019-08-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_at_scope_initial.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def create_or_update_at_scope( + self, + scope: str, + deployment_name: str, + properties: "models.DeploymentProperties", + location: Optional[str] = None, + **kwargs + ) -> "models.DeploymentExtended": + """You can provide the template and parameters directly in the request or link to JSON files. + + Deploys resources at a given scope. + + :param scope: The scope of a deployment. + :type scope: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param properties: The deployment properties. + :type properties: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentProperties + :param location: The location to store the deployment data. + :type location: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: DeploymentExtended + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._create_or_update_at_scope_initial( + scope=scope, + deployment_name=deployment_name, + properties=properties, + location=location, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + create_or_update_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def get_at_scope( + self, + scope: str, + deployment_name: str, + **kwargs + ) -> "models.DeploymentExtended": + """Gets a deployment. + + :param scope: The scope of a deployment. + :type scope: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExtended or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def cancel_at_scope( + self, + scope: str, + deployment_name: str, + **kwargs + ) -> None: + """You can cancel a deployment only if the provisioningState is Accepted or Running. After the deployment is canceled, the provisioningState is set to Canceled. Canceling a template deployment stops the currently running template deployment and leaves the resources partially deployed. + + Cancels a currently running template deployment. + + :param scope: The scope of a deployment. + :type scope: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + + # 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] + + # Construct and send request + 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 [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + cancel_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + + async def validate_at_scope( + self, + scope: str, + deployment_name: str, + properties: "models.DeploymentProperties", + location: Optional[str] = None, + **kwargs + ) -> "models.DeploymentValidateResult": + """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. + + :param scope: The scope of a deployment. + :type scope: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param properties: The deployment properties. + :type properties: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentProperties + :param location: The location to store the deployment data. + :type location: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentValidateResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentValidateResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.Deployment(location=location, properties=properties) + api_version = "2019-08-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 400]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + + if response.status_code == 400: + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + validate_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + async def export_template_at_scope( + self, + scope: str, + deployment_name: str, + **kwargs + ) -> "models.DeploymentExportResult": + """Exports the template used for specified deployment. + + :param scope: The scope of a deployment. + :type scope: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExportResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExportResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + + # 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'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + export_template_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + def list_at_scope( + self, + scope: str, + filter: Optional[str] = None, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.DeploymentListResult"]: + """Get all the deployments at the given scope. + + :param scope: The scope of a deployment. + :type scope: str + :param filter: The filter to apply on the operation. For example, you can use + $filter=provisioningState eq '{state}'. + :type filter: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/'} # type: ignore + + async def _delete_at_tenant_scope_initial( + self, + deployment_name: str, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + + # 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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_at_tenant_scope_initial.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def delete_at_tenant_scope( + self, + deployment_name: str, + **kwargs + ) -> None: + """A template deployment that is currently running cannot be deleted. Deleting a template deployment removes the associated deployment operations. This is an asynchronous operation that returns a status of 202 until the template deployment is successfully deleted. The Location response header contains the URI that is used to obtain the status of the process. While the process is running, a call to the URI in the Location header returns a status of 202. When the process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. + + Deletes a deployment from the deployment history. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._delete_at_tenant_scope_initial( + deployment_name=deployment_name, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + delete_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def check_existence_at_tenant_scope( + self, + deployment_name: str, + **kwargs + ) -> None: + """Checks whether the deployment exists. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + + # 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] + + # Construct and send request + 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 + + if response.status_code not in [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + 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, + location: str, + properties: "models.DeploymentProperties", + **kwargs + ) -> "models.DeploymentExtended": + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.ScopedDeployment(location=location, properties=properties) + api_version = "2019-08-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_at_tenant_scope_initial.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def create_or_update_at_tenant_scope( + self, + deployment_name: str, + location: str, + properties: "models.DeploymentProperties", + **kwargs + ) -> "models.DeploymentExtended": + """You can provide the template and parameters directly in the request or link to JSON files. + + Deploys resources at tenant scope. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param location: The location to store the deployment data. + :type location: str + :param properties: The deployment properties. + :type properties: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentProperties + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: DeploymentExtended + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._create_or_update_at_tenant_scope_initial( + deployment_name=deployment_name, + location=location, + properties=properties, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + create_or_update_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def get_at_tenant_scope( + self, + deployment_name: str, + **kwargs + ) -> "models.DeploymentExtended": + """Gets a deployment. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExtended or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def cancel_at_tenant_scope( + self, + deployment_name: str, + **kwargs + ) -> None: + """You can cancel a deployment only if the provisioningState is Accepted or Running. After the deployment is canceled, the provisioningState is set to Canceled. Canceling a template deployment stops the currently running template deployment and leaves the resources partially deployed. + + Cancels a currently running template deployment. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + + # 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] + + # Construct and send request + 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 [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + cancel_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + + async def validate_at_tenant_scope( + self, + deployment_name: str, + location: str, + properties: "models.DeploymentProperties", + **kwargs + ) -> "models.DeploymentValidateResult": + """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param location: The location to store the deployment data. + :type location: str + :param properties: The deployment properties. + :type properties: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentProperties + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentValidateResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentValidateResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.ScopedDeployment(location=location, properties=properties) + api_version = "2019-08-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 400]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + + if response.status_code == 400: + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + validate_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + async def export_template_at_tenant_scope( + self, + deployment_name: str, + **kwargs + ) -> "models.DeploymentExportResult": + """Exports the template used for specified deployment. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExportResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExportResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + + # 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'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + export_template_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + def list_at_tenant_scope( + self, + filter: Optional[str] = None, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.DeploymentListResult"]: + """Get all the deployments at the tenant scope. + + :param filter: The filter to apply on the operation. For example, you can use + $filter=provisioningState eq '{state}'. + :type filter: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/'} # type: ignore + + async def _delete_at_management_group_scope_initial( + self, + group_id: str, + deployment_name: str, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_at_management_group_scope_initial.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def delete_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + **kwargs + ) -> None: + """A template deployment that is currently running cannot be deleted. Deleting a template deployment removes the associated deployment operations. This is an asynchronous operation that returns a status of 202 until the template deployment is successfully deleted. The Location response header contains the URI that is used to obtain the status of the process. While the process is running, a call to the URI in the Location header returns a status of 202. When the process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. + + Deletes a deployment from the deployment history. + + :param group_id: The management group ID. + :type group_id: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._delete_at_management_group_scope_initial( + group_id=group_id, + deployment_name=deployment_name, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + delete_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def check_existence_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + **kwargs + ) -> None: + """Checks whether the deployment exists. + + :param group_id: The management group ID. + :type group_id: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-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] + + # Construct and send request + 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 + + if response.status_code not in [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + 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, + deployment_name: str, + location: str, + properties: "models.DeploymentProperties", + **kwargs + ) -> "models.DeploymentExtended": + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.ScopedDeployment(location=location, properties=properties) + api_version = "2019-08-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + 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 + + async def create_or_update_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + location: str, + properties: "models.DeploymentProperties", + **kwargs + ) -> "models.DeploymentExtended": + """You can provide the template and parameters directly in the request or link to JSON files. + + Deploys resources at management group scope. + + :param group_id: The management group ID. + :type group_id: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param location: The location to store the deployment data. + :type location: str + :param properties: The deployment properties. + :type properties: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentProperties + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: DeploymentExtended + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._create_or_update_at_management_group_scope_initial( + group_id=group_id, + deployment_name=deployment_name, + location=location, + properties=properties, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + create_or_update_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def get_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + **kwargs + ) -> "models.DeploymentExtended": + """Gets a deployment. + + :param group_id: The management group ID. + :type group_id: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExtended or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + 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 + + async def cancel_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + **kwargs + ) -> None: + """You can cancel a deployment only if the provisioningState is Accepted or Running. After the deployment is canceled, the provisioningState is set to Canceled. Canceling a template deployment stops the currently running template deployment and leaves the resources partially deployed. + + Cancels a currently running template deployment. + + :param group_id: The management group ID. + :type group_id: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-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] + + # Construct and send request + 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 [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + 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( + self, + group_id: str, + deployment_name: str, + location: str, + properties: "models.DeploymentProperties", + **kwargs + ) -> "models.DeploymentValidateResult": + """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. + + :param group_id: The management group ID. + :type group_id: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param location: The location to store the deployment data. + :type location: str + :param properties: The deployment properties. + :type properties: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentProperties + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentValidateResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentValidateResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.ScopedDeployment(location=location, properties=properties) + api_version = "2019-08-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 400]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + + if response.status_code == 400: + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + + if cls: + 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 + + async def export_template_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + **kwargs + ) -> "models.DeploymentExportResult": + """Exports the template used for specified deployment. + + :param group_id: The management group ID. + :type group_id: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExportResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExportResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + + # 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'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + + if cls: + 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 + + def list_at_management_group_scope( + self, + group_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.DeploymentListResult"]: + """Get all the deployments for a management group. + + :param group_id: The management group ID. + :type group_id: str + :param filter: The filter to apply on the operation. For example, you can use + $filter=provisioningState eq '{state}'. + :type filter: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + 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/'} # type: ignore + + async def _delete_at_subscription_scope_initial( + self, + deployment_name: str, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def delete_at_subscription_scope( + self, + deployment_name: str, + **kwargs + ) -> None: + """A template deployment that is currently running cannot be deleted. Deleting a template deployment removes the associated deployment operations. This is an asynchronous operation that returns a status of 202 until the template deployment is successfully deleted. The Location response header contains the URI that is used to obtain the status of the process. While the process is running, a call to the URI in the Location header returns a status of 202. When the process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. + + Deletes a deployment from the deployment history. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._delete_at_subscription_scope_initial( + deployment_name=deployment_name, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + delete_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def check_existence_at_subscription_scope( + self, + deployment_name: str, + **kwargs + ) -> None: + """Checks whether the deployment exists. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-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] + + # Construct and send request + 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 + + if response.status_code not in [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + 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, + properties: "models.DeploymentProperties", + location: Optional[str] = None, + **kwargs + ) -> "models.DeploymentExtended": + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.Deployment(location=location, properties=properties) + api_version = "2019-08-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + 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 + + async def create_or_update_at_subscription_scope( + self, + deployment_name: str, + properties: "models.DeploymentProperties", + location: Optional[str] = None, + **kwargs + ) -> "models.DeploymentExtended": + """You can provide the template and parameters directly in the request or link to JSON files. + + Deploys resources at subscription scope. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param properties: The deployment properties. + :type properties: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentProperties + :param location: The location to store the deployment data. + :type location: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: DeploymentExtended + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._create_or_update_at_subscription_scope_initial( + deployment_name=deployment_name, + properties=properties, + location=location, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + create_or_update_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def get_at_subscription_scope( + self, + deployment_name: str, + **kwargs + ) -> "models.DeploymentExtended": + """Gets a deployment. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExtended or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def cancel_at_subscription_scope( + self, + deployment_name: str, + **kwargs + ) -> None: + """You can cancel a deployment only if the provisioningState is Accepted or Running. After the deployment is canceled, the provisioningState is set to Canceled. Canceling a template deployment stops the currently running template deployment and leaves the resources partially deployed. + + Cancels a currently running template deployment. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-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] + + # Construct and send request + 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 [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + cancel_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + + async def validate_at_subscription_scope( + self, + deployment_name: str, + properties: "models.DeploymentProperties", + location: Optional[str] = None, + **kwargs + ) -> "models.DeploymentValidateResult": + """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param properties: The deployment properties. + :type properties: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentProperties + :param location: The location to store the deployment data. + :type location: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentValidateResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentValidateResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.Deployment(location=location, properties=properties) + api_version = "2019-08-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 400]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + + if response.status_code == 400: + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + + if cls: + 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, + properties: "models.DeploymentWhatIfProperties", + location: Optional[str] = None, + **kwargs + ) -> "models.WhatIfOperationResult": + cls = kwargs.pop('cls', None) # type: ClsType["models.WhatIfOperationResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.DeploymentWhatIf(location=location, properties=properties) + api_version = "2019-08-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + deserialized = None + 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 + + async def what_if_at_subscription_scope( + self, + deployment_name: str, + properties: "models.DeploymentWhatIfProperties", + location: Optional[str] = None, + **kwargs + ) -> "models.WhatIfOperationResult": + """Returns changes that will be made by the deployment if executed at the scope of the subscription. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param properties: The deployment properties. + :type properties: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentWhatIfProperties + :param location: The location to store the deployment data. + :type location: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: WhatIfOperationResult + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.WhatIfOperationResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.WhatIfOperationResult"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._what_if_at_subscription_scope_initial( + deployment_name=deployment_name, + properties=properties, + location=location, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + 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 + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + what_if_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + + async def export_template_at_subscription_scope( + self, + deployment_name: str, + **kwargs + ) -> "models.DeploymentExportResult": + """Exports the template used for specified deployment. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExportResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExportResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + + # 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'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + export_template_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + def list_at_subscription_scope( + self, + filter: Optional[str] = None, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.DeploymentListResult"]: + """Get all the deployments for a subscription. + + :param filter: The filter to apply on the operation. For example, you can use + $filter=provisioningState eq '{state}'. + :type filter: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/'} # type: ignore + + async def _delete_initial( + self, + resource_group_name: str, + deployment_name: str, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def delete( + self, + resource_group_name: str, + deployment_name: str, + **kwargs + ) -> None: + """A template deployment that is currently running cannot be deleted. Deleting a template deployment removes the associated deployment operations. Deleting a template deployment does not affect the state of the resource group. This is an asynchronous operation that returns a status of 202 until the template deployment is successfully deleted. The Location response header contains the URI that is used to obtain the status of the process. While the process is running, a call to the URI in the Location header returns a status of 202. When the process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. + + Deletes a deployment from the deployment history. + + :param resource_group_name: The name of the resource group with the deployment to delete. The + name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def check_existence( + self, + resource_group_name: str, + deployment_name: str, + **kwargs + ) -> None: + """Checks whether the deployment exists. + + :param resource_group_name: The name of the resource group with the deployment to check. The + name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-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] + + # Construct and send request + 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 + + if response.status_code not in [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + 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, + deployment_name: str, + properties: "models.DeploymentProperties", + location: Optional[str] = None, + **kwargs + ) -> "models.DeploymentExtended": + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.Deployment(location=location, properties=properties) + api_version = "2019-08-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def create_or_update( + self, + resource_group_name: str, + deployment_name: str, + properties: "models.DeploymentProperties", + location: Optional[str] = None, + **kwargs + ) -> "models.DeploymentExtended": + """You can provide the template and parameters directly in the request or link to JSON files. + + Deploys resources to a resource group. + + :param resource_group_name: The name of the resource group to deploy the resources to. The name + is case insensitive. The resource group must already exist. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param properties: The deployment properties. + :type properties: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentProperties + :param location: The location to store the deployment data. + :type location: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: DeploymentExtended + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + properties=properties, + location=location, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def get( + self, + resource_group_name: str, + deployment_name: str, + **kwargs + ) -> "models.DeploymentExtended": + """Gets a deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExtended or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + + # Construct URL + url = self.get.metadata['url'] # type: 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def cancel( + self, + resource_group_name: str, + deployment_name: str, + **kwargs + ) -> None: + """You can cancel a deployment only if the provisioningState is Accepted or Running. After the deployment is canceled, the provisioningState is set to Canceled. Canceling a template deployment stops the currently running template deployment and leaves the resource group partially deployed. + + Cancels a currently running template deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-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] + + # Construct and send request + 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 [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + cancel.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + + async def validate( + self, + resource_group_name: str, + deployment_name: str, + properties: "models.DeploymentProperties", + location: Optional[str] = None, + **kwargs + ) -> "models.DeploymentValidateResult": + """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param properties: The deployment properties. + :type properties: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentProperties + :param location: The location to store the deployment data. + :type location: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentValidateResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentValidateResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.Deployment(location=location, properties=properties) + api_version = "2019-08-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 400]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + + if response.status_code == 400: + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + + if cls: + 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, + deployment_name: str, + properties: "models.DeploymentWhatIfProperties", + location: Optional[str] = None, + **kwargs + ) -> "models.WhatIfOperationResult": + cls = kwargs.pop('cls', None) # type: ClsType["models.WhatIfOperationResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.DeploymentWhatIf(location=location, properties=properties) + api_version = "2019-08-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + deserialized = None + 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 + + async def what_if( + self, + resource_group_name: str, + deployment_name: str, + properties: "models.DeploymentWhatIfProperties", + location: Optional[str] = None, + **kwargs + ) -> "models.WhatIfOperationResult": + """Returns changes that will be made by the deployment if executed at the scope of the resource group. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param properties: The deployment properties. + :type properties: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentWhatIfProperties + :param location: The location to store the deployment data. + :type location: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: WhatIfOperationResult + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.WhatIfOperationResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.WhatIfOperationResult"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._what_if_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + properties=properties, + location=location, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + 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 + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + what_if.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + + async def export_template( + self, + resource_group_name: str, + deployment_name: str, + **kwargs + ) -> "models.DeploymentExportResult": + """Exports the template used for specified deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExportResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExportResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + + # 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'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + def list_by_resource_group( + self, + resource_group_name: str, + filter: Optional[str] = None, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.DeploymentListResult"]: + """Get all the deployments for a resource group. + + :param resource_group_name: The name of the resource group with the deployments to get. The + name is case insensitive. + :type resource_group_name: str + :param filter: The filter to apply on the operation. For example, you can use + $filter=provisioningState eq '{state}'. + :type filter: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + 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 + + async def calculate_template_hash( + self, + template: object, + **kwargs + ) -> "models.TemplateHashResult": + """Calculate the hash of the given template. + + :param template: The template provided to calculate hash. + :type template: object + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateHashResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.TemplateHashResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TemplateHashResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + content_type = kwargs.pop("content_type", "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'] = 'application/json' + + # Construct and send request + 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) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('TemplateHashResult', pipeline_response) + + if cls: + 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_async/_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/operations_async/_operations_async.py new file mode 100644 index 000000000000..9ee0cb7d0ff5 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/operations_async/_operations_async.py @@ -0,0 +1,101 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import 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 ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class Operations: + """Operations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2019_08_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + **kwargs + ) -> AsyncIterable["models.OperationListResult"]: + """Lists all of the available Microsoft.Resources REST API operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of OperationListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('OperationListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.Resources/operations'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/operations_async/_providers_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/operations_async/_providers_operations_async.py new file mode 100644 index 000000000000..9ee9d17c95d6 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/operations_async/_providers_operations_async.py @@ -0,0 +1,407 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import 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 ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ProvidersOperations: + """ProvidersOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2019_08_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def unregister( + self, + resource_provider_namespace: str, + **kwargs + ) -> "models.Provider": + """Unregisters a subscription from a resource provider. + + :param resource_provider_namespace: The namespace of the resource provider to unregister. + :type resource_provider_namespace: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Provider or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.Provider + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Provider"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + + # 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'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Provider', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + unregister.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister'} # type: ignore + + async def register( + self, + resource_provider_namespace: str, + **kwargs + ) -> "models.Provider": + """Registers a subscription with a resource provider. + + :param resource_provider_namespace: The namespace of the resource provider to register. + :type resource_provider_namespace: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Provider or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.Provider + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Provider"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + + # 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'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Provider', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + register.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register'} # type: ignore + + def list( + self, + top: Optional[int] = None, + expand: Optional[str] = None, + **kwargs + ) -> AsyncIterable["models.ProviderListResult"]: + """Gets all resource providers for a subscription. + + :param top: The number of results to return. If null is passed returns all deployments. + :type top: int + :param expand: The properties to include in the results. For example, use &$expand=metadata in + the query string to retrieve resource provider metadata. To include property aliases in + response, use $expand=resourceTypes/aliases. + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of ProviderListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ProviderListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers'} # type: ignore + + def list_at_tenant_scope( + self, + top: Optional[int] = None, + expand: Optional[str] = None, + **kwargs + ) -> AsyncIterable["models.ProviderListResult"]: + """Gets all resource providers for the tenant. + + :param top: The number of results to return. If null is passed returns all providers. + :type top: int + :param expand: The properties to include in the results. For example, use &$expand=metadata in + the query string to retrieve resource provider metadata. To include property aliases in + response, use $expand=resourceTypes/aliases. + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of ProviderListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ProviderListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_at_tenant_scope.metadata = {'url': '/providers'} # type: ignore + + async def get( + self, + resource_provider_namespace: str, + expand: Optional[str] = None, + **kwargs + ) -> "models.Provider": + """Gets the specified resource provider. + + :param resource_provider_namespace: The namespace of the resource provider. + :type resource_provider_namespace: str + :param expand: The $expand query parameter. For example, to include property aliases in + response, use $expand=resourceTypes/aliases. + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Provider or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.Provider + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Provider"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Provider', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}'} # type: ignore + + async def get_at_tenant_scope( + self, + resource_provider_namespace: str, + expand: Optional[str] = None, + **kwargs + ) -> "models.Provider": + """Gets the specified resource provider at the tenant level. + + :param resource_provider_namespace: The namespace of the resource provider. + :type resource_provider_namespace: str + :param expand: The $expand query parameter. For example, to include property aliases in + response, use $expand=resourceTypes/aliases. + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Provider or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.Provider + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Provider"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Provider', pipeline_response) + + if cls: + 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_async/_resource_groups_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/operations_async/_resource_groups_operations_async.py new file mode 100644 index 000000000000..9f2f01a32a8a --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/operations_async/_resource_groups_operations_async.py @@ -0,0 +1,545 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, List, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.polling import AsyncNoPolling, AsyncPollingMethod, async_poller +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ResourceGroupsOperations: + """ResourceGroupsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2019_08_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def check_existence( + self, + resource_group_name: str, + **kwargs + ) -> None: + """Checks whether a resource group exists. + + :param resource_group_name: The name of the resource group to check. 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: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-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] + + # Construct and send request + 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 + + if response.status_code not in [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + async def create_or_update( + self, + resource_group_name: str, + parameters: "models.ResourceGroup", + **kwargs + ) -> "models.ResourceGroup": + """Creates or updates a resource group. + + :param resource_group_name: The name of the resource group to create or update. Can include + alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters + that match the allowed characters. + :type resource_group_name: str + :param parameters: Parameters supplied to the create or update a resource group. + :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.ResourceGroup + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.ResourceGroup + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceGroup"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ResourceGroup', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ResourceGroup', pipeline_response) + + if cls: + 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, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-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] + + # Construct and send request + 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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + async def delete( + self, + resource_group_name: str, + **kwargs + ) -> None: + """When you delete a resource group, all of its resources are also deleted. Deleting a resource group deletes all of its template deployments and currently stored operations. + + Deletes a resource group. + + :param resource_group_name: The name of the resource group to delete. 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 + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + async def get( + self, + resource_group_name: str, + **kwargs + ) -> "models.ResourceGroup": + """Gets a resource group. + + :param resource_group_name: The name of the resource group to get. 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: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.ResourceGroup + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceGroup"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + + # Construct URL + url = self.get.metadata['url'] # type: 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ResourceGroup', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + async def update( + self, + resource_group_name: str, + parameters: "models.ResourceGroupPatchable", + **kwargs + ) -> "models.ResourceGroup": + """Resource groups can be updated through a simple PATCH operation to a group address. The format of the request is the same as that for creating a resource group. If a field is unspecified, the current value is retained. + + Updates a resource group. + + :param resource_group_name: The name of the resource group to update. The name is case + insensitive. + :type resource_group_name: str + :param parameters: Parameters supplied to update a resource group. + :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.ResourceGroupPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.ResourceGroup + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceGroup"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ResourceGroup', pipeline_response) + + if cls: + 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, + resources: Optional[List[str]] = None, + options: Optional[str] = None, + **kwargs + ) -> "models.ResourceGroupExportResult": + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceGroupExportResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.ExportTemplateRequest(resources=resources, options=options) + api_version = "2019-08-01" + content_type = kwargs.pop("content_type", "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, pattern=r'^[-\w\._\(\)]+$'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ResourceGroupExportResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _export_template_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate'} # type: ignore + + async def export_template( + self, + resource_group_name: str, + resources: Optional[List[str]] = None, + options: Optional[str] = None, + **kwargs + ) -> "models.ResourceGroupExportResult": + """Captures the specified resource group as a template. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param 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', + 'SkipResourceNameParameterization', 'SkipAllParameterization'. + :type options: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: ResourceGroupExportResult + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.ResourceGroupExportResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceGroupExportResult"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._export_template_initial( + resource_group_name=resource_group_name, + resources=resources, + options=options, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ResourceGroupExportResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + 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 + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate'} # type: ignore + + def list( + self, + filter: Optional[str] = None, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.ResourceGroupListResult"]: + """Gets all the resource groups for a subscription. + + :param filter: The filter to apply on the operation.:code:`
`:code:`
`You can filter by + tag names and values. For example, to filter for a tag name and value, use $filter=tagName eq + 'tag1' and tagValue eq 'Value1'. + :type filter: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ResourceGroupListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/operations_async/_resources_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/operations_async/_resources_operations_async.py new file mode 100644 index 000000000000..133c68f224c7 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/operations_async/_resources_operations_async.py @@ -0,0 +1,1310 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, List, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.polling import AsyncNoPolling, AsyncPollingMethod, async_poller +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ResourcesOperations: + """ResourcesOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2019_08_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list_by_resource_group( + self, + resource_group_name: str, + filter: Optional[str] = None, + expand: Optional[str] = None, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.ResourceListResult"]: + """Get all the resources for a resource group. + + :param resource_group_name: The resource group with the resources to get. + :type resource_group_name: str + :param filter: The filter to apply on the operation.:code:`
`:code:`
`The properties you + can use for eq (equals) or ne (not equals) are: location, resourceType, name, resourceGroup, + identity, identity/principalId, plan, plan/publisher, plan/product, plan/name, plan/version, + and plan/promotionCode.:code:`
`:code:`
`For example, to filter by a resource type, use: + $filter=resourceType eq 'Microsoft.Network/virtualNetworks':code:`
`:code:`
`You can use + substringof(value, property) in the filter. The properties you can use for substring are: name + and resourceGroup.:code:`
`:code:`
`For example, to get all resources with 'demo' + anywhere in the name, use: $filter=substringof('demo', name):code:`
`:code:`
`You can + link more than one substringof together by adding and/or operators.:code:`
`:code:`
`You + can filter by tag names and values. For example, to filter for a tag name and value, use + $filter=tagName eq 'tag1' and tagValue eq 'Value1'. When you filter by a tag name and value, + the tags for each resource are not returned in the results.:code:`
`:code:`
`You can use + some properties together when filtering. The combinations you can use are: substringof and/or + resourceType, plan and plan/publisher and plan/name, identity and identity/principalId. + :type filter: str + :param expand: Comma-separated list of additional properties to be included in the response. + Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, + ``$expand=createdTime,changedTime``. + :type expand: str + :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 ResourceListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ResourceListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources'} # type: ignore + + async def _move_resources_initial( + self, + source_resource_group_name: str, + resources: Optional[List[str]] = None, + target_resource_group: Optional[str] = None, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.ResourcesMoveInfo(resources=resources, target_resource_group=target_resource_group) + api_version = "2019-08-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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + + # Construct and send request + 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 + + if response.status_code not in [202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore + + async def move_resources( + self, + source_resource_group_name: str, + resources: Optional[List[str]] = None, + target_resource_group: Optional[str] = None, + **kwargs + ) -> None: + """The resources to move must be in the same source resource group. The target resource group may be in a different subscription. When moving resources, both the source group and the target group are locked for the duration of the operation. Write and delete operations are blocked on the groups until the move completes. + + Moves resources from one resource group to another resource group. + + :param source_resource_group_name: The name of the resource group containing the resources to + move. + :type source_resource_group_name: str + :param resources: The IDs of the resources. + :type resources: list[str] + :param target_resource_group: The target resource group. + :type target_resource_group: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._move_resources_initial( + source_resource_group_name=source_resource_group_name, + resources=resources, + target_resource_group=target_resource_group, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore + + async def _validate_move_resources_initial( + self, + source_resource_group_name: str, + resources: Optional[List[str]] = None, + target_resource_group: Optional[str] = None, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.ResourcesMoveInfo(resources=resources, target_resource_group=target_resource_group) + api_version = "2019-08-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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + + # Construct and send request + 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 + + if response.status_code not in [202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _validate_move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} # type: ignore + + async def validate_move_resources( + self, + source_resource_group_name: str, + resources: Optional[List[str]] = None, + target_resource_group: Optional[str] = None, + **kwargs + ) -> None: + """This operation checks whether the specified resources can be moved to the target. The resources to move must be in the same source resource group. The target resource group may be in a different subscription. If validation succeeds, it returns HTTP response code 204 (no content). If validation fails, it returns HTTP response code 409 (Conflict) with an error message. Retrieve the URL in the Location header value to check the result of the long-running operation. + + Validates whether resources can be moved from one resource group to another resource group. + + :param source_resource_group_name: The name of the resource group containing the resources to + validate for move. + :type source_resource_group_name: str + :param resources: The IDs of the resources. + :type resources: list[str] + :param target_resource_group: The target resource group. + :type target_resource_group: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._validate_move_resources_initial( + source_resource_group_name=source_resource_group_name, + resources=resources, + target_resource_group=target_resource_group, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + validate_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} # type: ignore + + def list( + self, + filter: Optional[str] = None, + expand: Optional[str] = None, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.ResourceListResult"]: + """Get all the resources in a subscription. + + :param filter: The filter to apply on the operation.:code:`
`:code:`
`The properties you + can use for eq (equals) or ne (not equals) are: location, resourceType, name, resourceGroup, + identity, identity/principalId, plan, plan/publisher, plan/product, plan/name, plan/version, + and plan/promotionCode.:code:`
`:code:`
`For example, to filter by a resource type, use: + $filter=resourceType eq 'Microsoft.Network/virtualNetworks':code:`
`:code:`
`You can use + substringof(value, property) in the filter. The properties you can use for substring are: name + and resourceGroup.:code:`
`:code:`
`For example, to get all resources with 'demo' + anywhere in the name, use: $filter=substringof('demo', name):code:`
`:code:`
`You can + link more than one substringof together by adding and/or operators.:code:`
`:code:`
`You + can filter by tag names and values. For example, to filter for a tag name and value, use + $filter=tagName eq 'tag1' and tagValue eq 'Value1'. When you filter by a tag name and value, + the tags for each resource are not returned in the results.:code:`
`:code:`
`You can use + some properties together when filtering. The combinations you can use are: substringof and/or + resourceType, plan and plan/publisher and plan/name, identity and identity/principalId. + :type filter: str + :param expand: Comma-separated list of additional properties to be included in the response. + Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, + ``$expand=createdTime,changedTime``. + :type expand: str + :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 ResourceListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ResourceListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resources'} # type: ignore + + async def check_existence( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + **kwargs + ) -> None: + """Checks whether a resource exists. + + :param resource_group_name: The name of the resource group containing the resource to check. + The name is case insensitive. + :type resource_group_name: str + :param resource_provider_namespace: The resource provider of the resource to check. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. + :type parent_resource_path: str + :param resource_type: The resource type. + :type resource_type: str + :param resource_name: The name of the resource to check whether it exists. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-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\._\(\)]+$'), + 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), + 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_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] + + # Construct and send request + 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 + + if response.status_code not in [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + 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, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-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\._\(\)]+$'), + 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), + 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + async def delete( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + **kwargs + ) -> None: + """Deletes a resource. + + :param resource_group_name: The name of the resource group that contains the resource to + delete. The name is case insensitive. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. + :type parent_resource_path: str + :param resource_type: The resource type. + :type resource_type: str + :param resource_name: The name of the resource to delete. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._delete_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, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + parameters: "models.GenericResource", + **kwargs + ) -> "models.GenericResource": + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + content_type = kwargs.pop("content_type", "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'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 201, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('GenericResource', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + async def create_or_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + parameters: "models.GenericResource", + **kwargs + ) -> "models.GenericResource": + """Creates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to create. + :type resource_type: str + :param resource_name: The name of the resource to create. + :type resource_name: str + :param parameters: Parameters for creating or updating the resource. + :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 polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: GenericResource + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._create_or_update_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, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + 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, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + parameters: "models.GenericResource", + **kwargs + ) -> "models.GenericResource": + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + content_type = kwargs.pop("content_type", "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'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + async def update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + parameters: "models.GenericResource", + **kwargs + ) -> "models.GenericResource": + """Updates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to update. + :type resource_type: str + :param resource_name: The name of the resource to update. + :type resource_name: str + :param parameters: Parameters for updating the resource. + :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 polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: GenericResource + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._update_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, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + async def get( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + **kwargs + ) -> "models.GenericResource": + """Gets a resource. + + :param resource_group_name: The name of the resource group containing the resource to get. The + name is case insensitive. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. + :type parent_resource_path: str + :param resource_type: The resource type of the resource. + :type resource_type: str + :param resource_name: The name of the resource to get. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GenericResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + + # Construct URL + url = self.get.metadata['url'] # type: 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + async def check_existence_by_id( + self, + resource_id: str, + **kwargs + ) -> None: + """Checks by ID whether a resource exists. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + :type resource_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + + # 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] + + # Construct and send request + 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 + + if response.status_code not in [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + 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, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + + # 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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + async def delete_by_id( + self, + resource_id: str, + **kwargs + ) -> None: + """Deletes a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + :type resource_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._delete_by_id_initial( + resource_id=resource_id, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + delete_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + + async def _create_or_update_by_id_initial( + self, + resource_id: str, + parameters: "models.GenericResource", + **kwargs + ) -> "models.GenericResource": + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + content_type = kwargs.pop("content_type", "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) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 201, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('GenericResource', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + async def create_or_update_by_id( + self, + resource_id: str, + parameters: "models.GenericResource", + **kwargs + ) -> "models.GenericResource": + """Create a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + :type resource_id: str + :param parameters: Create or update resource parameters. + :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 polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: GenericResource + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._create_or_update_by_id_initial( + resource_id=resource_id, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + create_or_update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + + async def _update_by_id_initial( + self, + resource_id: str, + parameters: "models.GenericResource", + **kwargs + ) -> "models.GenericResource": + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + content_type = kwargs.pop("content_type", "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) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + async def update_by_id( + self, + resource_id: str, + parameters: "models.GenericResource", + **kwargs + ) -> "models.GenericResource": + """Updates a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + :type resource_id: str + :param parameters: Update resource parameters. + :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 polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: GenericResource + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._update_by_id_initial( + resource_id=resource_id, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + + async def get_by_id( + self, + resource_id: str, + **kwargs + ) -> "models.GenericResource": + """Gets a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + :type resource_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GenericResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + 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_async/_tags_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/operations_async/_tags_operations_async.py new file mode 100644 index 000000000000..e5670192c9fc --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/aio/operations_async/_tags_operations_async.py @@ -0,0 +1,327 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import 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 ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class TagsOperations: + """TagsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2019_08_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def delete_value( + self, + tag_name: str, + tag_value: str, + **kwargs + ) -> None: + """Deletes a tag value. + + :param tag_name: The name of the tag. + :type tag_name: str + :param tag_value: The value of the tag to delete. + :type tag_value: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore + + async def create_or_update_value( + self, + tag_name: str, + tag_value: str, + **kwargs + ) -> "models.TagValue": + """Creates a tag value. The name of the tag must already exist. + + :param tag_name: The name of the tag. + :type tag_name: str + :param tag_value: The value of the tag to create. + :type tag_value: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagValue or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.TagValue + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TagValue"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + + # 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'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('TagValue', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('TagValue', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore + + async def create_or_update( + self, + tag_name: str, + **kwargs + ) -> "models.TagDetails": + """The tag name can have a maximum of 512 characters and is case insensitive. Tag names created by Azure have prefixes of microsoft, azure, or windows. You cannot create tags with one of these prefixes. + + Creates a tag in the subscription. + + :param tag_name: The name of the tag to create. + :type tag_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagDetails or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.TagDetails + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TagDetails"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + + # 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'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('TagDetails', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('TagDetails', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore + + async def delete( + self, + tag_name: str, + **kwargs + ) -> None: + """You must remove all values from a resource tag before you can delete it. + + Deletes a tag from the subscription. + + :param tag_name: The name of the tag. + :type tag_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore + + def list( + self, + **kwargs + ) -> AsyncIterable["models.TagsListResult"]: + """Gets the names and values of all resource tags that are defined in a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of TagsListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('TagsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/models/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/models/__init__.py index 1b7c3ec2fdd3..e8c8d8d28fb9 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/models/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/models/__init__.py @@ -1,26 +1,26 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- try: from ._models_py3 import AliasPathType from ._models_py3 import AliasType from ._models_py3 import BasicDependency + from ._models_py3 import ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties from ._models_py3 import DebugSetting from ._models_py3 import Dependency from ._models_py3 import Deployment from ._models_py3 import DeploymentExportResult from ._models_py3 import DeploymentExtended from ._models_py3 import DeploymentExtendedFilter + from ._models_py3 import DeploymentListResult from ._models_py3 import DeploymentOperation from ._models_py3 import DeploymentOperationProperties + from ._models_py3 import DeploymentOperationsListResult from ._models_py3 import DeploymentProperties from ._models_py3 import DeploymentPropertiesExtended from ._models_py3 import DeploymentValidateResult @@ -35,21 +35,24 @@ from ._models_py3 import GenericResourceFilter from ._models_py3 import HttpMessage from ._models_py3 import Identity - from ._models_py3 import IdentityUserAssignedIdentitiesValue from ._models_py3 import OnErrorDeployment from ._models_py3 import OnErrorDeploymentExtended from ._models_py3 import Operation from ._models_py3 import OperationDisplay + from ._models_py3 import OperationListResult from ._models_py3 import ParametersLink from ._models_py3 import Plan from ._models_py3 import Provider + from ._models_py3 import ProviderListResult from ._models_py3 import ProviderResourceType from ._models_py3 import Resource from ._models_py3 import ResourceGroup from ._models_py3 import ResourceGroupExportResult from ._models_py3 import ResourceGroupFilter + from ._models_py3 import ResourceGroupListResult from ._models_py3 import ResourceGroupPatchable from ._models_py3 import ResourceGroupProperties + from ._models_py3 import ResourceListResult from ._models_py3 import ResourceProviderOperationDisplayProperties from ._models_py3 import ResourcesMoveInfo from ._models_py3 import ScopedDeployment @@ -58,6 +61,7 @@ from ._models_py3 import TagCount from ._models_py3 import TagDetails from ._models_py3 import TagValue + from ._models_py3 import TagsListResult from ._models_py3 import TargetResource from ._models_py3 import TemplateHashResult from ._models_py3 import TemplateLink @@ -65,88 +69,92 @@ from ._models_py3 import WhatIfOperationResult from ._models_py3 import WhatIfPropertyChange except (SyntaxError, ImportError): - from ._models import AliasPathType - from ._models import AliasType - from ._models import BasicDependency - from ._models import DebugSetting - from ._models import Dependency - from ._models import Deployment - from ._models import DeploymentExportResult - from ._models import DeploymentExtended - from ._models import DeploymentExtendedFilter - from ._models import DeploymentOperation - from ._models import DeploymentOperationProperties - from ._models import DeploymentProperties - from ._models import DeploymentPropertiesExtended - from ._models import DeploymentValidateResult - from ._models import DeploymentWhatIf - from ._models import DeploymentWhatIfProperties - from ._models import DeploymentWhatIfSettings - from ._models import ErrorAdditionalInfo - from ._models import ErrorResponse - from ._models import ExportTemplateRequest - from ._models import GenericResource - from ._models import GenericResourceExpanded - from ._models import GenericResourceFilter - from ._models import HttpMessage - from ._models import Identity - from ._models import IdentityUserAssignedIdentitiesValue - from ._models import OnErrorDeployment - from ._models import OnErrorDeploymentExtended - from ._models import Operation - from ._models import OperationDisplay - from ._models import ParametersLink - from ._models import Plan - from ._models import Provider - from ._models import ProviderResourceType - from ._models import Resource - from ._models import ResourceGroup - from ._models import ResourceGroupExportResult - from ._models import ResourceGroupFilter - from ._models import ResourceGroupPatchable - from ._models import ResourceGroupProperties - from ._models import ResourceProviderOperationDisplayProperties - from ._models import ResourcesMoveInfo - from ._models import ScopedDeployment - from ._models import Sku - from ._models import SubResource - from ._models import TagCount - from ._models import TagDetails - from ._models import TagValue - from ._models import TargetResource - from ._models import TemplateHashResult - from ._models import TemplateLink - from ._models import WhatIfChange - from ._models import WhatIfOperationResult - from ._models import WhatIfPropertyChange -from ._paged_models import DeploymentExtendedPaged -from ._paged_models import DeploymentOperationPaged -from ._paged_models import GenericResourceExpandedPaged -from ._paged_models import OperationPaged -from ._paged_models import ProviderPaged -from ._paged_models import ResourceGroupPaged -from ._paged_models import TagDetailsPaged + from ._models import AliasPathType # type: ignore + from ._models import AliasType # type: ignore + from ._models import BasicDependency # type: ignore + from ._models import ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties # type: ignore + from ._models import DebugSetting # type: ignore + from ._models import Dependency # type: ignore + from ._models import Deployment # type: ignore + from ._models import DeploymentExportResult # type: ignore + from ._models import DeploymentExtended # type: ignore + from ._models import DeploymentExtendedFilter # type: ignore + from ._models import DeploymentListResult # type: ignore + from ._models import DeploymentOperation # type: ignore + from ._models import DeploymentOperationProperties # type: ignore + from ._models import DeploymentOperationsListResult # type: ignore + from ._models import DeploymentProperties # type: ignore + from ._models import DeploymentPropertiesExtended # type: ignore + from ._models import DeploymentValidateResult # type: ignore + from ._models import DeploymentWhatIf # type: ignore + from ._models import DeploymentWhatIfProperties # type: ignore + from ._models import DeploymentWhatIfSettings # type: ignore + from ._models import ErrorAdditionalInfo # type: ignore + from ._models import ErrorResponse # type: ignore + from ._models import ExportTemplateRequest # type: ignore + from ._models import GenericResource # type: ignore + from ._models import GenericResourceExpanded # type: ignore + from ._models import GenericResourceFilter # type: ignore + from ._models import HttpMessage # type: ignore + from ._models import Identity # type: ignore + from ._models import OnErrorDeployment # type: ignore + from ._models import OnErrorDeploymentExtended # type: ignore + from ._models import Operation # type: ignore + from ._models import OperationDisplay # type: ignore + from ._models import OperationListResult # type: ignore + from ._models import ParametersLink # type: ignore + from ._models import Plan # type: ignore + from ._models import Provider # type: ignore + from ._models import ProviderListResult # type: ignore + from ._models import ProviderResourceType # type: ignore + from ._models import Resource # type: ignore + from ._models import ResourceGroup # type: ignore + from ._models import ResourceGroupExportResult # type: ignore + from ._models import ResourceGroupFilter # type: ignore + from ._models import ResourceGroupListResult # type: ignore + from ._models import ResourceGroupPatchable # type: ignore + from ._models import ResourceGroupProperties # type: ignore + from ._models import ResourceListResult # type: ignore + from ._models import ResourceProviderOperationDisplayProperties # type: ignore + from ._models import ResourcesMoveInfo # type: ignore + from ._models import ScopedDeployment # type: ignore + from ._models import Sku # type: ignore + from ._models import SubResource # type: ignore + from ._models import TagCount # type: ignore + from ._models import TagDetails # type: ignore + from ._models import TagValue # type: ignore + from ._models import TagsListResult # type: ignore + from ._models import TargetResource # type: ignore + from ._models import TemplateHashResult # type: ignore + from ._models import TemplateLink # type: ignore + from ._models import WhatIfChange # type: ignore + from ._models import WhatIfOperationResult # type: ignore + from ._models import WhatIfPropertyChange # type: ignore + from ._resource_management_client_enums import ( + ChangeType, DeploymentMode, OnErrorDeploymentType, - WhatIfResultFormat, - ResourceIdentityType, PropertyChangeType, - ChangeType, + ResourceIdentityType, + WhatIfResultFormat, ) __all__ = [ 'AliasPathType', 'AliasType', 'BasicDependency', + 'ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties', 'DebugSetting', 'Dependency', 'Deployment', 'DeploymentExportResult', 'DeploymentExtended', 'DeploymentExtendedFilter', + 'DeploymentListResult', 'DeploymentOperation', 'DeploymentOperationProperties', + 'DeploymentOperationsListResult', 'DeploymentProperties', 'DeploymentPropertiesExtended', 'DeploymentValidateResult', @@ -161,21 +169,24 @@ 'GenericResourceFilter', 'HttpMessage', 'Identity', - 'IdentityUserAssignedIdentitiesValue', 'OnErrorDeployment', 'OnErrorDeploymentExtended', 'Operation', 'OperationDisplay', + 'OperationListResult', 'ParametersLink', 'Plan', 'Provider', + 'ProviderListResult', 'ProviderResourceType', 'Resource', 'ResourceGroup', 'ResourceGroupExportResult', 'ResourceGroupFilter', + 'ResourceGroupListResult', 'ResourceGroupPatchable', 'ResourceGroupProperties', + 'ResourceListResult', 'ResourceProviderOperationDisplayProperties', 'ResourcesMoveInfo', 'ScopedDeployment', @@ -184,23 +195,17 @@ 'TagCount', 'TagDetails', 'TagValue', + 'TagsListResult', 'TargetResource', 'TemplateHashResult', 'TemplateLink', 'WhatIfChange', 'WhatIfOperationResult', 'WhatIfPropertyChange', - 'OperationPaged', - 'DeploymentExtendedPaged', - 'ProviderPaged', - 'GenericResourceExpandedPaged', - 'ResourceGroupPaged', - 'TagDetailsPaged', - 'DeploymentOperationPaged', + 'ChangeType', 'DeploymentMode', 'OnErrorDeploymentType', - 'WhatIfResultFormat', - 'ResourceIdentityType', 'PropertyChangeType', - 'ChangeType', + 'ResourceIdentityType', + 'WhatIfResultFormat', ] 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 795db659f2b6..2d554906d180 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 @@ -1,20 +1,16 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.serialization import Model -from msrest.exceptions import HttpOperationError +import msrest.serialization -class AliasPathType(Model): - """The type of the paths for alias. . +class AliasPathType(msrest.serialization.Model): + """The type of the paths for alias. :param path: The path of an alias. :type path: str @@ -27,20 +23,22 @@ class AliasPathType(Model): 'api_versions': {'key': 'apiVersions', 'type': '[str]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(AliasPathType, self).__init__(**kwargs) self.path = kwargs.get('path', None) self.api_versions = kwargs.get('api_versions', None) -class AliasType(Model): - """The alias type. . +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] + :type paths: list[~azure.mgmt.resource.resources.v2019_08_01.models.AliasPathType] """ _attribute_map = { @@ -48,13 +46,16 @@ class AliasType(Model): 'paths': {'key': 'paths', 'type': '[AliasPathType]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(AliasType, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.paths = kwargs.get('paths', None) -class BasicDependency(Model): +class BasicDependency(msrest.serialization.Model): """Deployment dependency information. :param id: The ID of the dependency. @@ -71,52 +72,55 @@ class BasicDependency(Model): 'resource_name': {'key': 'resourceName', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(BasicDependency, self).__init__(**kwargs) self.id = kwargs.get('id', None) self.resource_type = kwargs.get('resource_type', None) self.resource_name = kwargs.get('resource_name', None) -class CloudError(Model): - """An error response for a resource management request. +class ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties(msrest.serialization.Model): + """ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties. - :param error: - :type error: - ~azure.mgmt.resource.resources.v2019_08_01.models.ErrorResponse + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar principal_id: The principal id of user assigned identity. + :vartype principal_id: str + :ivar client_id: The client id of user assigned identity. + :vartype client_id: str """ - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorResponse'}, + _validation = { + 'principal_id': {'readonly': True}, + 'client_id': {'readonly': True}, } - def __init__(self, **kwargs): - super(CloudError, self).__init__(**kwargs) - self.error = kwargs.get('error', None) - - -class CloudErrorException(HttpOperationError): - """Server responsed with exception of type: 'CloudError'. - - :param deserialize: A deserializer - :param response: Server response to be deserialized. - """ - - def __init__(self, deserialize, response, *args): + _attribute_map = { + 'principal_id': {'key': 'principalId', 'type': 'str'}, + 'client_id': {'key': 'clientId', 'type': 'str'}, + } - super(CloudErrorException, self).__init__(deserialize, response, 'CloudError', *args) + def __init__( + self, + **kwargs + ): + super(ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties, self).__init__(**kwargs) + self.principal_id = None + self.client_id = None -class DebugSetting(Model): +class DebugSetting(msrest.serialization.Model): """The debug setting. - :param 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. + :param 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 """ @@ -124,17 +128,19 @@ class DebugSetting(Model): 'detail_level': {'key': 'detailLevel', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DebugSetting, self).__init__(**kwargs) self.detail_level = kwargs.get('detail_level', None) -class Dependency(Model): +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] + :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. @@ -150,7 +156,10 @@ class Dependency(Model): 'resource_name': {'key': 'resourceName', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Dependency, self).__init__(**kwargs) self.depends_on = kwargs.get('depends_on', None) self.id = kwargs.get('id', None) @@ -158,7 +167,7 @@ def __init__(self, **kwargs): self.resource_name = kwargs.get('resource_name', None) -class Deployment(Model): +class Deployment(msrest.serialization.Model): """Deployment operation parameters. All required parameters must be populated in order to send to Azure. @@ -166,8 +175,7 @@ class Deployment(Model): :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 + :type properties: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentProperties """ _validation = { @@ -179,14 +187,17 @@ class Deployment(Model): 'properties': {'key': 'properties', 'type': 'DeploymentProperties'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Deployment, self).__init__(**kwargs) self.location = kwargs.get('location', None) - self.properties = kwargs.get('properties', None) + self.properties = kwargs['properties'] -class DeploymentExportResult(Model): - """The deployment export result. . +class DeploymentExportResult(msrest.serialization.Model): + """The deployment export result. :param template: The template content. :type template: object @@ -196,16 +207,18 @@ class DeploymentExportResult(Model): 'template': {'key': 'template', 'type': 'object'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentExportResult, self).__init__(**kwargs) self.template = kwargs.get('template', None) -class DeploymentExtended(Model): +class DeploymentExtended(msrest.serialization.Model): """Deployment information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The ID of the deployment. :vartype id: str @@ -234,7 +247,10 @@ class DeploymentExtended(Model): 'properties': {'key': 'properties', 'type': 'DeploymentPropertiesExtended'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentExtended, self).__init__(**kwargs) self.id = None self.name = None @@ -243,7 +259,7 @@ def __init__(self, **kwargs): self.properties = kwargs.get('properties', None) -class DeploymentExtendedFilter(Model): +class DeploymentExtendedFilter(msrest.serialization.Model): """Deployment filter. :param provisioning_state: The provisioning state. @@ -254,16 +270,47 @@ class DeploymentExtendedFilter(Model): 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentExtendedFilter, self).__init__(**kwargs) self.provisioning_state = kwargs.get('provisioning_state', None) -class DeploymentOperation(Model): +class DeploymentListResult(msrest.serialization.Model): + """List of deployments. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[DeploymentExtended]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(DeploymentListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = None + + +class DeploymentOperation(msrest.serialization.Model): """Deployment operation information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Full deployment operation ID. :vartype id: str @@ -285,23 +332,25 @@ class DeploymentOperation(Model): 'properties': {'key': 'properties', 'type': 'DeploymentOperationProperties'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentOperation, self).__init__(**kwargs) self.id = None self.operation_id = None self.properties = kwargs.get('properties', None) -class DeploymentOperationProperties(Model): +class DeploymentOperationProperties(msrest.serialization.Model): """Deployment operation properties. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar provisioning_state: The state of the provisioning. :vartype provisioning_state: str :ivar timestamp: The date and time of the operation. - :vartype timestamp: datetime + :vartype timestamp: ~datetime.datetime :ivar duration: The duration of the operation. :vartype duration: str :ivar service_request_id: Deployment operation service request id. @@ -311,14 +360,11 @@ class DeploymentOperationProperties(Model): :ivar status_message: Operation status message. :vartype status_message: object :ivar target_resource: The target resource. - :vartype target_resource: - ~azure.mgmt.resource.resources.v2019_08_01.models.TargetResource + :vartype target_resource: ~azure.mgmt.resource.resources.v2019_08_01.models.TargetResource :ivar request: The HTTP request message. - :vartype request: - ~azure.mgmt.resource.resources.v2019_08_01.models.HttpMessage + :vartype request: ~azure.mgmt.resource.resources.v2019_08_01.models.HttpMessage :ivar response: The HTTP response message. - :vartype response: - ~azure.mgmt.resource.resources.v2019_08_01.models.HttpMessage + :vartype response: ~azure.mgmt.resource.resources.v2019_08_01.models.HttpMessage """ _validation = { @@ -345,7 +391,10 @@ class DeploymentOperationProperties(Model): 'response': {'key': 'response', 'type': 'HttpMessage'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentOperationProperties, self).__init__(**kwargs) self.provisioning_state = None self.timestamp = None @@ -358,48 +407,68 @@ def __init__(self, **kwargs): self.response = None -class DeploymentProperties(Model): +class DeploymentOperationsListResult(msrest.serialization.Model): + """List of deployment operations. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[DeploymentOperation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(DeploymentOperationsListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = None + + +class DeploymentProperties(msrest.serialization.Model): """Deployment properties. 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 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. + :param 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: object - :param 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. 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. + :param 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. + 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: object - :param 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 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 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 + 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 + :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 + :type on_error_deployment: ~azure.mgmt.resource.resources.v2019_08_01.models.OnErrorDeployment """ _validation = { @@ -411,66 +480,59 @@ class DeploymentProperties(Model): 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, 'parameters': {'key': 'parameters', 'type': 'object'}, 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, - 'mode': {'key': 'mode', 'type': 'DeploymentMode'}, + 'mode': {'key': 'mode', 'type': 'str'}, 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, 'on_error_deployment': {'key': 'onErrorDeployment', 'type': 'OnErrorDeployment'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentProperties, self).__init__(**kwargs) self.template = kwargs.get('template', None) self.template_link = kwargs.get('template_link', None) self.parameters = kwargs.get('parameters', None) self.parameters_link = kwargs.get('parameters_link', None) - self.mode = kwargs.get('mode', None) + self.mode = kwargs['mode'] self.debug_setting = kwargs.get('debug_setting', None) self.on_error_deployment = kwargs.get('on_error_deployment', None) -class DeploymentPropertiesExtended(Model): +class DeploymentPropertiesExtended(msrest.serialization.Model): """Deployment properties with additional details. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :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 + :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: object - :param providers: The list of resource providers needed for the - deployment. - :type providers: - list[~azure.mgmt.resource.resources.v2019_08_01.models.Provider] + :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 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: object - :param 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. + :param 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: object - :param 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 include: 'Incremental', 'Complete' - :type mode: str or - ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentMode + :param 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 + 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 + :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.OnErrorDeploymentExtended @@ -495,12 +557,15 @@ class DeploymentPropertiesExtended(Model): 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, 'parameters': {'key': 'parameters', 'type': 'object'}, 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, - 'mode': {'key': 'mode', 'type': 'DeploymentMode'}, + 'mode': {'key': 'mode', 'type': 'str'}, 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, 'on_error_deployment': {'key': 'onErrorDeployment', 'type': 'OnErrorDeploymentExtended'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentPropertiesExtended, self).__init__(**kwargs) self.provisioning_state = None self.correlation_id = None @@ -518,12 +583,11 @@ def __init__(self, **kwargs): self.on_error_deployment = kwargs.get('on_error_deployment', None) -class DeploymentValidateResult(Model): +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 + :type error: ~azure.mgmt.resource.resources.v2019_08_01.models.ErrorResponse :param properties: The template deployment properties. :type properties: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentPropertiesExtended @@ -534,13 +598,16 @@ class DeploymentValidateResult(Model): 'properties': {'key': 'properties', 'type': 'DeploymentPropertiesExtended'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentValidateResult, self).__init__(**kwargs) self.error = kwargs.get('error', None) self.properties = kwargs.get('properties', None) -class DeploymentWhatIf(Model): +class DeploymentWhatIf(msrest.serialization.Model): """Deployment What-if operation parameters. All required parameters must be populated in order to send to Azure. @@ -548,8 +615,7 @@ class DeploymentWhatIf(Model): :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 + :type properties: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentWhatIfProperties """ _validation = { @@ -561,10 +627,13 @@ class DeploymentWhatIf(Model): 'properties': {'key': 'properties', 'type': 'DeploymentWhatIfProperties'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentWhatIf, self).__init__(**kwargs) self.location = kwargs.get('location', None) - self.properties = kwargs.get('properties', None) + self.properties = kwargs['properties'] class DeploymentWhatIfProperties(DeploymentProperties): @@ -572,43 +641,34 @@ 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 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. + :param 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: object - :param 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. 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. + :param 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. + 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: object - :param 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 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 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 + 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 + :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 + :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: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentWhatIfSettings @@ -623,40 +683,45 @@ class DeploymentWhatIfProperties(DeploymentProperties): 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, 'parameters': {'key': 'parameters', 'type': 'object'}, 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, - 'mode': {'key': 'mode', 'type': 'DeploymentMode'}, + 'mode': {'key': 'mode', 'type': 'str'}, 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, 'on_error_deployment': {'key': 'onErrorDeployment', 'type': 'OnErrorDeployment'}, 'what_if_settings': {'key': 'whatIfSettings', 'type': 'DeploymentWhatIfSettings'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentWhatIfProperties, self).__init__(**kwargs) self.what_if_settings = kwargs.get('what_if_settings', None) -class DeploymentWhatIfSettings(Model): +class DeploymentWhatIfSettings(msrest.serialization.Model): """Deployment What-If operation settings. - :param result_format: The format of the What-If results. Possible values - include: 'ResourceIdOnly', 'FullResourcePayloads' + :param result_format: The format of the What-If results. Possible values include: + "ResourceIdOnly", "FullResourcePayloads". :type result_format: str or ~azure.mgmt.resource.resources.v2019_08_01.models.WhatIfResultFormat """ _attribute_map = { - 'result_format': {'key': 'resultFormat', 'type': 'WhatIfResultFormat'}, + 'result_format': {'key': 'resultFormat', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentWhatIfSettings, self).__init__(**kwargs) self.result_format = kwargs.get('result_format', None) -class ErrorAdditionalInfo(Model): +class ErrorAdditionalInfo(msrest.serialization.Model): """The resource management error additional info. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar type: The additional info type. :vartype type: str @@ -674,17 +739,19 @@ class ErrorAdditionalInfo(Model): 'info': {'key': 'info', 'type': 'object'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None -class ErrorResponse(Model): +class ErrorResponse(msrest.serialization.Model): """The resource management error response. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar code: The error code. :vartype code: str @@ -693,8 +760,7 @@ class ErrorResponse(Model): :ivar target: The error target. :vartype target: str :ivar details: The error details. - :vartype details: - list[~azure.mgmt.resource.resources.v2019_08_01.models.ErrorResponse] + :vartype details: list[~azure.mgmt.resource.resources.v2019_08_01.models.ErrorResponse] :ivar additional_info: The error additional info. :vartype additional_info: list[~azure.mgmt.resource.resources.v2019_08_01.models.ErrorAdditionalInfo] @@ -716,7 +782,10 @@ class ErrorResponse(Model): 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ErrorResponse, self).__init__(**kwargs) self.code = None self.message = None @@ -725,16 +794,15 @@ def __init__(self, **kwargs): self.additional_info = None -class ExportTemplateRequest(Model): +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, supply an array with single entry '*'. + :param 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', 'SkipResourceNameParameterization', - 'SkipAllParameterization' + :param options: The export template options. A CSV-formatted list containing zero or more of + the following: 'IncludeParameterDefaultValue', 'IncludeComments', + 'SkipResourceNameParameterization', 'SkipAllParameterization'. :type options: str """ @@ -743,27 +811,29 @@ class ExportTemplateRequest(Model): 'options': {'key': 'options', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ExportTemplateRequest, self).__init__(**kwargs) self.resources = kwargs.get('resources', None) self.options = kwargs.get('options', None) -class Resource(Model): +class Resource(msrest.serialization.Model): """Specified resource. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID + :ivar id: Resource ID. :vartype id: str - :ivar name: Resource name + :ivar name: Resource name. :vartype name: str - :ivar type: Resource type + :ivar type: Resource type. :vartype type: str - :param location: Resource location + :param location: Resource location. :type location: str - :param tags: Resource tags + :param tags: A set of tags. Resource tags. :type tags: dict[str, str] """ @@ -781,7 +851,10 @@ class Resource(Model): 'tags': {'key': 'tags', 'type': '{str}'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -793,18 +866,17 @@ def __init__(self, **kwargs): class GenericResource(Resource): """Resource information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID + :ivar id: Resource ID. :vartype id: str - :ivar name: Resource name + :ivar name: Resource name. :vartype name: str - :ivar type: Resource type + :ivar type: Resource type. :vartype type: str - :param location: Resource location + :param location: Resource location. :type location: str - :param tags: Resource tags + :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 @@ -841,7 +913,10 @@ class GenericResource(Resource): 'identity': {'key': 'identity', 'type': 'Identity'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(GenericResource, self).__init__(**kwargs) self.plan = kwargs.get('plan', None) self.properties = kwargs.get('properties', None) @@ -854,18 +929,17 @@ def __init__(self, **kwargs): class GenericResourceExpanded(GenericResource): """Resource information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID + :ivar id: Resource ID. :vartype id: str - :ivar name: Resource name + :ivar name: Resource name. :vartype name: str - :ivar type: Resource type + :ivar type: Resource type. :vartype type: str - :param location: Resource location + :param location: Resource location. :type location: str - :param tags: Resource tags + :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 @@ -879,14 +953,14 @@ class GenericResourceExpanded(GenericResource): :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 created_time: The created time of the resource. This is only present - if requested via the $expand query parameter. - :vartype created_time: datetime - :ivar changed_time: The changed time of the resource. This is only present - if requested via the $expand query parameter. - :vartype changed_time: datetime - :ivar provisioning_state: The provisioning state of the resource. This is - only present if requested via the $expand query parameter. + :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 + :ivar changed_time: The changed time of the resource. This is only present if requested via the + $expand query parameter. + :vartype changed_time: ~datetime.datetime + :ivar provisioning_state: The provisioning state of the resource. This is only present if + requested via the $expand query parameter. :vartype provisioning_state: str """ @@ -917,14 +991,17 @@ class GenericResourceExpanded(GenericResource): 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(GenericResourceExpanded, self).__init__(**kwargs) self.created_time = None self.changed_time = None self.provisioning_state = None -class GenericResourceFilter(Model): +class GenericResourceFilter(msrest.serialization.Model): """Resource filter. :param resource_type: The resource type. @@ -941,14 +1018,17 @@ class GenericResourceFilter(Model): 'tagvalue': {'key': 'tagvalue', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(GenericResourceFilter, self).__init__(**kwargs) self.resource_type = kwargs.get('resource_type', None) self.tagname = kwargs.get('tagname', None) self.tagvalue = kwargs.get('tagvalue', None) -class HttpMessage(Model): +class HttpMessage(msrest.serialization.Model): """HTTP message. :param content: HTTP message content. @@ -959,31 +1039,31 @@ class HttpMessage(Model): 'content': {'key': 'content', 'type': 'object'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(HttpMessage, self).__init__(**kwargs) self.content = kwargs.get('content', None) -class Identity(Model): +class Identity(msrest.serialization.Model): """Identity for the resource. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar principal_id: The principal ID of resource identity. :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :param 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 user identity dictionary key references will be ARM - resource ids in the form: + :param 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 + 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, - ~azure.mgmt.resource.resources.v2019_08_01.models.IdentityUserAssignedIdentitiesValue] + ~azure.mgmt.resource.resources.v2019_08_01.models.ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties] """ _validation = { @@ -994,11 +1074,14 @@ class Identity(Model): _attribute_map = { 'principal_id': {'key': 'principalId', 'type': 'str'}, 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'ResourceIdentityType'}, - 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{IdentityUserAssignedIdentitiesValue}'}, + 'type': {'key': 'type', 'type': 'str'}, + 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties}'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Identity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None @@ -1006,71 +1089,40 @@ def __init__(self, **kwargs): self.user_assigned_identities = kwargs.get('user_assigned_identities', None) -class IdentityUserAssignedIdentitiesValue(Model): - """IdentityUserAssignedIdentitiesValue. - - Variables are only populated by the server, and will be ignored when - sending a request. - - :ivar principal_id: The principal id of user assigned identity. - :vartype principal_id: str - :ivar client_id: The client id of user assigned identity. - :vartype client_id: str - """ - - _validation = { - 'principal_id': {'readonly': True}, - 'client_id': {'readonly': True}, - } - - _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'client_id': {'key': 'clientId', 'type': 'str'}, - } - - def __init__(self, **kwargs): - super(IdentityUserAssignedIdentitiesValue, self).__init__(**kwargs) - self.principal_id = None - self.client_id = None - - -class OnErrorDeployment(Model): +class OnErrorDeployment(msrest.serialization.Model): """Deployment on error behavior. - :param 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 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 """ _attribute_map = { - 'type': {'key': 'type', 'type': 'OnErrorDeploymentType'}, + 'type': {'key': 'type', 'type': 'str'}, 'deployment_name': {'key': 'deploymentName', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(OnErrorDeployment, self).__init__(**kwargs) self.type = kwargs.get('type', None) self.deployment_name = kwargs.get('deployment_name', None) -class OnErrorDeploymentExtended(Model): +class OnErrorDeploymentExtended(msrest.serialization.Model): """Deployment on error behavior with additional details. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar provisioning_state: The state of the provisioning for the on error - deployment. + :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 SpecificDeployment. Possible values include: - 'LastSuccessful', 'SpecificDeployment' - :type type: str or - ~azure.mgmt.resource.resources.v2019_08_01.models.OnErrorDeploymentType + :param 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 """ @@ -1081,25 +1133,27 @@ class OnErrorDeploymentExtended(Model): _attribute_map = { 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'OnErrorDeploymentType'}, + 'type': {'key': 'type', 'type': 'str'}, 'deployment_name': {'key': 'deploymentName', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(OnErrorDeploymentExtended, self).__init__(**kwargs) self.provisioning_state = None self.type = kwargs.get('type', None) self.deployment_name = kwargs.get('deployment_name', None) -class Operation(Model): +class Operation(msrest.serialization.Model): """Microsoft.Resources operation. - :param name: Operation name: {provider}/{resource}/{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 + :type display: ~azure.mgmt.resource.resources.v2019_08_01.models.OperationDisplay """ _attribute_map = { @@ -1107,19 +1161,21 @@ class Operation(Model): 'display': {'key': 'display', 'type': 'OperationDisplay'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Operation, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.display = kwargs.get('display', None) -class OperationDisplay(Model): +class OperationDisplay(msrest.serialization.Model): """The object that represents the operation. - :param provider: Service provider: Microsoft.Resources + :param provider: Service provider: Microsoft.Resources. :type provider: str - :param resource: Resource on which the operation is performed: Profile, - endpoint, etc. + :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 @@ -1134,7 +1190,10 @@ class OperationDisplay(Model): 'description': {'key': 'description', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(OperationDisplay, self).__init__(**kwargs) self.provider = kwargs.get('provider', None) self.resource = kwargs.get('resource', None) @@ -1142,15 +1201,37 @@ def __init__(self, **kwargs): self.description = kwargs.get('description', None) -class ParametersLink(Model): +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 + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Operation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(OperationListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class ParametersLink(msrest.serialization.Model): """Entity representing the reference to the deployment parameters. 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. + :param content_version: If included, must match the ContentVersion in the template. :type content_version: str """ @@ -1163,13 +1244,16 @@ class ParametersLink(Model): 'content_version': {'key': 'contentVersion', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ParametersLink, self).__init__(**kwargs) - self.uri = kwargs.get('uri', None) + self.uri = kwargs['uri'] self.content_version = kwargs.get('content_version', None) -class Plan(Model): +class Plan(msrest.serialization.Model): """Plan for the resource. :param name: The plan ID. @@ -1192,7 +1276,10 @@ class Plan(Model): 'version': {'key': 'version', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Plan, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.publisher = kwargs.get('publisher', None) @@ -1201,11 +1288,10 @@ def __init__(self, **kwargs): self.version = kwargs.get('version', None) -class Provider(Model): +class Provider(msrest.serialization.Model): """Resource provider information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The provider ID. :vartype id: str @@ -1213,8 +1299,7 @@ class Provider(Model): :type 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. + :ivar registration_policy: The registration policy of the resource provider. :vartype registration_policy: str :ivar resource_types: The collection of provider resource types. :vartype resource_types: @@ -1236,7 +1321,10 @@ class Provider(Model): 'resource_types': {'key': 'resourceTypes', 'type': '[ProviderResourceType]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Provider, self).__init__(**kwargs) self.id = None self.namespace = kwargs.get('namespace', None) @@ -1245,21 +1333,47 @@ def __init__(self, **kwargs): self.resource_types = None -class ProviderResourceType(Model): +class ProviderListResult(msrest.serialization.Model): + """List of resource providers. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Provider]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ProviderListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = None + + +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. + :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] + :type aliases: list[~azure.mgmt.resource.resources.v2019_08_01.models.AliasType] :param api_versions: The API version. :type api_versions: list[str] - :param capabilities: The additional capabilities offered by this resource - type. + :param capabilities: The additional capabilities offered by this resource type. :type capabilities: str :param properties: The properties. :type properties: dict[str, str] @@ -1274,7 +1388,10 @@ class ProviderResourceType(Model): 'properties': {'key': 'properties', 'type': '{str}'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ProviderResourceType, self).__init__(**kwargs) self.resource_type = kwargs.get('resource_type', None) self.locations = kwargs.get('locations', None) @@ -1284,11 +1401,10 @@ def __init__(self, **kwargs): self.properties = kwargs.get('properties', None) -class ResourceGroup(Model): +class ResourceGroup(msrest.serialization.Model): """Resource group information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. @@ -1299,16 +1415,13 @@ class ResourceGroup(Model): :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 resource group has been created. It must be one of - the supported Azure locations. + :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 + 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. + :param managed_by: The ID of the resource that manages this resource group. :type managed_by: str - :param tags: The tags attached to the resource group. + :param tags: A set of tags. The tags attached to the resource group. :type tags: dict[str, str] """ @@ -1329,25 +1442,27 @@ class ResourceGroup(Model): 'tags': {'key': 'tags', 'type': '{str}'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ResourceGroup, self).__init__(**kwargs) self.id = None self.name = None self.type = None self.properties = kwargs.get('properties', None) - self.location = kwargs.get('location', None) + self.location = kwargs['location'] self.managed_by = kwargs.get('managed_by', None) self.tags = kwargs.get('tags', None) -class ResourceGroupExportResult(Model): +class ResourceGroupExportResult(msrest.serialization.Model): """Resource group export result. :param template: The template content. :type template: object :param error: The template export error. - :type error: - ~azure.mgmt.resource.resources.v2019_08_01.models.ErrorResponse + :type error: ~azure.mgmt.resource.resources.v2019_08_01.models.ErrorResponse """ _attribute_map = { @@ -1355,13 +1470,16 @@ class ResourceGroupExportResult(Model): 'error': {'key': 'error', 'type': 'ErrorResponse'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ResourceGroupExportResult, self).__init__(**kwargs) self.template = kwargs.get('template', None) self.error = kwargs.get('error', None) -class ResourceGroupFilter(Model): +class ResourceGroupFilter(msrest.serialization.Model): """Resource group filter. :param tag_name: The tag name. @@ -1375,24 +1493,54 @@ class ResourceGroupFilter(Model): 'tag_value': {'key': 'tagValue', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ResourceGroupFilter, self).__init__(**kwargs) self.tag_name = kwargs.get('tag_name', None) self.tag_value = kwargs.get('tag_value', None) -class ResourceGroupPatchable(Model): +class ResourceGroupListResult(msrest.serialization.Model): + """List of resource groups. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ResourceGroup]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ResourceGroupListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = None + + +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 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: The tags attached to the resource group. + :param tags: A set of tags. The tags attached to the resource group. :type tags: dict[str, str] """ @@ -1403,7 +1551,10 @@ class ResourceGroupPatchable(Model): 'tags': {'key': 'tags', 'type': '{str}'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ResourceGroupPatchable, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.properties = kwargs.get('properties', None) @@ -1411,11 +1562,10 @@ def __init__(self, **kwargs): self.tags = kwargs.get('tags', None) -class ResourceGroupProperties(Model): +class ResourceGroupProperties(msrest.serialization.Model): """The resource group properties. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar provisioning_state: The provisioning state. :vartype provisioning_state: str @@ -1429,12 +1579,44 @@ class ResourceGroupProperties(Model): 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ResourceGroupProperties, self).__init__(**kwargs) self.provisioning_state = None -class ResourceProviderOperationDisplayProperties(Model): +class ResourceListResult(msrest.serialization.Model): + """List of resource groups. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[GenericResourceExpanded]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ResourceListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = None + + +class ResourceProviderOperationDisplayProperties(msrest.serialization.Model): """Resource provider operation's display properties. :param publisher: Operation description. @@ -1457,7 +1639,10 @@ class ResourceProviderOperationDisplayProperties(Model): 'description': {'key': 'description', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ResourceProviderOperationDisplayProperties, self).__init__(**kwargs) self.publisher = kwargs.get('publisher', None) self.provider = kwargs.get('provider', None) @@ -1466,7 +1651,7 @@ def __init__(self, **kwargs): self.description = kwargs.get('description', None) -class ResourcesMoveInfo(Model): +class ResourcesMoveInfo(msrest.serialization.Model): """Parameters of move resources. :param resources: The IDs of the resources. @@ -1480,13 +1665,16 @@ class ResourcesMoveInfo(Model): 'target_resource_group': {'key': 'targetResourceGroup', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ResourcesMoveInfo, self).__init__(**kwargs) self.resources = kwargs.get('resources', None) self.target_resource_group = kwargs.get('target_resource_group', None) -class ScopedDeployment(Model): +class ScopedDeployment(msrest.serialization.Model): """Deployment operation parameters. All required parameters must be populated in order to send to Azure. @@ -1494,8 +1682,7 @@ class ScopedDeployment(Model): :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 + :type properties: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentProperties """ _validation = { @@ -1508,13 +1695,16 @@ class ScopedDeployment(Model): 'properties': {'key': 'properties', 'type': 'DeploymentProperties'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ScopedDeployment, self).__init__(**kwargs) - self.location = kwargs.get('location', None) - self.properties = kwargs.get('properties', None) + self.location = kwargs['location'] + self.properties = kwargs['properties'] -class Sku(Model): +class Sku(msrest.serialization.Model): """SKU for the resource. :param name: The SKU name. @@ -1540,7 +1730,10 @@ class Sku(Model): 'capacity': {'key': 'capacity', 'type': 'int'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Sku, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.tier = kwargs.get('tier', None) @@ -1550,10 +1743,10 @@ def __init__(self, **kwargs): self.capacity = kwargs.get('capacity', None) -class SubResource(Model): +class SubResource(msrest.serialization.Model): """Sub-resource. - :param id: Resource ID + :param id: Resource ID. :type id: str """ @@ -1561,12 +1754,15 @@ class SubResource(Model): 'id': {'key': 'id', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(SubResource, self).__init__(**kwargs) self.id = kwargs.get('id', None) -class TagCount(Model): +class TagCount(msrest.serialization.Model): """Tag count. :param type: Type of count. @@ -1580,29 +1776,29 @@ class TagCount(Model): 'value': {'key': 'value', 'type': 'int'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(TagCount, self).__init__(**kwargs) self.type = kwargs.get('type', None) self.value = kwargs.get('value', None) -class TagDetails(Model): +class TagDetails(msrest.serialization.Model): """Tag details. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :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 created and has no associated resources, the value - is 0. + :param 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] + :type values: list[~azure.mgmt.resource.resources.v2019_08_01.models.TagValue] """ _validation = { @@ -1616,7 +1812,10 @@ class TagDetails(Model): 'values': {'key': 'values', 'type': '[TagValue]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(TagDetails, self).__init__(**kwargs) self.id = None self.tag_name = kwargs.get('tag_name', None) @@ -1624,11 +1823,39 @@ def __init__(self, **kwargs): self.values = kwargs.get('values', None) -class TagValue(Model): +class TagsListResult(msrest.serialization.Model): + """List of subscription tags. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[TagDetails]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(TagsListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = None + + +class TagValue(msrest.serialization.Model): """Tag information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The tag ID. :vartype id: str @@ -1648,14 +1875,17 @@ class TagValue(Model): 'count': {'key': 'count', 'type': 'TagCount'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(TagValue, self).__init__(**kwargs) self.id = None self.tag_value = kwargs.get('tag_value', None) self.count = kwargs.get('count', None) -class TargetResource(Model): +class TargetResource(msrest.serialization.Model): """Target resource. :param id: The ID of the resource. @@ -1672,16 +1902,18 @@ class TargetResource(Model): 'resource_type': {'key': 'resourceType', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(TargetResource, self).__init__(**kwargs) self.id = kwargs.get('id', None) self.resource_name = kwargs.get('resource_name', None) self.resource_type = kwargs.get('resource_type', None) -class TemplateHashResult(Model): - """Result of the request to calculate template hash. It contains a string of - minified template and its hash. +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 @@ -1694,21 +1926,23 @@ class TemplateHashResult(Model): 'template_hash': {'key': 'templateHash', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(TemplateHashResult, self).__init__(**kwargs) self.minified_template = kwargs.get('minified_template', None) self.template_hash = kwargs.get('template_hash', None) -class TemplateLink(Model): +class TemplateLink(msrest.serialization.Model): """Entity representing the reference to the template. 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. + :param content_version: If included, must match the ContentVersion in the template. :type content_version: str """ @@ -1721,33 +1955,32 @@ class TemplateLink(Model): 'content_version': {'key': 'contentVersion', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(TemplateLink, self).__init__(**kwargs) - self.uri = kwargs.get('uri', None) + self.uri = kwargs['uri'] self.content_version = kwargs.get('content_version', None) -class WhatIfChange(Model): +class WhatIfChange(msrest.serialization.Model): """Information about a single resource change predicted by What-If operation. All required parameters must be populated in order to send to Azure. - :param resource_id: Required. Resource ID + :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 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. + :param 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: object - :param after: The predicted snapshot of the resource after the deployment - is executed. + :param after: The predicted snapshot of the resource after the deployment is executed. :type after: object :param delta: The predicted changes to resource properties. - :type delta: - list[~azure.mgmt.resource.resources.v2019_08_01.models.WhatIfPropertyChange] + :type delta: list[~azure.mgmt.resource.resources.v2019_08_01.models.WhatIfPropertyChange] """ _validation = { @@ -1757,67 +1990,68 @@ class WhatIfChange(Model): _attribute_map = { 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'change_type': {'key': 'changeType', 'type': 'ChangeType'}, + 'change_type': {'key': 'changeType', 'type': 'str'}, 'before': {'key': 'before', 'type': 'object'}, 'after': {'key': 'after', 'type': 'object'}, 'delta': {'key': 'delta', 'type': '[WhatIfPropertyChange]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(WhatIfChange, self).__init__(**kwargs) - self.resource_id = kwargs.get('resource_id', None) - self.change_type = kwargs.get('change_type', None) + self.resource_id = kwargs['resource_id'] + self.change_type = kwargs['change_type'] self.before = kwargs.get('before', None) self.after = kwargs.get('after', None) self.delta = kwargs.get('delta', None) -class WhatIfOperationResult(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. +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 changes: List of resource changes predicted by What-If operation. - :type changes: - list[~azure.mgmt.resource.resources.v2019_08_01.models.WhatIfChange] :param error: Error when What-If operation fails. - :type error: - ~azure.mgmt.resource.resources.v2019_08_01.models.ErrorResponse + :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] """ _attribute_map = { 'status': {'key': 'status', 'type': 'str'}, - 'changes': {'key': 'properties.changes', 'type': '[WhatIfChange]'}, 'error': {'key': 'error', 'type': 'ErrorResponse'}, + 'changes': {'key': 'properties.changes', 'type': '[WhatIfChange]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(WhatIfOperationResult, self).__init__(**kwargs) self.status = kwargs.get('status', None) - self.changes = kwargs.get('changes', None) self.error = kwargs.get('error', None) + self.changes = kwargs.get('changes', None) -class WhatIfPropertyChange(Model): +class WhatIfPropertyChange(msrest.serialization.Model): """The predicted change to the resource property. 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: 'Create', 'Delete', 'Modify', 'Array' + :param property_change_type: Required. The type of property change. Possible values include: + "Create", "Delete", "Modify", "Array". :type 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. + :param before: The value of the property before the deployment is executed. :type before: object :param after: The value of the property after the deployment is executed. :type after: object :param children: Nested property changes. - :type children: - list[~azure.mgmt.resource.resources.v2019_08_01.models.WhatIfPropertyChange] + :type children: list[~azure.mgmt.resource.resources.v2019_08_01.models.WhatIfPropertyChange] """ _validation = { @@ -1827,16 +2061,19 @@ class WhatIfPropertyChange(Model): _attribute_map = { 'path': {'key': 'path', 'type': 'str'}, - 'property_change_type': {'key': 'propertyChangeType', 'type': 'PropertyChangeType'}, + 'property_change_type': {'key': 'propertyChangeType', 'type': 'str'}, 'before': {'key': 'before', 'type': 'object'}, 'after': {'key': 'after', 'type': 'object'}, 'children': {'key': 'children', 'type': '[WhatIfPropertyChange]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(WhatIfPropertyChange, self).__init__(**kwargs) - self.path = kwargs.get('path', None) - self.property_change_type = kwargs.get('property_change_type', None) + 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) 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 3c9993b1d39b..d284dec71b9c 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 @@ -1,20 +1,20 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.serialization import Model -from msrest.exceptions import HttpOperationError +from typing import Dict, List, Optional, Union +import msrest.serialization -class AliasPathType(Model): - """The type of the paths for alias. . +from ._resource_management_client_enums import * + + +class AliasPathType(msrest.serialization.Model): + """The type of the paths for alias. :param path: The path of an alias. :type path: str @@ -27,20 +27,25 @@ class AliasPathType(Model): 'api_versions': {'key': 'apiVersions', 'type': '[str]'}, } - def __init__(self, *, path: str=None, api_versions=None, **kwargs) -> None: + def __init__( + self, + *, + path: Optional[str] = None, + api_versions: Optional[List[str]] = None, + **kwargs + ): super(AliasPathType, self).__init__(**kwargs) self.path = path self.api_versions = api_versions -class AliasType(Model): - """The alias type. . +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] + :type paths: list[~azure.mgmt.resource.resources.v2019_08_01.models.AliasPathType] """ _attribute_map = { @@ -48,13 +53,19 @@ class AliasType(Model): 'paths': {'key': 'paths', 'type': '[AliasPathType]'}, } - def __init__(self, *, name: str=None, paths=None, **kwargs) -> None: + def __init__( + self, + *, + name: Optional[str] = None, + paths: Optional[List["AliasPathType"]] = None, + **kwargs + ): super(AliasType, self).__init__(**kwargs) self.name = name self.paths = paths -class BasicDependency(Model): +class BasicDependency(msrest.serialization.Model): """Deployment dependency information. :param id: The ID of the dependency. @@ -71,52 +82,59 @@ class BasicDependency(Model): 'resource_name': {'key': 'resourceName', 'type': 'str'}, } - def __init__(self, *, id: str=None, resource_type: str=None, resource_name: str=None, **kwargs) -> None: + def __init__( + self, + *, + id: Optional[str] = None, + resource_type: Optional[str] = None, + resource_name: Optional[str] = None, + **kwargs + ): super(BasicDependency, self).__init__(**kwargs) self.id = id self.resource_type = resource_type self.resource_name = resource_name -class CloudError(Model): - """An error response for a resource management request. +class ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties(msrest.serialization.Model): + """ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties. + + Variables are only populated by the server, and will be ignored when sending a request. - :param error: - :type error: - ~azure.mgmt.resource.resources.v2019_08_01.models.ErrorResponse + :ivar principal_id: The principal id of user assigned identity. + :vartype principal_id: str + :ivar client_id: The client id of user assigned identity. + :vartype client_id: str """ - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorResponse'}, + _validation = { + 'principal_id': {'readonly': True}, + 'client_id': {'readonly': True}, } - def __init__(self, *, error=None, **kwargs) -> None: - super(CloudError, self).__init__(**kwargs) - self.error = error - - -class CloudErrorException(HttpOperationError): - """Server responsed with exception of type: 'CloudError'. - - :param deserialize: A deserializer - :param response: Server response to be deserialized. - """ - - def __init__(self, deserialize, response, *args): + _attribute_map = { + 'principal_id': {'key': 'principalId', 'type': 'str'}, + 'client_id': {'key': 'clientId', 'type': 'str'}, + } - super(CloudErrorException, self).__init__(deserialize, response, 'CloudError', *args) + def __init__( + self, + **kwargs + ): + super(ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties, self).__init__(**kwargs) + self.principal_id = None + self.client_id = None -class DebugSetting(Model): +class DebugSetting(msrest.serialization.Model): """The debug setting. - :param 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. + :param 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 """ @@ -124,17 +142,21 @@ class DebugSetting(Model): 'detail_level': {'key': 'detailLevel', 'type': 'str'}, } - def __init__(self, *, detail_level: str=None, **kwargs) -> None: + def __init__( + self, + *, + detail_level: Optional[str] = None, + **kwargs + ): super(DebugSetting, self).__init__(**kwargs) self.detail_level = detail_level -class Dependency(Model): +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] + :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. @@ -150,7 +172,15 @@ class Dependency(Model): 'resource_name': {'key': 'resourceName', 'type': 'str'}, } - def __init__(self, *, depends_on=None, id: str=None, resource_type: str=None, resource_name: str=None, **kwargs) -> None: + def __init__( + self, + *, + depends_on: Optional[List["BasicDependency"]] = None, + id: Optional[str] = None, + resource_type: Optional[str] = None, + resource_name: Optional[str] = None, + **kwargs + ): super(Dependency, self).__init__(**kwargs) self.depends_on = depends_on self.id = id @@ -158,7 +188,7 @@ def __init__(self, *, depends_on=None, id: str=None, resource_type: str=None, re self.resource_name = resource_name -class Deployment(Model): +class Deployment(msrest.serialization.Model): """Deployment operation parameters. All required parameters must be populated in order to send to Azure. @@ -166,8 +196,7 @@ class Deployment(Model): :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 + :type properties: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentProperties """ _validation = { @@ -179,14 +208,20 @@ class Deployment(Model): 'properties': {'key': 'properties', 'type': 'DeploymentProperties'}, } - def __init__(self, *, properties, location: str=None, **kwargs) -> None: + def __init__( + self, + *, + properties: "DeploymentProperties", + location: Optional[str] = None, + **kwargs + ): super(Deployment, self).__init__(**kwargs) self.location = location self.properties = properties -class DeploymentExportResult(Model): - """The deployment export result. . +class DeploymentExportResult(msrest.serialization.Model): + """The deployment export result. :param template: The template content. :type template: object @@ -196,16 +231,20 @@ class DeploymentExportResult(Model): 'template': {'key': 'template', 'type': 'object'}, } - def __init__(self, *, template=None, **kwargs) -> None: + def __init__( + self, + *, + template: Optional[object] = None, + **kwargs + ): super(DeploymentExportResult, self).__init__(**kwargs) self.template = template -class DeploymentExtended(Model): +class DeploymentExtended(msrest.serialization.Model): """Deployment information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The ID of the deployment. :vartype id: str @@ -234,7 +273,13 @@ class DeploymentExtended(Model): 'properties': {'key': 'properties', 'type': 'DeploymentPropertiesExtended'}, } - def __init__(self, *, location: str=None, properties=None, **kwargs) -> None: + def __init__( + self, + *, + location: Optional[str] = None, + properties: Optional["DeploymentPropertiesExtended"] = None, + **kwargs + ): super(DeploymentExtended, self).__init__(**kwargs) self.id = None self.name = None @@ -243,7 +288,7 @@ def __init__(self, *, location: str=None, properties=None, **kwargs) -> None: self.properties = properties -class DeploymentExtendedFilter(Model): +class DeploymentExtendedFilter(msrest.serialization.Model): """Deployment filter. :param provisioning_state: The provisioning state. @@ -254,16 +299,51 @@ class DeploymentExtendedFilter(Model): 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, } - def __init__(self, *, provisioning_state: str=None, **kwargs) -> None: + def __init__( + self, + *, + provisioning_state: Optional[str] = None, + **kwargs + ): super(DeploymentExtendedFilter, self).__init__(**kwargs) self.provisioning_state = provisioning_state -class DeploymentOperation(Model): +class DeploymentListResult(msrest.serialization.Model): + """List of deployments. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[DeploymentExtended]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["DeploymentExtended"]] = None, + **kwargs + ): + super(DeploymentListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class DeploymentOperation(msrest.serialization.Model): """Deployment operation information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Full deployment operation ID. :vartype id: str @@ -285,23 +365,27 @@ class DeploymentOperation(Model): 'properties': {'key': 'properties', 'type': 'DeploymentOperationProperties'}, } - def __init__(self, *, properties=None, **kwargs) -> None: + def __init__( + self, + *, + properties: Optional["DeploymentOperationProperties"] = None, + **kwargs + ): super(DeploymentOperation, self).__init__(**kwargs) self.id = None self.operation_id = None self.properties = properties -class DeploymentOperationProperties(Model): +class DeploymentOperationProperties(msrest.serialization.Model): """Deployment operation properties. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar provisioning_state: The state of the provisioning. :vartype provisioning_state: str :ivar timestamp: The date and time of the operation. - :vartype timestamp: datetime + :vartype timestamp: ~datetime.datetime :ivar duration: The duration of the operation. :vartype duration: str :ivar service_request_id: Deployment operation service request id. @@ -311,14 +395,11 @@ class DeploymentOperationProperties(Model): :ivar status_message: Operation status message. :vartype status_message: object :ivar target_resource: The target resource. - :vartype target_resource: - ~azure.mgmt.resource.resources.v2019_08_01.models.TargetResource + :vartype target_resource: ~azure.mgmt.resource.resources.v2019_08_01.models.TargetResource :ivar request: The HTTP request message. - :vartype request: - ~azure.mgmt.resource.resources.v2019_08_01.models.HttpMessage + :vartype request: ~azure.mgmt.resource.resources.v2019_08_01.models.HttpMessage :ivar response: The HTTP response message. - :vartype response: - ~azure.mgmt.resource.resources.v2019_08_01.models.HttpMessage + :vartype response: ~azure.mgmt.resource.resources.v2019_08_01.models.HttpMessage """ _validation = { @@ -345,7 +426,10 @@ class DeploymentOperationProperties(Model): 'response': {'key': 'response', 'type': 'HttpMessage'}, } - def __init__(self, **kwargs) -> None: + def __init__( + self, + **kwargs + ): super(DeploymentOperationProperties, self).__init__(**kwargs) self.provisioning_state = None self.timestamp = None @@ -358,48 +442,70 @@ def __init__(self, **kwargs) -> None: self.response = None -class DeploymentProperties(Model): +class DeploymentOperationsListResult(msrest.serialization.Model): + """List of deployment operations. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[DeploymentOperation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["DeploymentOperation"]] = None, + **kwargs + ): + super(DeploymentOperationsListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class DeploymentProperties(msrest.serialization.Model): """Deployment properties. 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 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. + :param 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: object - :param 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. 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. + :param 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. + 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: object - :param 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 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 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 + 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 + :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 + :type on_error_deployment: ~azure.mgmt.resource.resources.v2019_08_01.models.OnErrorDeployment """ _validation = { @@ -411,12 +517,23 @@ class DeploymentProperties(Model): 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, 'parameters': {'key': 'parameters', 'type': 'object'}, 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, - 'mode': {'key': 'mode', 'type': 'DeploymentMode'}, + 'mode': {'key': 'mode', 'type': 'str'}, 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, 'on_error_deployment': {'key': 'onErrorDeployment', 'type': 'OnErrorDeployment'}, } - def __init__(self, *, mode, template=None, template_link=None, parameters=None, parameters_link=None, debug_setting=None, on_error_deployment=None, **kwargs) -> None: + def __init__( + self, + *, + mode: Union[str, "DeploymentMode"], + template: Optional[object] = None, + template_link: Optional["TemplateLink"] = None, + parameters: Optional[object] = None, + parameters_link: Optional["ParametersLink"] = None, + debug_setting: Optional["DebugSetting"] = None, + on_error_deployment: Optional["OnErrorDeployment"] = None, + **kwargs + ): super(DeploymentProperties, self).__init__(**kwargs) self.template = template self.template_link = template_link @@ -427,50 +544,40 @@ def __init__(self, *, mode, template=None, template_link=None, parameters=None, self.on_error_deployment = on_error_deployment -class DeploymentPropertiesExtended(Model): +class DeploymentPropertiesExtended(msrest.serialization.Model): """Deployment properties with additional details. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :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 + :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: object - :param providers: The list of resource providers needed for the - deployment. - :type providers: - list[~azure.mgmt.resource.resources.v2019_08_01.models.Provider] + :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 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: object - :param 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. + :param 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: object - :param 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 include: 'Incremental', 'Complete' - :type mode: str or - ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentMode + :param 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 + 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 + :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.OnErrorDeploymentExtended @@ -495,12 +602,26 @@ class DeploymentPropertiesExtended(Model): 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, 'parameters': {'key': 'parameters', 'type': 'object'}, 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, - 'mode': {'key': 'mode', 'type': 'DeploymentMode'}, + 'mode': {'key': 'mode', 'type': 'str'}, 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, 'on_error_deployment': {'key': 'onErrorDeployment', 'type': 'OnErrorDeploymentExtended'}, } - def __init__(self, *, outputs=None, providers=None, dependencies=None, template=None, template_link=None, parameters=None, parameters_link=None, mode=None, debug_setting=None, on_error_deployment=None, **kwargs) -> None: + def __init__( + self, + *, + outputs: Optional[object] = None, + providers: Optional[List["Provider"]] = None, + dependencies: Optional[List["Dependency"]] = None, + template: Optional[object] = None, + template_link: Optional["TemplateLink"] = None, + parameters: Optional[object] = None, + parameters_link: Optional["ParametersLink"] = None, + mode: Optional[Union[str, "DeploymentMode"]] = None, + debug_setting: Optional["DebugSetting"] = None, + on_error_deployment: Optional["OnErrorDeploymentExtended"] = None, + **kwargs + ): super(DeploymentPropertiesExtended, self).__init__(**kwargs) self.provisioning_state = None self.correlation_id = None @@ -518,12 +639,11 @@ def __init__(self, *, outputs=None, providers=None, dependencies=None, template= self.on_error_deployment = on_error_deployment -class DeploymentValidateResult(Model): +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 + :type error: ~azure.mgmt.resource.resources.v2019_08_01.models.ErrorResponse :param properties: The template deployment properties. :type properties: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentPropertiesExtended @@ -534,13 +654,19 @@ class DeploymentValidateResult(Model): 'properties': {'key': 'properties', 'type': 'DeploymentPropertiesExtended'}, } - def __init__(self, *, error=None, properties=None, **kwargs) -> None: + def __init__( + self, + *, + error: Optional["ErrorResponse"] = None, + properties: Optional["DeploymentPropertiesExtended"] = None, + **kwargs + ): super(DeploymentValidateResult, self).__init__(**kwargs) self.error = error self.properties = properties -class DeploymentWhatIf(Model): +class DeploymentWhatIf(msrest.serialization.Model): """Deployment What-if operation parameters. All required parameters must be populated in order to send to Azure. @@ -548,8 +674,7 @@ class DeploymentWhatIf(Model): :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 + :type properties: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentWhatIfProperties """ _validation = { @@ -561,7 +686,13 @@ class DeploymentWhatIf(Model): 'properties': {'key': 'properties', 'type': 'DeploymentWhatIfProperties'}, } - def __init__(self, *, properties, location: str=None, **kwargs) -> None: + def __init__( + self, + *, + properties: "DeploymentWhatIfProperties", + location: Optional[str] = None, + **kwargs + ): super(DeploymentWhatIf, self).__init__(**kwargs) self.location = location self.properties = properties @@ -572,43 +703,34 @@ 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 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. + :param 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: object - :param 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. 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. + :param 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. + 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: object - :param 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 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 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 + 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 + :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 + :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: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentWhatIfSettings @@ -623,40 +745,56 @@ class DeploymentWhatIfProperties(DeploymentProperties): 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, 'parameters': {'key': 'parameters', 'type': 'object'}, 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, - 'mode': {'key': 'mode', 'type': 'DeploymentMode'}, + 'mode': {'key': 'mode', 'type': 'str'}, 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, 'on_error_deployment': {'key': 'onErrorDeployment', 'type': 'OnErrorDeployment'}, 'what_if_settings': {'key': 'whatIfSettings', 'type': 'DeploymentWhatIfSettings'}, } - def __init__(self, *, mode, template=None, template_link=None, parameters=None, parameters_link=None, debug_setting=None, on_error_deployment=None, what_if_settings=None, **kwargs) -> None: + def __init__( + self, + *, + mode: Union[str, "DeploymentMode"], + template: Optional[object] = None, + template_link: Optional["TemplateLink"] = None, + parameters: Optional[object] = None, + parameters_link: Optional["ParametersLink"] = None, + debug_setting: Optional["DebugSetting"] = None, + on_error_deployment: Optional["OnErrorDeployment"] = None, + what_if_settings: Optional["DeploymentWhatIfSettings"] = None, + **kwargs + ): 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 -class DeploymentWhatIfSettings(Model): +class DeploymentWhatIfSettings(msrest.serialization.Model): """Deployment What-If operation settings. - :param result_format: The format of the What-If results. Possible values - include: 'ResourceIdOnly', 'FullResourcePayloads' + :param result_format: The format of the What-If results. Possible values include: + "ResourceIdOnly", "FullResourcePayloads". :type result_format: str or ~azure.mgmt.resource.resources.v2019_08_01.models.WhatIfResultFormat """ _attribute_map = { - 'result_format': {'key': 'resultFormat', 'type': 'WhatIfResultFormat'}, + 'result_format': {'key': 'resultFormat', 'type': 'str'}, } - def __init__(self, *, result_format=None, **kwargs) -> None: + def __init__( + self, + *, + result_format: Optional[Union[str, "WhatIfResultFormat"]] = None, + **kwargs + ): super(DeploymentWhatIfSettings, self).__init__(**kwargs) self.result_format = result_format -class ErrorAdditionalInfo(Model): +class ErrorAdditionalInfo(msrest.serialization.Model): """The resource management error additional info. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar type: The additional info type. :vartype type: str @@ -674,17 +812,19 @@ class ErrorAdditionalInfo(Model): 'info': {'key': 'info', 'type': 'object'}, } - def __init__(self, **kwargs) -> None: + def __init__( + self, + **kwargs + ): super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None -class ErrorResponse(Model): +class ErrorResponse(msrest.serialization.Model): """The resource management error response. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar code: The error code. :vartype code: str @@ -693,8 +833,7 @@ class ErrorResponse(Model): :ivar target: The error target. :vartype target: str :ivar details: The error details. - :vartype details: - list[~azure.mgmt.resource.resources.v2019_08_01.models.ErrorResponse] + :vartype details: list[~azure.mgmt.resource.resources.v2019_08_01.models.ErrorResponse] :ivar additional_info: The error additional info. :vartype additional_info: list[~azure.mgmt.resource.resources.v2019_08_01.models.ErrorAdditionalInfo] @@ -716,7 +855,10 @@ class ErrorResponse(Model): 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, } - def __init__(self, **kwargs) -> None: + def __init__( + self, + **kwargs + ): super(ErrorResponse, self).__init__(**kwargs) self.code = None self.message = None @@ -725,16 +867,15 @@ def __init__(self, **kwargs) -> None: self.additional_info = None -class ExportTemplateRequest(Model): +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, supply an array with single entry '*'. + :param 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', 'SkipResourceNameParameterization', - 'SkipAllParameterization' + :param options: The export template options. A CSV-formatted list containing zero or more of + the following: 'IncludeParameterDefaultValue', 'IncludeComments', + 'SkipResourceNameParameterization', 'SkipAllParameterization'. :type options: str """ @@ -743,27 +884,32 @@ class ExportTemplateRequest(Model): 'options': {'key': 'options', 'type': 'str'}, } - def __init__(self, *, resources=None, options: str=None, **kwargs) -> None: + def __init__( + self, + *, + resources: Optional[List[str]] = None, + options: Optional[str] = None, + **kwargs + ): super(ExportTemplateRequest, self).__init__(**kwargs) self.resources = resources self.options = options -class Resource(Model): +class Resource(msrest.serialization.Model): """Specified resource. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID + :ivar id: Resource ID. :vartype id: str - :ivar name: Resource name + :ivar name: Resource name. :vartype name: str - :ivar type: Resource type + :ivar type: Resource type. :vartype type: str - :param location: Resource location + :param location: Resource location. :type location: str - :param tags: Resource tags + :param tags: A set of tags. Resource tags. :type tags: dict[str, str] """ @@ -781,7 +927,13 @@ class Resource(Model): 'tags': {'key': 'tags', 'type': '{str}'}, } - def __init__(self, *, location: str=None, tags=None, **kwargs) -> None: + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -793,18 +945,17 @@ def __init__(self, *, location: str=None, tags=None, **kwargs) -> None: class GenericResource(Resource): """Resource information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID + :ivar id: Resource ID. :vartype id: str - :ivar name: Resource name + :ivar name: Resource name. :vartype name: str - :ivar type: Resource type + :ivar type: Resource type. :vartype type: str - :param location: Resource location + :param location: Resource location. :type location: str - :param tags: Resource tags + :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 @@ -841,7 +992,19 @@ class GenericResource(Resource): 'identity': {'key': 'identity', 'type': 'Identity'}, } - def __init__(self, *, location: str=None, tags=None, plan=None, properties=None, kind: str=None, managed_by: str=None, sku=None, identity=None, **kwargs) -> None: + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + plan: Optional["Plan"] = None, + properties: Optional[object] = None, + kind: Optional[str] = None, + managed_by: Optional[str] = None, + sku: Optional["Sku"] = None, + identity: Optional["Identity"] = None, + **kwargs + ): super(GenericResource, self).__init__(location=location, tags=tags, **kwargs) self.plan = plan self.properties = properties @@ -854,18 +1017,17 @@ def __init__(self, *, location: str=None, tags=None, plan=None, properties=None, class GenericResourceExpanded(GenericResource): """Resource information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID + :ivar id: Resource ID. :vartype id: str - :ivar name: Resource name + :ivar name: Resource name. :vartype name: str - :ivar type: Resource type + :ivar type: Resource type. :vartype type: str - :param location: Resource location + :param location: Resource location. :type location: str - :param tags: Resource tags + :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 @@ -879,14 +1041,14 @@ class GenericResourceExpanded(GenericResource): :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 created_time: The created time of the resource. This is only present - if requested via the $expand query parameter. - :vartype created_time: datetime - :ivar changed_time: The changed time of the resource. This is only present - if requested via the $expand query parameter. - :vartype changed_time: datetime - :ivar provisioning_state: The provisioning state of the resource. This is - only present if requested via the $expand query parameter. + :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 + :ivar changed_time: The changed time of the resource. This is only present if requested via the + $expand query parameter. + :vartype changed_time: ~datetime.datetime + :ivar provisioning_state: The provisioning state of the resource. This is only present if + requested via the $expand query parameter. :vartype provisioning_state: str """ @@ -917,14 +1079,26 @@ class GenericResourceExpanded(GenericResource): 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, } - def __init__(self, *, location: str=None, tags=None, plan=None, properties=None, kind: str=None, managed_by: str=None, sku=None, identity=None, **kwargs) -> None: + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + plan: Optional["Plan"] = None, + properties: Optional[object] = None, + kind: Optional[str] = None, + managed_by: Optional[str] = None, + sku: Optional["Sku"] = None, + identity: Optional["Identity"] = None, + **kwargs + ): 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 self.provisioning_state = None -class GenericResourceFilter(Model): +class GenericResourceFilter(msrest.serialization.Model): """Resource filter. :param resource_type: The resource type. @@ -941,14 +1115,21 @@ class GenericResourceFilter(Model): 'tagvalue': {'key': 'tagvalue', 'type': 'str'}, } - def __init__(self, *, resource_type: str=None, tagname: str=None, tagvalue: str=None, **kwargs) -> None: + def __init__( + self, + *, + resource_type: Optional[str] = None, + tagname: Optional[str] = None, + tagvalue: Optional[str] = None, + **kwargs + ): super(GenericResourceFilter, self).__init__(**kwargs) self.resource_type = resource_type self.tagname = tagname self.tagvalue = tagvalue -class HttpMessage(Model): +class HttpMessage(msrest.serialization.Model): """HTTP message. :param content: HTTP message content. @@ -959,31 +1140,33 @@ class HttpMessage(Model): 'content': {'key': 'content', 'type': 'object'}, } - def __init__(self, *, content=None, **kwargs) -> None: + def __init__( + self, + *, + content: Optional[object] = None, + **kwargs + ): super(HttpMessage, self).__init__(**kwargs) self.content = content -class Identity(Model): +class Identity(msrest.serialization.Model): """Identity for the resource. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar principal_id: The principal ID of resource identity. :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :param 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 user identity dictionary key references will be ARM - resource ids in the form: + :param 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 + 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, - ~azure.mgmt.resource.resources.v2019_08_01.models.IdentityUserAssignedIdentitiesValue] + ~azure.mgmt.resource.resources.v2019_08_01.models.ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties] """ _validation = { @@ -994,11 +1177,17 @@ class Identity(Model): _attribute_map = { 'principal_id': {'key': 'principalId', 'type': 'str'}, 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'ResourceIdentityType'}, - 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{IdentityUserAssignedIdentitiesValue}'}, + 'type': {'key': 'type', 'type': 'str'}, + 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties}'}, } - def __init__(self, *, type=None, user_assigned_identities=None, **kwargs) -> None: + def __init__( + self, + *, + type: Optional[Union[str, "ResourceIdentityType"]] = None, + user_assigned_identities: Optional[Dict[str, "ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties"]] = None, + **kwargs + ): super(Identity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None @@ -1006,71 +1195,43 @@ def __init__(self, *, type=None, user_assigned_identities=None, **kwargs) -> Non self.user_assigned_identities = user_assigned_identities -class IdentityUserAssignedIdentitiesValue(Model): - """IdentityUserAssignedIdentitiesValue. - - Variables are only populated by the server, and will be ignored when - sending a request. - - :ivar principal_id: The principal id of user assigned identity. - :vartype principal_id: str - :ivar client_id: The client id of user assigned identity. - :vartype client_id: str - """ - - _validation = { - 'principal_id': {'readonly': True}, - 'client_id': {'readonly': True}, - } - - _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'client_id': {'key': 'clientId', 'type': 'str'}, - } - - def __init__(self, **kwargs) -> None: - super(IdentityUserAssignedIdentitiesValue, self).__init__(**kwargs) - self.principal_id = None - self.client_id = None - - -class OnErrorDeployment(Model): +class OnErrorDeployment(msrest.serialization.Model): """Deployment on error behavior. - :param 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 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 """ _attribute_map = { - 'type': {'key': 'type', 'type': 'OnErrorDeploymentType'}, + 'type': {'key': 'type', 'type': 'str'}, 'deployment_name': {'key': 'deploymentName', 'type': 'str'}, } - def __init__(self, *, type=None, deployment_name: str=None, **kwargs) -> None: + def __init__( + self, + *, + type: Optional[Union[str, "OnErrorDeploymentType"]] = None, + deployment_name: Optional[str] = None, + **kwargs + ): super(OnErrorDeployment, self).__init__(**kwargs) self.type = type self.deployment_name = deployment_name -class OnErrorDeploymentExtended(Model): +class OnErrorDeploymentExtended(msrest.serialization.Model): """Deployment on error behavior with additional details. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar provisioning_state: The state of the provisioning for the on error - deployment. + :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 SpecificDeployment. Possible values include: - 'LastSuccessful', 'SpecificDeployment' - :type type: str or - ~azure.mgmt.resource.resources.v2019_08_01.models.OnErrorDeploymentType + :param 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 """ @@ -1081,25 +1242,30 @@ class OnErrorDeploymentExtended(Model): _attribute_map = { 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'OnErrorDeploymentType'}, + 'type': {'key': 'type', 'type': 'str'}, 'deployment_name': {'key': 'deploymentName', 'type': 'str'}, } - def __init__(self, *, type=None, deployment_name: str=None, **kwargs) -> None: + def __init__( + self, + *, + type: Optional[Union[str, "OnErrorDeploymentType"]] = None, + deployment_name: Optional[str] = None, + **kwargs + ): super(OnErrorDeploymentExtended, self).__init__(**kwargs) self.provisioning_state = None self.type = type self.deployment_name = deployment_name -class Operation(Model): +class Operation(msrest.serialization.Model): """Microsoft.Resources operation. - :param name: Operation name: {provider}/{resource}/{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 + :type display: ~azure.mgmt.resource.resources.v2019_08_01.models.OperationDisplay """ _attribute_map = { @@ -1107,19 +1273,24 @@ class Operation(Model): 'display': {'key': 'display', 'type': 'OperationDisplay'}, } - def __init__(self, *, name: str=None, display=None, **kwargs) -> None: + def __init__( + self, + *, + name: Optional[str] = None, + display: Optional["OperationDisplay"] = None, + **kwargs + ): super(Operation, self).__init__(**kwargs) self.name = name self.display = display -class OperationDisplay(Model): +class OperationDisplay(msrest.serialization.Model): """The object that represents the operation. - :param provider: Service provider: Microsoft.Resources + :param provider: Service provider: Microsoft.Resources. :type provider: str - :param resource: Resource on which the operation is performed: Profile, - endpoint, etc. + :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 @@ -1134,7 +1305,15 @@ class OperationDisplay(Model): 'description': {'key': 'description', 'type': 'str'}, } - def __init__(self, *, provider: str=None, resource: str=None, operation: str=None, description: str=None, **kwargs) -> None: + def __init__( + self, + *, + provider: Optional[str] = None, + resource: Optional[str] = None, + operation: Optional[str] = None, + description: Optional[str] = None, + **kwargs + ): super(OperationDisplay, self).__init__(**kwargs) self.provider = provider self.resource = resource @@ -1142,15 +1321,40 @@ def __init__(self, *, provider: str=None, resource: str=None, operation: str=Non self.description = description -class ParametersLink(Model): +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 + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Operation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["Operation"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(OperationListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ParametersLink(msrest.serialization.Model): """Entity representing the reference to the deployment parameters. 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. + :param content_version: If included, must match the ContentVersion in the template. :type content_version: str """ @@ -1163,13 +1367,19 @@ class ParametersLink(Model): 'content_version': {'key': 'contentVersion', 'type': 'str'}, } - def __init__(self, *, uri: str, content_version: str=None, **kwargs) -> None: + def __init__( + self, + *, + uri: str, + content_version: Optional[str] = None, + **kwargs + ): super(ParametersLink, self).__init__(**kwargs) self.uri = uri self.content_version = content_version -class Plan(Model): +class Plan(msrest.serialization.Model): """Plan for the resource. :param name: The plan ID. @@ -1192,7 +1402,16 @@ class Plan(Model): 'version': {'key': 'version', 'type': 'str'}, } - def __init__(self, *, name: str=None, publisher: str=None, product: str=None, promotion_code: str=None, version: str=None, **kwargs) -> None: + def __init__( + self, + *, + name: Optional[str] = None, + publisher: Optional[str] = None, + product: Optional[str] = None, + promotion_code: Optional[str] = None, + version: Optional[str] = None, + **kwargs + ): super(Plan, self).__init__(**kwargs) self.name = name self.publisher = publisher @@ -1201,11 +1420,10 @@ def __init__(self, *, name: str=None, publisher: str=None, product: str=None, pr self.version = version -class Provider(Model): +class Provider(msrest.serialization.Model): """Resource provider information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The provider ID. :vartype id: str @@ -1213,8 +1431,7 @@ class Provider(Model): :type 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. + :ivar registration_policy: The registration policy of the resource provider. :vartype registration_policy: str :ivar resource_types: The collection of provider resource types. :vartype resource_types: @@ -1236,7 +1453,12 @@ class Provider(Model): 'resource_types': {'key': 'resourceTypes', 'type': '[ProviderResourceType]'}, } - def __init__(self, *, namespace: str=None, **kwargs) -> None: + def __init__( + self, + *, + namespace: Optional[str] = None, + **kwargs + ): super(Provider, self).__init__(**kwargs) self.id = None self.namespace = namespace @@ -1245,21 +1467,49 @@ def __init__(self, *, namespace: str=None, **kwargs) -> None: self.resource_types = None -class ProviderResourceType(Model): +class ProviderListResult(msrest.serialization.Model): + """List of resource providers. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Provider]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["Provider"]] = None, + **kwargs + ): + super(ProviderListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +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. + :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] + :type aliases: list[~azure.mgmt.resource.resources.v2019_08_01.models.AliasType] :param api_versions: The API version. :type api_versions: list[str] - :param capabilities: The additional capabilities offered by this resource - type. + :param capabilities: The additional capabilities offered by this resource type. :type capabilities: str :param properties: The properties. :type properties: dict[str, str] @@ -1274,7 +1524,17 @@ class ProviderResourceType(Model): 'properties': {'key': 'properties', 'type': '{str}'}, } - def __init__(self, *, resource_type: str=None, locations=None, aliases=None, api_versions=None, capabilities: str=None, properties=None, **kwargs) -> None: + def __init__( + self, + *, + resource_type: Optional[str] = None, + locations: Optional[List[str]] = None, + aliases: Optional[List["AliasType"]] = None, + api_versions: Optional[List[str]] = None, + capabilities: Optional[str] = None, + properties: Optional[Dict[str, str]] = None, + **kwargs + ): super(ProviderResourceType, self).__init__(**kwargs) self.resource_type = resource_type self.locations = locations @@ -1284,11 +1544,10 @@ def __init__(self, *, resource_type: str=None, locations=None, aliases=None, api self.properties = properties -class ResourceGroup(Model): +class ResourceGroup(msrest.serialization.Model): """Resource group information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. @@ -1299,16 +1558,13 @@ class ResourceGroup(Model): :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 resource group has been created. It must be one of - the supported Azure locations. + :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 + 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. + :param managed_by: The ID of the resource that manages this resource group. :type managed_by: str - :param tags: The tags attached to the resource group. + :param tags: A set of tags. The tags attached to the resource group. :type tags: dict[str, str] """ @@ -1329,7 +1585,15 @@ class ResourceGroup(Model): 'tags': {'key': 'tags', 'type': '{str}'}, } - def __init__(self, *, location: str, properties=None, managed_by: str=None, tags=None, **kwargs) -> None: + def __init__( + self, + *, + location: str, + properties: Optional["ResourceGroupProperties"] = None, + managed_by: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): super(ResourceGroup, self).__init__(**kwargs) self.id = None self.name = None @@ -1340,14 +1604,13 @@ def __init__(self, *, location: str, properties=None, managed_by: str=None, tags self.tags = tags -class ResourceGroupExportResult(Model): +class ResourceGroupExportResult(msrest.serialization.Model): """Resource group export result. :param template: The template content. :type template: object :param error: The template export error. - :type error: - ~azure.mgmt.resource.resources.v2019_08_01.models.ErrorResponse + :type error: ~azure.mgmt.resource.resources.v2019_08_01.models.ErrorResponse """ _attribute_map = { @@ -1355,13 +1618,19 @@ class ResourceGroupExportResult(Model): 'error': {'key': 'error', 'type': 'ErrorResponse'}, } - def __init__(self, *, template=None, error=None, **kwargs) -> None: + def __init__( + self, + *, + template: Optional[object] = None, + error: Optional["ErrorResponse"] = None, + **kwargs + ): super(ResourceGroupExportResult, self).__init__(**kwargs) self.template = template self.error = error -class ResourceGroupFilter(Model): +class ResourceGroupFilter(msrest.serialization.Model): """Resource group filter. :param tag_name: The tag name. @@ -1375,24 +1644,59 @@ class ResourceGroupFilter(Model): 'tag_value': {'key': 'tagValue', 'type': 'str'}, } - def __init__(self, *, tag_name: str=None, tag_value: str=None, **kwargs) -> None: + def __init__( + self, + *, + tag_name: Optional[str] = None, + tag_value: Optional[str] = None, + **kwargs + ): super(ResourceGroupFilter, self).__init__(**kwargs) self.tag_name = tag_name self.tag_value = tag_value -class ResourceGroupPatchable(Model): +class ResourceGroupListResult(msrest.serialization.Model): + """List of resource groups. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ResourceGroup]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["ResourceGroup"]] = None, + **kwargs + ): + super(ResourceGroupListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +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 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: The tags attached to the resource group. + :param tags: A set of tags. The tags attached to the resource group. :type tags: dict[str, str] """ @@ -1403,7 +1707,15 @@ class ResourceGroupPatchable(Model): 'tags': {'key': 'tags', 'type': '{str}'}, } - def __init__(self, *, name: str=None, properties=None, managed_by: str=None, tags=None, **kwargs) -> None: + def __init__( + self, + *, + name: Optional[str] = None, + properties: Optional["ResourceGroupProperties"] = None, + managed_by: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): super(ResourceGroupPatchable, self).__init__(**kwargs) self.name = name self.properties = properties @@ -1411,11 +1723,10 @@ def __init__(self, *, name: str=None, properties=None, managed_by: str=None, tag self.tags = tags -class ResourceGroupProperties(Model): +class ResourceGroupProperties(msrest.serialization.Model): """The resource group properties. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar provisioning_state: The provisioning state. :vartype provisioning_state: str @@ -1429,12 +1740,46 @@ class ResourceGroupProperties(Model): 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, } - def __init__(self, **kwargs) -> None: + def __init__( + self, + **kwargs + ): super(ResourceGroupProperties, self).__init__(**kwargs) self.provisioning_state = None -class ResourceProviderOperationDisplayProperties(Model): +class ResourceListResult(msrest.serialization.Model): + """List of resource groups. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[GenericResourceExpanded]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["GenericResourceExpanded"]] = None, + **kwargs + ): + super(ResourceListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class ResourceProviderOperationDisplayProperties(msrest.serialization.Model): """Resource provider operation's display properties. :param publisher: Operation description. @@ -1457,7 +1802,16 @@ class ResourceProviderOperationDisplayProperties(Model): 'description': {'key': 'description', 'type': 'str'}, } - def __init__(self, *, publisher: str=None, provider: str=None, resource: str=None, operation: str=None, description: str=None, **kwargs) -> None: + def __init__( + self, + *, + publisher: Optional[str] = None, + provider: Optional[str] = None, + resource: Optional[str] = None, + operation: Optional[str] = None, + description: Optional[str] = None, + **kwargs + ): super(ResourceProviderOperationDisplayProperties, self).__init__(**kwargs) self.publisher = publisher self.provider = provider @@ -1466,7 +1820,7 @@ def __init__(self, *, publisher: str=None, provider: str=None, resource: str=Non self.description = description -class ResourcesMoveInfo(Model): +class ResourcesMoveInfo(msrest.serialization.Model): """Parameters of move resources. :param resources: The IDs of the resources. @@ -1480,13 +1834,19 @@ class ResourcesMoveInfo(Model): 'target_resource_group': {'key': 'targetResourceGroup', 'type': 'str'}, } - def __init__(self, *, resources=None, target_resource_group: str=None, **kwargs) -> None: + def __init__( + self, + *, + resources: Optional[List[str]] = None, + target_resource_group: Optional[str] = None, + **kwargs + ): super(ResourcesMoveInfo, self).__init__(**kwargs) self.resources = resources self.target_resource_group = target_resource_group -class ScopedDeployment(Model): +class ScopedDeployment(msrest.serialization.Model): """Deployment operation parameters. All required parameters must be populated in order to send to Azure. @@ -1494,8 +1854,7 @@ class ScopedDeployment(Model): :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 + :type properties: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentProperties """ _validation = { @@ -1508,13 +1867,19 @@ class ScopedDeployment(Model): 'properties': {'key': 'properties', 'type': 'DeploymentProperties'}, } - def __init__(self, *, location: str, properties, **kwargs) -> None: + def __init__( + self, + *, + location: str, + properties: "DeploymentProperties", + **kwargs + ): super(ScopedDeployment, self).__init__(**kwargs) self.location = location self.properties = properties -class Sku(Model): +class Sku(msrest.serialization.Model): """SKU for the resource. :param name: The SKU name. @@ -1540,7 +1905,17 @@ class Sku(Model): 'capacity': {'key': 'capacity', 'type': 'int'}, } - def __init__(self, *, name: str=None, tier: str=None, size: str=None, family: str=None, model: str=None, capacity: int=None, **kwargs) -> None: + def __init__( + self, + *, + name: Optional[str] = None, + tier: Optional[str] = None, + size: Optional[str] = None, + family: Optional[str] = None, + model: Optional[str] = None, + capacity: Optional[int] = None, + **kwargs + ): super(Sku, self).__init__(**kwargs) self.name = name self.tier = tier @@ -1550,10 +1925,10 @@ def __init__(self, *, name: str=None, tier: str=None, size: str=None, family: st self.capacity = capacity -class SubResource(Model): +class SubResource(msrest.serialization.Model): """Sub-resource. - :param id: Resource ID + :param id: Resource ID. :type id: str """ @@ -1561,12 +1936,17 @@ class SubResource(Model): 'id': {'key': 'id', 'type': 'str'}, } - def __init__(self, *, id: str=None, **kwargs) -> None: + def __init__( + self, + *, + id: Optional[str] = None, + **kwargs + ): super(SubResource, self).__init__(**kwargs) self.id = id -class TagCount(Model): +class TagCount(msrest.serialization.Model): """Tag count. :param type: Type of count. @@ -1580,29 +1960,32 @@ class TagCount(Model): 'value': {'key': 'value', 'type': 'int'}, } - def __init__(self, *, type: str=None, value: int=None, **kwargs) -> None: + def __init__( + self, + *, + type: Optional[str] = None, + value: Optional[int] = None, + **kwargs + ): super(TagCount, self).__init__(**kwargs) self.type = type self.value = value -class TagDetails(Model): +class TagDetails(msrest.serialization.Model): """Tag details. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :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 created and has no associated resources, the value - is 0. + :param 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] + :type values: list[~azure.mgmt.resource.resources.v2019_08_01.models.TagValue] """ _validation = { @@ -1616,7 +1999,14 @@ class TagDetails(Model): 'values': {'key': 'values', 'type': '[TagValue]'}, } - def __init__(self, *, tag_name: str=None, count=None, values=None, **kwargs) -> None: + def __init__( + self, + *, + tag_name: Optional[str] = None, + count: Optional["TagCount"] = None, + values: Optional[List["TagValue"]] = None, + **kwargs + ): super(TagDetails, self).__init__(**kwargs) self.id = None self.tag_name = tag_name @@ -1624,11 +2014,41 @@ def __init__(self, *, tag_name: str=None, count=None, values=None, **kwargs) -> self.values = values -class TagValue(Model): +class TagsListResult(msrest.serialization.Model): + """List of subscription tags. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[TagDetails]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["TagDetails"]] = None, + **kwargs + ): + super(TagsListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class TagValue(msrest.serialization.Model): """Tag information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The tag ID. :vartype id: str @@ -1648,14 +2068,20 @@ class TagValue(Model): 'count': {'key': 'count', 'type': 'TagCount'}, } - def __init__(self, *, tag_value: str=None, count=None, **kwargs) -> None: + def __init__( + self, + *, + tag_value: Optional[str] = None, + count: Optional["TagCount"] = None, + **kwargs + ): super(TagValue, self).__init__(**kwargs) self.id = None self.tag_value = tag_value self.count = count -class TargetResource(Model): +class TargetResource(msrest.serialization.Model): """Target resource. :param id: The ID of the resource. @@ -1672,16 +2098,22 @@ class TargetResource(Model): 'resource_type': {'key': 'resourceType', 'type': 'str'}, } - def __init__(self, *, id: str=None, resource_name: str=None, resource_type: str=None, **kwargs) -> None: + def __init__( + self, + *, + id: Optional[str] = None, + resource_name: Optional[str] = None, + resource_type: Optional[str] = None, + **kwargs + ): super(TargetResource, self).__init__(**kwargs) self.id = id self.resource_name = resource_name self.resource_type = resource_type -class TemplateHashResult(Model): - """Result of the request to calculate template hash. It contains a string of - minified template and its hash. +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 @@ -1694,21 +2126,26 @@ class TemplateHashResult(Model): 'template_hash': {'key': 'templateHash', 'type': 'str'}, } - def __init__(self, *, minified_template: str=None, template_hash: str=None, **kwargs) -> None: + def __init__( + self, + *, + minified_template: Optional[str] = None, + template_hash: Optional[str] = None, + **kwargs + ): super(TemplateHashResult, self).__init__(**kwargs) self.minified_template = minified_template self.template_hash = template_hash -class TemplateLink(Model): +class TemplateLink(msrest.serialization.Model): """Entity representing the reference to the template. 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. + :param content_version: If included, must match the ContentVersion in the template. :type content_version: str """ @@ -1721,33 +2158,35 @@ class TemplateLink(Model): 'content_version': {'key': 'contentVersion', 'type': 'str'}, } - def __init__(self, *, uri: str, content_version: str=None, **kwargs) -> None: + def __init__( + self, + *, + uri: str, + content_version: Optional[str] = None, + **kwargs + ): super(TemplateLink, self).__init__(**kwargs) self.uri = uri self.content_version = content_version -class WhatIfChange(Model): +class WhatIfChange(msrest.serialization.Model): """Information about a single resource change predicted by What-If operation. All required parameters must be populated in order to send to Azure. - :param resource_id: Required. Resource ID + :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 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. + :param 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: object - :param after: The predicted snapshot of the resource after the deployment - is executed. + :param after: The predicted snapshot of the resource after the deployment is executed. :type after: object :param delta: The predicted changes to resource properties. - :type delta: - list[~azure.mgmt.resource.resources.v2019_08_01.models.WhatIfPropertyChange] + :type delta: list[~azure.mgmt.resource.resources.v2019_08_01.models.WhatIfPropertyChange] """ _validation = { @@ -1757,13 +2196,22 @@ class WhatIfChange(Model): _attribute_map = { 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'change_type': {'key': 'changeType', 'type': 'ChangeType'}, + 'change_type': {'key': 'changeType', 'type': 'str'}, 'before': {'key': 'before', 'type': 'object'}, 'after': {'key': 'after', 'type': 'object'}, 'delta': {'key': 'delta', 'type': '[WhatIfPropertyChange]'}, } - def __init__(self, *, resource_id: str, change_type, before=None, after=None, delta=None, **kwargs) -> None: + def __init__( + self, + *, + resource_id: str, + change_type: Union[str, "ChangeType"], + before: Optional[object] = None, + after: Optional[object] = None, + delta: Optional[List["WhatIfPropertyChange"]] = None, + **kwargs + ): super(WhatIfChange, self).__init__(**kwargs) self.resource_id = resource_id self.change_type = change_type @@ -1772,52 +2220,54 @@ def __init__(self, *, resource_id: str, change_type, before=None, after=None, de self.delta = delta -class WhatIfOperationResult(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. +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 changes: List of resource changes predicted by What-If operation. - :type changes: - list[~azure.mgmt.resource.resources.v2019_08_01.models.WhatIfChange] :param error: Error when What-If operation fails. - :type error: - ~azure.mgmt.resource.resources.v2019_08_01.models.ErrorResponse + :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] """ _attribute_map = { 'status': {'key': 'status', 'type': 'str'}, - 'changes': {'key': 'properties.changes', 'type': '[WhatIfChange]'}, 'error': {'key': 'error', 'type': 'ErrorResponse'}, + 'changes': {'key': 'properties.changes', 'type': '[WhatIfChange]'}, } - def __init__(self, *, status: str=None, changes=None, error=None, **kwargs) -> None: + def __init__( + self, + *, + status: Optional[str] = None, + error: Optional["ErrorResponse"] = None, + changes: Optional[List["WhatIfChange"]] = None, + **kwargs + ): super(WhatIfOperationResult, self).__init__(**kwargs) self.status = status - self.changes = changes self.error = error + self.changes = changes -class WhatIfPropertyChange(Model): +class WhatIfPropertyChange(msrest.serialization.Model): """The predicted change to the resource property. 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: 'Create', 'Delete', 'Modify', 'Array' + :param property_change_type: Required. The type of property change. Possible values include: + "Create", "Delete", "Modify", "Array". :type 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. + :param before: The value of the property before the deployment is executed. :type before: object :param after: The value of the property after the deployment is executed. :type after: object :param children: Nested property changes. - :type children: - list[~azure.mgmt.resource.resources.v2019_08_01.models.WhatIfPropertyChange] + :type children: list[~azure.mgmt.resource.resources.v2019_08_01.models.WhatIfPropertyChange] """ _validation = { @@ -1827,13 +2277,22 @@ class WhatIfPropertyChange(Model): _attribute_map = { 'path': {'key': 'path', 'type': 'str'}, - 'property_change_type': {'key': 'propertyChangeType', 'type': 'PropertyChangeType'}, + 'property_change_type': {'key': 'propertyChangeType', 'type': 'str'}, 'before': {'key': 'before', 'type': 'object'}, 'after': {'key': 'after', 'type': 'object'}, 'children': {'key': 'children', 'type': '[WhatIfPropertyChange]'}, } - def __init__(self, *, path: str, property_change_type, before=None, after=None, children=None, **kwargs) -> None: + def __init__( + self, + *, + path: str, + property_change_type: Union[str, "PropertyChangeType"], + before: Optional[object] = None, + after: Optional[object] = None, + children: Optional[List["WhatIfPropertyChange"]] = None, + **kwargs + ): super(WhatIfPropertyChange, self).__init__(**kwargs) self.path = path self.property_change_type = property_change_type diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/models/_paged_models.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/models/_paged_models.py deleted file mode 100644 index b254e60921b9..000000000000 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/models/_paged_models.py +++ /dev/null @@ -1,105 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.paging import Paged - - -class OperationPaged(Paged): - """ - A paging container for iterating over a list of :class:`Operation ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[Operation]'} - } - - def __init__(self, *args, **kwargs): - - super(OperationPaged, self).__init__(*args, **kwargs) -class DeploymentExtendedPaged(Paged): - """ - A paging container for iterating over a list of :class:`DeploymentExtended ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[DeploymentExtended]'} - } - - def __init__(self, *args, **kwargs): - - super(DeploymentExtendedPaged, self).__init__(*args, **kwargs) -class ProviderPaged(Paged): - """ - A paging container for iterating over a list of :class:`Provider ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[Provider]'} - } - - def __init__(self, *args, **kwargs): - - super(ProviderPaged, self).__init__(*args, **kwargs) -class GenericResourceExpandedPaged(Paged): - """ - A paging container for iterating over a list of :class:`GenericResourceExpanded ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[GenericResourceExpanded]'} - } - - def __init__(self, *args, **kwargs): - - super(GenericResourceExpandedPaged, self).__init__(*args, **kwargs) -class ResourceGroupPaged(Paged): - """ - A paging container for iterating over a list of :class:`ResourceGroup ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[ResourceGroup]'} - } - - def __init__(self, *args, **kwargs): - - super(ResourceGroupPaged, self).__init__(*args, **kwargs) -class TagDetailsPaged(Paged): - """ - A paging container for iterating over a list of :class:`TagDetails ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[TagDetails]'} - } - - def __init__(self, *args, **kwargs): - - super(TagDetailsPaged, self).__init__(*args, **kwargs) -class DeploymentOperationPaged(Paged): - """ - A paging container for iterating over a list of :class:`DeploymentOperation ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[DeploymentOperation]'} - } - - def __init__(self, *args, **kwargs): - - super(DeploymentOperationPaged, self).__init__(*args, **kwargs) 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 7306f86842bf..cb5967865b4f 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 @@ -1,56 +1,64 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from enum import Enum +class ChangeType(str, Enum): + """Type of change that will be made to the resource when the deployment is executed. + """ + + create = "Create" #: The resource does not exist in the current state but is present in the desired state. The resource will be created when the deployment is executed. + delete = "Delete" #: The resource exists in the current state and is missing from the desired state. The resource will be deleted when the deployment is executed. + ignore = "Ignore" #: The resource exists in the current state and is missing from the desired state. The resource will not be deployed or modified when the deployment is executed. + deploy = "Deploy" #: The resource exists in the current state and the desired state and will be redeployed when the deployment is executed. The properties of the resource may or may not change. + no_change = "NoChange" #: The resource exists in the current state and the desired state and will be redeployed when the deployment is executed. The properties of the resource will not change. + modify = "Modify" #: The resource exists in the current state and the desired state and will be redeployed when the deployment is executed. The properties of the resource will change. class DeploymentMode(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 + the resource group that are not included in the template are deleted. Be careful when using + Complete mode as you may unintentionally delete resources. + """ incremental = "Incremental" complete = "Complete" - class OnErrorDeploymentType(str, Enum): + """The deployment on error behavior type. Possible values are LastSuccessful and + SpecificDeployment. + """ last_successful = "LastSuccessful" specific_deployment = "SpecificDeployment" +class PropertyChangeType(str, Enum): + """The type of property change. + """ -class WhatIfResultFormat(str, Enum): - - resource_id_only = "ResourceIdOnly" - full_resource_payloads = "FullResourcePayloads" - + create = "Create" #: The property does not exist in the current state but is present in the desired state. The property will be created when the deployment is executed. + delete = "Delete" #: The property exists in the current state and is missing from the desired state. It will be deleted when the deployment is executed. + modify = "Modify" #: The property exists in both current and desired state and is different. The value of the property will change when the deployment is executed. + array = "Array" #: The property is an array and contains nested changes. class ResourceIdentityType(str, Enum): + """The identity type. + """ system_assigned = "SystemAssigned" user_assigned = "UserAssigned" system_assigned_user_assigned = "SystemAssigned, UserAssigned" none = "None" +class WhatIfResultFormat(str, Enum): + """The format of the What-If results + """ -class PropertyChangeType(str, Enum): - - create = "Create" #: The property does not exist in the current state but is present in the desired state. The property will be created when the deployment is executed. - delete = "Delete" #: The property exists in the current state and is missing from the desired state. It will be deleted when the deployment is executed. - modify = "Modify" #: The property exists in both current and desired state and is different. The value of the property will change when the deployment is executed. - array = "Array" #: The property is an array and contains nested changes. - - -class ChangeType(str, Enum): - - create = "Create" #: The resource does not exist in the current state but is present in the desired state. The resource will be created when the deployment is executed. - delete = "Delete" #: The resource exists in the current state and is missing from the desired state. The resource will be deleted when the deployment is executed. - ignore = "Ignore" #: The resource exists in the current state and is missing from the desired state. The resource will not be deployed or modified when the deployment is executed. - deploy = "Deploy" #: The resource exists in the current state and the desired state and will be redeployed when the deployment is executed. The properties of the resource may or may not change. - no_change = "NoChange" #: The resource exists in the current state and the desired state and will be redeployed when the deployment is executed. The properties of the resource will not change. - modify = "Modify" #: The resource exists in the current state and the desired state and will be redeployed when the deployment is executed. The properties of the resource will change. + resource_id_only = "ResourceIdOnly" + full_resource_payloads = "FullResourcePayloads" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/operations/__init__.py index 41027cf11028..a6f5fa20e792 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/operations/__init__.py @@ -1,12 +1,9 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from ._operations import Operations @@ -15,7 +12,7 @@ from ._resources_operations import ResourcesOperations from ._resource_groups_operations import ResourceGroupsOperations from ._tags_operations import TagsOperations -from ._deployment_operations import DeploymentOperations +from ._deployment_operations_operations import DeploymentOperationsOperations __all__ = [ 'Operations', @@ -24,5 +21,5 @@ 'ResourcesOperations', 'ResourceGroupsOperations', 'TagsOperations', - 'DeploymentOperations', + 'DeploymentOperationsOperations', ] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/operations/_deployment_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/operations/_deployment_operations.py deleted file mode 100644 index ef16f6d907e2..000000000000 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/operations/_deployment_operations.py +++ /dev/null @@ -1,729 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError - -from .. import models - - -class DeploymentOperations(object): - """DeploymentOperations operations. - - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. - - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for this operation. Constant value: "2019-08-01". - """ - - models = models - - def __init__(self, client, config, serializer, deserializer): - - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self.api_version = "2019-08-01" - - self.config = config - - def get_at_scope( - self, scope, deployment_name, operation_id, custom_headers=None, raw=False, **operation_config): - """Gets a deployments operation. - - :param scope: The scope of a deployment. - :type scope: str - :param deployment_name: The name of the deployment. - :type deployment_name: str - :param operation_id: The ID of the operation to get. - :type operation_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentOperation or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentOperation - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` - """ - # Construct URL - url = self.get_at_scope.metadata['url'] - 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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) - - if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentOperation', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - - return deserialized - get_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} - - def list_at_scope( - self, scope, deployment_name, top=None, custom_headers=None, raw=False, **operation_config): - """Gets all deployments operations for a deployment. - - :param scope: The scope of a deployment. - :type scope: str - :param deployment_name: The name of the deployment. - :type deployment_name: str - :param top: The number of results to return. - :type top: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of DeploymentOperation - :rtype: - ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentOperationPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentOperation] - :raises: :class:`CloudError` - """ - def prepare_request(next_link=None): - if not next_link: - # Construct URL - url = self.list_at_scope.metadata['url'] - 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 = {} - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - else: - url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) - return request - - def internal_paging(next_link=None): - request = prepare_request(next_link) - - response = self._client.send(request, stream=False, **operation_config) - - if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response - - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.DeploymentOperationPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} - - def get_at_tenant_scope( - self, deployment_name, operation_id, custom_headers=None, raw=False, **operation_config): - """Gets a deployments operation. - - :param deployment_name: The name of the deployment. - :type deployment_name: str - :param operation_id: The ID of the operation to get. - :type operation_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentOperation or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentOperation - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` - """ - # Construct URL - url = self.get_at_tenant_scope.metadata['url'] - 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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) - - if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentOperation', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - - return deserialized - get_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} - - def list_at_tenant_scope( - self, deployment_name, top=None, custom_headers=None, raw=False, **operation_config): - """Gets all deployments operations for a deployment. - - :param deployment_name: The name of the deployment. - :type deployment_name: str - :param top: The number of results to return. - :type top: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of DeploymentOperation - :rtype: - ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentOperationPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentOperation] - :raises: :class:`CloudError` - """ - def prepare_request(next_link=None): - if not next_link: - # Construct URL - url = self.list_at_tenant_scope.metadata['url'] - 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 = {} - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - else: - url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) - return request - - def internal_paging(next_link=None): - request = prepare_request(next_link) - - response = self._client.send(request, stream=False, **operation_config) - - if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response - - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.DeploymentOperationPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} - - def get_at_management_group_scope( - self, group_id, deployment_name, operation_id, custom_headers=None, raw=False, **operation_config): - """Gets a deployments operation. - - :param group_id: The management group ID. - :type group_id: str - :param deployment_name: The name of the deployment. - :type deployment_name: str - :param operation_id: The ID of the operation to get. - :type operation_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentOperation or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentOperation - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` - """ - # Construct URL - url = self.get_at_management_group_scope.metadata['url'] - 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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) - - if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentOperation', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - - return deserialized - get_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} - - def list_at_management_group_scope( - self, group_id, deployment_name, top=None, custom_headers=None, raw=False, **operation_config): - """Gets all deployments operations for a deployment. - - :param group_id: The management group ID. - :type group_id: str - :param deployment_name: The name of the deployment. - :type deployment_name: str - :param top: The number of results to return. - :type top: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of DeploymentOperation - :rtype: - ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentOperationPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentOperation] - :raises: :class:`CloudError` - """ - def prepare_request(next_link=None): - if not next_link: - # Construct URL - url = self.list_at_management_group_scope.metadata['url'] - 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 = {} - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - else: - url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) - return request - - def internal_paging(next_link=None): - request = prepare_request(next_link) - - response = self._client.send(request, stream=False, **operation_config) - - if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response - - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.DeploymentOperationPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} - - def get_at_subscription_scope( - self, deployment_name, operation_id, custom_headers=None, raw=False, **operation_config): - """Gets a deployments operation. - - :param deployment_name: The name of the deployment. - :type deployment_name: str - :param operation_id: The ID of the operation to get. - :type operation_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentOperation or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentOperation - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` - """ - # Construct URL - url = self.get_at_subscription_scope.metadata['url'] - 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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) - - if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentOperation', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - - return deserialized - get_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} - - def list_at_subscription_scope( - self, deployment_name, top=None, custom_headers=None, raw=False, **operation_config): - """Gets all deployments operations for a deployment. - - :param deployment_name: The name of the deployment. - :type deployment_name: str - :param top: The number of results to return. - :type top: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of DeploymentOperation - :rtype: - ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentOperationPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentOperation] - :raises: :class:`CloudError` - """ - def prepare_request(next_link=None): - if not next_link: - # Construct URL - url = self.list_at_subscription_scope.metadata['url'] - 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 = {} - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - else: - url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) - return request - - def internal_paging(next_link=None): - request = prepare_request(next_link) - - response = self._client.send(request, stream=False, **operation_config) - - if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response - - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.DeploymentOperationPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} - - def get( - self, resource_group_name, deployment_name, operation_id, custom_headers=None, raw=False, **operation_config): - """Gets a deployments operation. - - :param resource_group_name: The name of the resource group. The name - is case insensitive. - :type resource_group_name: str - :param deployment_name: The name of the deployment. - :type deployment_name: str - :param operation_id: The ID of the operation to get. - :type operation_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentOperation or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentOperation - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` - """ - # Construct URL - url = self.get.metadata['url'] - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, 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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) - - if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentOperation', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}'} - - def list( - self, resource_group_name, deployment_name, top=None, custom_headers=None, raw=False, **operation_config): - """Gets all deployments operations for a deployment. - - :param resource_group_name: The name of the resource group. The name - is case insensitive. - :type resource_group_name: str - :param deployment_name: The name of the deployment. - :type deployment_name: str - :param top: The number of results to return. - :type top: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of DeploymentOperation - :rtype: - ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentOperationPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentOperation] - :raises: :class:`CloudError` - """ - def prepare_request(next_link=None): - if not next_link: - # Construct URL - url = self.list.metadata['url'] - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - else: - url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) - return request - - def internal_paging(next_link=None): - request = prepare_request(next_link) - - response = self._client.send(request, stream=False, **operation_config) - - if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response - - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.DeploymentOperationPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations'} 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 new file mode 100644 index 000000000000..6cee7d2ba42f --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/operations/_deployment_operations_operations.py @@ -0,0 +1,714 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class DeploymentOperationsOperations(object): + """DeploymentOperationsOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2019_08_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def get_at_scope( + self, + scope, # type: str + deployment_name, # type: str + operation_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentOperation" + """Gets a deployments operation. + + :param scope: The scope of a deployment. + :type scope: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param operation_id: The ID of the operation to get. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentOperation or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentOperation + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentOperation"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + + # 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'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentOperation', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + def list_at_scope( + self, + scope, # type: str + deployment_name, # type: str + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.DeploymentOperationsListResult"] + """Gets all deployments operations for a deployment. + + :param scope: The scope of a deployment. + :type scope: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentOperationsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} # type: ignore + + def get_at_tenant_scope( + self, + deployment_name, # type: str + operation_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentOperation" + """Gets a deployments operation. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param operation_id: The ID of the operation to get. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentOperation or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentOperation + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentOperation"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + + # 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'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentOperation', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + def list_at_tenant_scope( + self, + deployment_name, # type: str + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.DeploymentOperationsListResult"] + """Gets all deployments operations for a deployment. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentOperationsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} # type: ignore + + def get_at_management_group_scope( + self, + group_id, # type: str + deployment_name, # type: str + operation_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentOperation" + """Gets a deployments operation. + + :param group_id: The management group ID. + :type group_id: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param operation_id: The ID of the operation to get. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentOperation or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentOperation + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentOperation"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + + # 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'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentOperation', pipeline_response) + + if cls: + 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 + + def list_at_management_group_scope( + self, + group_id, # type: str + deployment_name, # type: str + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.DeploymentOperationsListResult"] + """Gets all deployments operations for a deployment. + + :param group_id: The management group ID. + :type group_id: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentOperationsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + 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 + + def get_at_subscription_scope( + self, + deployment_name, # type: str + operation_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentOperation" + """Gets a deployments operation. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param operation_id: The ID of the operation to get. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentOperation or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentOperation + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentOperation"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + + # 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'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentOperation', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + def list_at_subscription_scope( + self, + deployment_name, # type: str + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.DeploymentOperationsListResult"] + """Gets all deployments operations for a deployment. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentOperationsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + 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 + + def get( + self, + resource_group_name, # type: str + deployment_name, # type: str + operation_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentOperation" + """Gets a deployments operation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param operation_id: The ID of the operation to get. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentOperation or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentOperation + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentOperation"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + + # Construct URL + url = self.get.metadata['url'] # type: 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'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentOperation', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + def list( + self, + resource_group_name, # type: str + deployment_name, # type: str + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.DeploymentOperationsListResult"] + """Gets all deployments operations for a deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentOperationsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations'} # type: ignore 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 d10519d69f0f..8599a6450a66 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 @@ -1,1391 +1,1382 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError -from msrest.polling import LROPoller, NoPolling -from msrestazure.polling.arm_polling import ARMPolling +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class DeploymentsOperations(object): """DeploymentsOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2019_08_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for this operation. Constant value: "2019-08-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-08-01" - - self.config = config - + self._config = config def _delete_at_scope_initial( - self, scope, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + scope, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + # Construct URL - url = self.delete_at_scope.metadata['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\._\(\)]+$') + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [202, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - - def delete_at_scope( - self, scope, deployment_name, custom_headers=None, raw=False, polling=True, **operation_config): - """Deletes a deployment from the deployment history. - - A template deployment that is currently running cannot be deleted. - Deleting a template deployment removes the associated deployment - operations. This is an asynchronous operation that returns a status of - 202 until the template deployment is successfully deleted. The Location - response header contains the URI that is used to obtain the status of - the process. While the process is running, a call to the URI in the - Location header returns a status of 202. When the process finishes, the - URI in the Location header returns a status of 204 on success. If the - asynchronous request failed, the URI in the Location header returns an - error-level status code. + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_at_scope_initial.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + def begin_delete_at_scope( + self, + scope, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """A template deployment that is currently running cannot be deleted. Deleting a template deployment removes the associated deployment operations. This is an asynchronous operation that returns a status of 202 until the template deployment is successfully deleted. The Location response header contains the URI that is used to obtain the status of the process. While the process is running, a call to the URI in the Location header returns a status of 202. When the process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. + + Deletes a deployment from the deployment history. :param scope: The scope of a deployment. :type scope: str :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns None or - ClientRawResponse if raw==True - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._delete_at_scope_initial( scope=scope, deployment_name=deployment_name, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - delete_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} + begin_delete_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore def check_existence_at_scope( - self, scope, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + scope, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Checks whether the deployment exists. :param scope: The scope of a deployment. :type scope: str :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: bool or ClientRawResponse if raw=true - :rtype: bool or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + # Construct URL - url = self.check_existence_at_scope.metadata['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\._\(\)]+$') + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204, 404]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = (response.status_code == 204) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - return deserialized - check_existence_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + 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, deployment_name, properties, location=None, custom_headers=None, raw=False, **operation_config): - parameters = models.Deployment(location=location, properties=properties) + self, + scope, # type: str + deployment_name, # type: str + properties, # type: "models.DeploymentProperties" + location=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentExtended" + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.Deployment(location=location, properties=properties) + api_version = "2019-08-01" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.create_or_update_at_scope.metadata['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\._\(\)]+$') + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'Deployment') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 201]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', response) + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', response) + deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_at_scope_initial.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore - def create_or_update_at_scope( - self, scope, deployment_name, properties, location=None, custom_headers=None, raw=False, polling=True, **operation_config): - """Deploys resources at a given scope. + def begin_create_or_update_at_scope( + self, + scope, # type: str + deployment_name, # type: str + properties, # type: "models.DeploymentProperties" + location=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """You can provide the template and parameters directly in the request or link to JSON files. - You can provide the template and parameters directly in the request or - link to JSON files. + Deploys resources at a given scope. :param scope: The scope of a deployment. :type scope: str :param deployment_name: The name of the deployment. :type deployment_name: str :param properties: The deployment properties. - :type properties: - ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentProperties + :type properties: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentProperties :param location: The location to store the deployment data. :type location: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns DeploymentExtended or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 DeploymentExtended + :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] + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._create_or_update_at_scope_initial( scope=scope, deployment_name=deployment_name, properties=properties, location=location, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - deserialized = self._deserialize('DeploymentExtended', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - create_or_update_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} + begin_create_or_update_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore def get_at_scope( - self, scope, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + scope, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentExtended" """Gets a deployment. :param scope: The scope of a deployment. :type scope: str :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentExtended or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExtended or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + # Construct URL - url = self.get_at_scope.metadata['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\._\(\)]+$') + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', response) + deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} + get_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore def cancel_at_scope( - self, scope, deployment_name, custom_headers=None, raw=False, **operation_config): - """Cancels a currently running template deployment. + self, + scope, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """You can cancel a deployment only if the provisioningState is Accepted or Running. After the deployment is canceled, the provisioningState is set to Canceled. Canceling a template deployment stops the currently running template deployment and leaves the resources partially deployed. - You can cancel a deployment only if the provisioningState is Accepted - or Running. After the deployment is canceled, the provisioningState is - set to Canceled. Canceling a template deployment stops the currently - running template deployment and leaves the resources partially - deployed. + Cancels a currently running template deployment. :param scope: The scope of a deployment. :type scope: str :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + # Construct URL - url = self.cancel_at_scope.metadata['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\._\(\)]+$') + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - cancel_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} + cancel_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore def validate_at_scope( - self, scope, deployment_name, properties, location=None, custom_headers=None, raw=False, **operation_config): - """Validates whether the specified template is syntactically correct and - will be accepted by Azure Resource Manager.. + self, + scope, # type: str + deployment_name, # type: str + properties, # type: "models.DeploymentProperties" + location=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentValidateResult" + """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. :param scope: The scope of a deployment. :type scope: str :param deployment_name: The name of the deployment. :type deployment_name: str :param properties: The deployment properties. - :type properties: - ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentProperties + :type properties: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentProperties :param location: The location to store the deployment data. :type location: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentValidateResult or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentValidateResult - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentValidateResult + :raises: ~azure.core.exceptions.HttpResponseError """ - parameters = models.Deployment(location=location, properties=properties) + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentValidateResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.Deployment(location=location, properties=properties) + api_version = "2019-08-01" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.validate_at_scope.metadata['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\._\(\)]+$') + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'Deployment') # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 400]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', response) + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', response) + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - validate_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} + validate_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore def export_template_at_scope( - self, scope, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + scope, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentExportResult" """Exports the template used for specified deployment. :param scope: The scope of a deployment. :type scope: str :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentExportResult or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExportResult - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExportResult + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExportResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + # Construct URL - url = self.export_template_at_scope.metadata['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\._\(\)]+$') + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentExportResult', response) + deserialized = self._deserialize('DeploymentExportResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - export_template_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} + export_template_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore def list_at_scope( - self, scope, filter=None, top=None, custom_headers=None, raw=False, **operation_config): + self, + scope, # type: str + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.DeploymentListResult"] """Get all the deployments at the given scope. :param scope: The scope of a deployment. :type scope: str - :param filter: The filter to apply on the operation. For example, you - can use $filter=provisioningState eq '{state}'. + :param filter: The filter to apply on the operation. For example, you can use + $filter=provisioningState eq '{state}'. :type filter: str - :param top: The number of results to get. If null is passed, returns - all deployments. + :param top: The number of results to get. If null is passed, returns all deployments. :type top: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of DeploymentExtended - :rtype: - ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtendedPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_at_scope.metadata['url'] + url = self.list_at_scope.metadata['url'] # type: ignore path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str') + 'scope': self._serialize.url("scope", scope, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.DeploymentExtendedPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/'} + return pipeline_response + return ItemPaged( + get_next, extract_data + ) + list_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/'} # type: ignore def _delete_at_tenant_scope_initial( - self, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + # Construct URL - url = self.delete_at_tenant_scope.metadata['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\._\(\)]+$') + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [202, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - - def delete_at_tenant_scope( - self, deployment_name, custom_headers=None, raw=False, polling=True, **operation_config): - """Deletes a deployment from the deployment history. - - A template deployment that is currently running cannot be deleted. - Deleting a template deployment removes the associated deployment - operations. This is an asynchronous operation that returns a status of - 202 until the template deployment is successfully deleted. The Location - response header contains the URI that is used to obtain the status of - the process. While the process is running, a call to the URI in the - Location header returns a status of 202. When the process finishes, the - URI in the Location header returns a status of 204 on success. If the - asynchronous request failed, the URI in the Location header returns an - error-level status code. + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_at_tenant_scope_initial.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + def begin_delete_at_tenant_scope( + self, + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """A template deployment that is currently running cannot be deleted. Deleting a template deployment removes the associated deployment operations. This is an asynchronous operation that returns a status of 202 until the template deployment is successfully deleted. The Location response header contains the URI that is used to obtain the status of the process. While the process is running, a call to the URI in the Location header returns a status of 202. When the process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. + + Deletes a deployment from the deployment history. :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns None or - ClientRawResponse if raw==True - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._delete_at_tenant_scope_initial( deployment_name=deployment_name, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - delete_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} + begin_delete_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore def check_existence_at_tenant_scope( - self, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Checks whether the deployment exists. :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: bool or ClientRawResponse if raw=true - :rtype: bool or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + # Construct URL - url = self.check_existence_at_tenant_scope.metadata['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\._\(\)]+$') + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204, 404]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = (response.status_code == 204) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - return deserialized - check_existence_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + 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, location, properties, custom_headers=None, raw=False, **operation_config): - parameters = models.ScopedDeployment(location=location, properties=properties) + self, + deployment_name, # type: str + location, # type: str + properties, # type: "models.DeploymentProperties" + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentExtended" + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.ScopedDeployment(location=location, properties=properties) + api_version = "2019-08-01" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.create_or_update_at_tenant_scope.metadata['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\._\(\)]+$') + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'ScopedDeployment') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 201]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', response) + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', response) + deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_at_tenant_scope_initial.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore - def create_or_update_at_tenant_scope( - self, deployment_name, location, properties, custom_headers=None, raw=False, polling=True, **operation_config): - """Deploys resources at tenant scope. + def begin_create_or_update_at_tenant_scope( + self, + deployment_name, # type: str + location, # type: str + properties, # type: "models.DeploymentProperties" + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """You can provide the template and parameters directly in the request or link to JSON files. - You can provide the template and parameters directly in the request or - link to JSON files. + Deploys resources at tenant scope. :param deployment_name: The name of the deployment. :type deployment_name: str :param location: The location to store the deployment data. :type location: str :param properties: The deployment properties. - :type properties: - ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentProperties - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :type properties: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentProperties + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns DeploymentExtended or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 DeploymentExtended + :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] + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._create_or_update_at_tenant_scope_initial( deployment_name=deployment_name, location=location, properties=properties, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - deserialized = self._deserialize('DeploymentExtended', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - create_or_update_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} + begin_create_or_update_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore def get_at_tenant_scope( - self, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentExtended" """Gets a deployment. :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentExtended or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExtended or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + # Construct URL - url = self.get_at_tenant_scope.metadata['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\._\(\)]+$') + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', response) + deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} + get_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore def cancel_at_tenant_scope( - self, deployment_name, custom_headers=None, raw=False, **operation_config): - """Cancels a currently running template deployment. + self, + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """You can cancel a deployment only if the provisioningState is Accepted or Running. After the deployment is canceled, the provisioningState is set to Canceled. Canceling a template deployment stops the currently running template deployment and leaves the resources partially deployed. - You can cancel a deployment only if the provisioningState is Accepted - or Running. After the deployment is canceled, the provisioningState is - set to Canceled. Canceling a template deployment stops the currently - running template deployment and leaves the resources partially - deployed. + Cancels a currently running template deployment. :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + # Construct URL - url = self.cancel_at_tenant_scope.metadata['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\._\(\)]+$') + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - cancel_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} + cancel_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore def validate_at_tenant_scope( - self, deployment_name, location, properties, custom_headers=None, raw=False, **operation_config): - """Validates whether the specified template is syntactically correct and - will be accepted by Azure Resource Manager.. + self, + deployment_name, # type: str + location, # type: str + properties, # type: "models.DeploymentProperties" + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentValidateResult" + """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. :param deployment_name: The name of the deployment. :type deployment_name: str :param location: The location to store the deployment data. :type location: str :param properties: The deployment properties. - :type properties: - ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentProperties - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentValidateResult or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentValidateResult - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :type properties: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentProperties + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentValidateResult + :raises: ~azure.core.exceptions.HttpResponseError """ - parameters = models.ScopedDeployment(location=location, properties=properties) + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentValidateResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.ScopedDeployment(location=location, properties=properties) + api_version = "2019-08-01" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.validate_at_tenant_scope.metadata['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\._\(\)]+$') + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'ScopedDeployment') # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 400]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', response) + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', response) + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - validate_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} + validate_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore def export_template_at_tenant_scope( - self, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentExportResult" """Exports the template used for specified deployment. :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentExportResult or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExportResult - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExportResult + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExportResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + # Construct URL - url = self.export_template_at_tenant_scope.metadata['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\._\(\)]+$') + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentExportResult', response) + deserialized = self._deserialize('DeploymentExportResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - export_template_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} + export_template_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore def list_at_tenant_scope( - self, filter=None, top=None, custom_headers=None, raw=False, **operation_config): + self, + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.DeploymentListResult"] """Get all the deployments at the tenant scope. - :param filter: The filter to apply on the operation. For example, you - can use $filter=provisioningState eq '{state}'. + :param filter: The filter to apply on the operation. For example, you can use + $filter=provisioningState eq '{state}'. :type filter: str - :param top: The number of results to get. If null is passed, returns - all deployments. + :param top: The number of results to get. If null is passed, returns all deployments. :type top: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of DeploymentExtended - :rtype: - ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtendedPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_at_tenant_scope.metadata['url'] - + url = self.list_at_tenant_scope.metadata['url'] # type: ignore # Construct parameters - query_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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.DeploymentExtendedPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/'} + return pipeline_response + return ItemPaged( + get_next, extract_data + ) + list_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/'} # type: ignore def _delete_at_management_group_scope_initial( - self, group_id, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + # Construct URL - url = self.delete_at_management_group_scope.metadata['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\._\(\)]+$') + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [202, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - - def delete_at_management_group_scope( - self, group_id, deployment_name, custom_headers=None, raw=False, polling=True, **operation_config): - """Deletes a deployment from the deployment history. - - A template deployment that is currently running cannot be deleted. - Deleting a template deployment removes the associated deployment - operations. This is an asynchronous operation that returns a status of - 202 until the template deployment is successfully deleted. The Location - response header contains the URI that is used to obtain the status of - the process. While the process is running, a call to the URI in the - Location header returns a status of 202. When the process finishes, the - URI in the Location header returns a status of 204 on success. If the - asynchronous request failed, the URI in the Location header returns an - error-level status code. + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_at_management_group_scope_initial.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + def begin_delete_at_management_group_scope( + self, + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """A template deployment that is currently running cannot be deleted. Deleting a template deployment removes the associated deployment operations. This is an asynchronous operation that returns a status of 202 until the template deployment is successfully deleted. The Location response header contains the URI that is used to obtain the status of the process. While the process is running, a call to the URI in the Location header returns a status of 202. When the process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. + + Deletes a deployment from the deployment history. :param group_id: The management group ID. :type group_id: str :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns None or - ClientRawResponse if raw==True - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._delete_at_management_group_scope_initial( group_id=group_id, deployment_name=deployment_name, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - delete_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} + begin_delete_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore def check_existence_at_management_group_scope( - self, group_id, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Checks whether the deployment exists. :param group_id: The management group ID. :type group_id: str :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: bool or ClientRawResponse if raw=true - :rtype: bool or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + # Construct URL - url = self.check_existence_at_management_group_scope.metadata['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\._\(\)]+$') + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204, 404]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = (response.status_code == 204) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - return deserialized - check_existence_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + 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, deployment_name, location, properties, custom_headers=None, raw=False, **operation_config): - parameters = models.ScopedDeployment(location=location, properties=properties) + self, + group_id, # type: str + deployment_name, # type: str + location, # type: str + properties, # type: "models.DeploymentProperties" + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentExtended" + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.ScopedDeployment(location=location, properties=properties) + api_version = "2019-08-01" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.create_or_update_at_management_group_scope.metadata['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\._\(\)]+$') + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'ScopedDeployment') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 201]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', response) + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', response) + deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + 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 - def create_or_update_at_management_group_scope( - self, group_id, deployment_name, location, properties, custom_headers=None, raw=False, polling=True, **operation_config): - """Deploys resources at management group scope. + def begin_create_or_update_at_management_group_scope( + self, + group_id, # type: str + deployment_name, # type: str + location, # type: str + properties, # type: "models.DeploymentProperties" + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """You can provide the template and parameters directly in the request or link to JSON files. - You can provide the template and parameters directly in the request or - link to JSON files. + Deploys resources at management group scope. :param group_id: The management group ID. :type group_id: str @@ -1394,172 +1385,164 @@ def create_or_update_at_management_group_scope( :param location: The location to store the deployment data. :type location: str :param properties: The deployment properties. - :type properties: - ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentProperties - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :type properties: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentProperties + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns DeploymentExtended or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 DeploymentExtended + :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] + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._create_or_update_at_management_group_scope_initial( group_id=group_id, deployment_name=deployment_name, location=location, properties=properties, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - deserialized = self._deserialize('DeploymentExtended', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - create_or_update_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} + begin_create_or_update_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore def get_at_management_group_scope( - self, group_id, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentExtended" """Gets a deployment. :param group_id: The management group ID. :type group_id: str :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentExtended or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExtended or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + # Construct URL - url = self.get_at_management_group_scope.metadata['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\._\(\)]+$') + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', response) + deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} + get_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore def cancel_at_management_group_scope( - self, group_id, deployment_name, custom_headers=None, raw=False, **operation_config): - """Cancels a currently running template deployment. + self, + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """You can cancel a deployment only if the provisioningState is Accepted or Running. After the deployment is canceled, the provisioningState is set to Canceled. Canceling a template deployment stops the currently running template deployment and leaves the resources partially deployed. - You can cancel a deployment only if the provisioningState is Accepted - or Running. After the deployment is canceled, the provisioningState is - set to Canceled. Canceling a template deployment stops the currently - running template deployment and leaves the resources partially - deployed. + Cancels a currently running template deployment. :param group_id: The management group ID. :type group_id: str :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + # Construct URL - url = self.cancel_at_management_group_scope.metadata['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\._\(\)]+$') + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - cancel_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} + 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( - self, group_id, deployment_name, location, properties, custom_headers=None, raw=False, **operation_config): - """Validates whether the specified template is syntactically correct and - will be accepted by Azure Resource Manager.. + self, + group_id, # type: str + deployment_name, # type: str + location, # type: str + properties, # type: "models.DeploymentProperties" + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentValidateResult" + """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. :param group_id: The management group ID. :type group_id: str @@ -1568,1667 +1551,1621 @@ def validate_at_management_group_scope( :param location: The location to store the deployment data. :type location: str :param properties: The deployment properties. - :type properties: - ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentProperties - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentValidateResult or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentValidateResult - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :type properties: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentProperties + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentValidateResult + :raises: ~azure.core.exceptions.HttpResponseError """ - parameters = models.ScopedDeployment(location=location, properties=properties) + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentValidateResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.ScopedDeployment(location=location, properties=properties) + api_version = "2019-08-01" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.validate_at_management_group_scope.metadata['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\._\(\)]+$') + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'ScopedDeployment') # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 400]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', response) + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', response) + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + 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'} + validate_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore def export_template_at_management_group_scope( - self, group_id, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentExportResult" """Exports the template used for specified deployment. :param group_id: The management group ID. :type group_id: str :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentExportResult or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExportResult - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExportResult + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExportResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + # Construct URL - url = self.export_template_at_management_group_scope.metadata['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\._\(\)]+$') + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentExportResult', response) + deserialized = self._deserialize('DeploymentExportResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + 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'} + export_template_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore def list_at_management_group_scope( - self, group_id, filter=None, top=None, custom_headers=None, raw=False, **operation_config): + self, + group_id, # type: str + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.DeploymentListResult"] """Get all the deployments for a management group. :param group_id: The management group ID. :type group_id: str - :param filter: The filter to apply on the operation. For example, you - can use $filter=provisioningState eq '{state}'. + :param filter: The filter to apply on the operation. For example, you can use + $filter=provisioningState eq '{state}'. :type filter: str - :param top: The number of results to get. If null is passed, returns - all deployments. + :param top: The number of results to get. If null is passed, returns all deployments. :type top: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of DeploymentExtended - :rtype: - ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtendedPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_at_management_group_scope.metadata['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) + '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 = {} + 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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return response - - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.DeploymentExtendedPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/'} + 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/'} # type: ignore def _delete_at_subscription_scope_initial( - self, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + # Construct URL - url = self.delete_at_subscription_scope.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [202, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - - def delete_at_subscription_scope( - self, deployment_name, custom_headers=None, raw=False, polling=True, **operation_config): - """Deletes a deployment from the deployment history. - - A template deployment that is currently running cannot be deleted. - Deleting a template deployment removes the associated deployment - operations. This is an asynchronous operation that returns a status of - 202 until the template deployment is successfully deleted. The Location - response header contains the URI that is used to obtain the status of - the process. While the process is running, a call to the URI in the - Location header returns a status of 202. When the process finishes, the - URI in the Location header returns a status of 204 on success. If the - asynchronous request failed, the URI in the Location header returns an - error-level status code. + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + def begin_delete_at_subscription_scope( + self, + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """A template deployment that is currently running cannot be deleted. Deleting a template deployment removes the associated deployment operations. This is an asynchronous operation that returns a status of 202 until the template deployment is successfully deleted. The Location response header contains the URI that is used to obtain the status of the process. While the process is running, a call to the URI in the Location header returns a status of 202. When the process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. + + Deletes a deployment from the deployment history. :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns None or - ClientRawResponse if raw==True - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._delete_at_subscription_scope_initial( deployment_name=deployment_name, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - delete_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} + begin_delete_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore def check_existence_at_subscription_scope( - self, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Checks whether the deployment exists. :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: bool or ClientRawResponse if raw=true - :rtype: bool or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + # Construct URL - url = self.check_existence_at_subscription_scope.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204, 404]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = (response.status_code == 204) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - return deserialized - check_existence_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + if cls: + return cls(pipeline_response, None, {}) + + 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, properties, location=None, custom_headers=None, raw=False, **operation_config): - parameters = models.Deployment(location=location, properties=properties) + self, + deployment_name, # type: str + properties, # type: "models.DeploymentProperties" + location=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentExtended" + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.Deployment(location=location, properties=properties) + api_version = "2019-08-01" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.create_or_update_at_subscription_scope.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'Deployment') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 201]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', response) + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', response) + deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + 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 - def create_or_update_at_subscription_scope( - self, deployment_name, properties, location=None, custom_headers=None, raw=False, polling=True, **operation_config): - """Deploys resources at subscription scope. + def begin_create_or_update_at_subscription_scope( + self, + deployment_name, # type: str + properties, # type: "models.DeploymentProperties" + location=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """You can provide the template and parameters directly in the request or link to JSON files. - You can provide the template and parameters directly in the request or - link to JSON files. + Deploys resources at subscription scope. :param deployment_name: The name of the deployment. :type deployment_name: str :param properties: The deployment properties. - :type properties: - ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentProperties + :type properties: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentProperties :param location: The location to store the deployment data. :type location: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns DeploymentExtended or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 DeploymentExtended + :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] + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._create_or_update_at_subscription_scope_initial( deployment_name=deployment_name, properties=properties, location=location, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - deserialized = self._deserialize('DeploymentExtended', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - create_or_update_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} + begin_create_or_update_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore def get_at_subscription_scope( - self, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentExtended" """Gets a deployment. :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentExtended or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExtended or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + # Construct URL - url = self.get_at_subscription_scope.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', response) + deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} + get_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore def cancel_at_subscription_scope( - self, deployment_name, custom_headers=None, raw=False, **operation_config): - """Cancels a currently running template deployment. + self, + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """You can cancel a deployment only if the provisioningState is Accepted or Running. After the deployment is canceled, the provisioningState is set to Canceled. Canceling a template deployment stops the currently running template deployment and leaves the resources partially deployed. - You can cancel a deployment only if the provisioningState is Accepted - or Running. After the deployment is canceled, the provisioningState is - set to Canceled. Canceling a template deployment stops the currently - running template deployment and leaves the resources partially - deployed. + Cancels a currently running template deployment. :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + # Construct URL - url = self.cancel_at_subscription_scope.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - cancel_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} + cancel_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore def validate_at_subscription_scope( - self, deployment_name, properties, location=None, custom_headers=None, raw=False, **operation_config): - """Validates whether the specified template is syntactically correct and - will be accepted by Azure Resource Manager.. + self, + deployment_name, # type: str + properties, # type: "models.DeploymentProperties" + location=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentValidateResult" + """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. :param deployment_name: The name of the deployment. :type deployment_name: str :param properties: The deployment properties. - :type properties: - ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentProperties + :type properties: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentProperties :param location: The location to store the deployment data. :type location: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentValidateResult or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentValidateResult - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentValidateResult + :raises: ~azure.core.exceptions.HttpResponseError """ - parameters = models.Deployment(location=location, properties=properties) + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentValidateResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.Deployment(location=location, properties=properties) + api_version = "2019-08-01" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.validate_at_subscription_scope.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'Deployment') # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 400]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', response) + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', response) + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - validate_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} - + 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, properties, location=None, custom_headers=None, raw=False, **operation_config): - parameters = models.DeploymentWhatIf(location=location, properties=properties) + self, + deployment_name, # type: str + properties, # type: "models.DeploymentWhatIfProperties" + location=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.WhatIfOperationResult" + cls = kwargs.pop('cls', None) # type: ClsType["models.WhatIfOperationResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.DeploymentWhatIf(location=location, properties=properties) + api_version = "2019-08-01" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.what_if_at_subscription_scope.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'DeploymentWhatIf') # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 202]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} deserialized = None - header_dict = {} - if response.status_code == 200: - deserialized = self._deserialize('WhatIfOperationResult', response) - header_dict = { - 'Location': 'str', - 'Retry-After': 'str', - } + deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_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')) - return deserialized + if cls: + return cls(pipeline_response, deserialized, response_headers) - def what_if_at_subscription_scope( - self, deployment_name, properties, location=None, custom_headers=None, raw=False, polling=True, **operation_config): - """Returns changes that will be made by the deployment if executed at the - scope of the subscription. + return deserialized + _what_if_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + + def begin_what_if_at_subscription_scope( + self, + deployment_name, # type: str + properties, # type: "models.DeploymentWhatIfProperties" + location=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """Returns changes that will be made by the deployment if executed at the scope of the subscription. :param deployment_name: The name of the deployment. :type deployment_name: str :param properties: The deployment properties. - :type properties: - ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentWhatIfProperties + :type properties: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentWhatIfProperties :param location: The location to store the deployment data. :type location: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy + :paramtype polling: bool or ~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 WhatIfOperationResult - or ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.resource.resources.v2019_08_01.models.WhatIfOperationResult] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.resource.resources.v2019_08_01.models.WhatIfOperationResult]] - :raises: :class:`CloudError` + :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] + cls = kwargs.pop('cls', None) # type: ClsType["models.WhatIfOperationResult"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._what_if_at_subscription_scope_initial( deployment_name=deployment_name, properties=properties, location=location, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - header_dict = { - 'Location': 'str', - 'Retry-After': 'str', - } - deserialized = self._deserialize('WhatIfOperationResult', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **operation_config) + 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 return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - what_if_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} + begin_what_if_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore def export_template_at_subscription_scope( - self, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentExportResult" """Exports the template used for specified deployment. :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentExportResult or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExportResult - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExportResult + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExportResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + # Construct URL - url = self.export_template_at_subscription_scope.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentExportResult', response) + deserialized = self._deserialize('DeploymentExportResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - export_template_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} + export_template_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore def list_at_subscription_scope( - self, filter=None, top=None, custom_headers=None, raw=False, **operation_config): + self, + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.DeploymentListResult"] """Get all the deployments for a subscription. - :param filter: The filter to apply on the operation. For example, you - can use $filter=provisioningState eq '{state}'. + :param filter: The filter to apply on the operation. For example, you can use + $filter=provisioningState eq '{state}'. :type filter: str - :param top: The number of results to get. If null is passed, returns - all deployments. + :param top: The number of results to get. If null is passed, returns all deployments. :type top: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of DeploymentExtended - :rtype: - ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtendedPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_at_subscription_scope.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.DeploymentExtendedPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/'} + return pipeline_response + return ItemPaged( + get_next, extract_data + ) + list_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/'} # type: ignore def _delete_initial( - self, resource_group_name, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + # Construct URL - url = self.delete.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [202, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - - def delete( - self, resource_group_name, deployment_name, custom_headers=None, raw=False, polling=True, **operation_config): - """Deletes a deployment from the deployment history. - - A template deployment that is currently running cannot be deleted. - Deleting a template deployment removes the associated deployment - operations. Deleting a template deployment does not affect the state of - the resource group. This is an asynchronous operation that returns a - status of 202 until the template deployment is successfully deleted. - The Location response header contains the URI that is used to obtain - the status of the process. While the process is running, a call to the - URI in the Location header returns a status of 202. When the process - finishes, the URI in the Location header returns a status of 204 on - success. If the asynchronous request failed, the URI in the Location - header returns an error-level status code. - - :param resource_group_name: The name of the resource group with the - deployment to delete. The name is case insensitive. + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + def begin_delete( + self, + resource_group_name, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """A template deployment that is currently running cannot be deleted. Deleting a template deployment removes the associated deployment operations. Deleting a template deployment does not affect the state of the resource group. This is an asynchronous operation that returns a status of 202 until the template deployment is successfully deleted. The Location response header contains the URI that is used to obtain the status of the process. While the process is running, a call to the URI in the Location header returns a status of 202. When the process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. + + Deletes a deployment from the deployment history. + + :param resource_group_name: The name of the resource group with the deployment to delete. The + name is case insensitive. :type resource_group_name: str :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns None or - ClientRawResponse if raw==True - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._delete_initial( resource_group_name=resource_group_name, deployment_name=deployment_name, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore def check_existence( - self, resource_group_name, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Checks whether the deployment exists. - :param resource_group_name: The name of the resource group with the - deployment to check. The name is case insensitive. + :param resource_group_name: The name of the resource group with the deployment to check. The + name is case insensitive. :type resource_group_name: str :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: bool or ClientRawResponse if raw=true - :rtype: bool or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + # Construct URL - url = self.check_existence.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204, 404]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = (response.status_code == 204) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - return deserialized - check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + if cls: + return cls(pipeline_response, None, {}) + + 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, deployment_name, properties, location=None, custom_headers=None, raw=False, **operation_config): - parameters = models.Deployment(location=location, properties=properties) + self, + resource_group_name, # type: str + deployment_name, # type: str + properties, # type: "models.DeploymentProperties" + location=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentExtended" + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.Deployment(location=location, properties=properties) + api_version = "2019-08-01" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.create_or_update.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'Deployment') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 201]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', response) + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', response) + deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - - def create_or_update( - self, resource_group_name, deployment_name, properties, location=None, custom_headers=None, raw=False, polling=True, **operation_config): - """Deploys resources to a resource group. - - You can provide the template and parameters directly in the request or - link to JSON files. - - :param resource_group_name: The name of the resource group to deploy - the resources to. The name is case insensitive. The resource group - must already exist. + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + def begin_create_or_update( + self, + resource_group_name, # type: str + deployment_name, # type: str + properties, # type: "models.DeploymentProperties" + location=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """You can provide the template and parameters directly in the request or link to JSON files. + + Deploys resources to a resource group. + + :param resource_group_name: The name of the resource group to deploy the resources to. The name + is case insensitive. The resource group must already exist. :type resource_group_name: str :param deployment_name: The name of the deployment. :type deployment_name: str :param properties: The deployment properties. - :type properties: - ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentProperties + :type properties: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentProperties :param location: The location to store the deployment data. :type location: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns DeploymentExtended or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 DeploymentExtended + :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] + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._create_or_update_initial( resource_group_name=resource_group_name, deployment_name=deployment_name, properties=properties, location=location, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - deserialized = self._deserialize('DeploymentExtended', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore def get( - self, resource_group_name, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentExtended" """Gets a deployment. - :param resource_group_name: The name of the resource group. The name - is case insensitive. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentExtended or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExtended or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + # Construct URL - url = self.get.metadata['url'] + url = self.get.metadata['url'] # type: 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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', response) + deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore def cancel( - self, resource_group_name, deployment_name, custom_headers=None, raw=False, **operation_config): - """Cancels a currently running template deployment. + self, + resource_group_name, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """You can cancel a deployment only if the provisioningState is Accepted or Running. After the deployment is canceled, the provisioningState is set to Canceled. Canceling a template deployment stops the currently running template deployment and leaves the resource group partially deployed. - You can cancel a deployment only if the provisioningState is Accepted - or Running. After the deployment is canceled, the provisioningState is - set to Canceled. Canceling a template deployment stops the currently - running template deployment and leaves the resource group partially - deployed. + Cancels a currently running template deployment. - :param resource_group_name: The name of the resource group. The name - is case insensitive. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + # Construct URL - url = self.cancel.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - cancel.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} + if cls: + return cls(pipeline_response, None, {}) - def validate( - self, resource_group_name, deployment_name, properties, location=None, custom_headers=None, raw=False, **operation_config): - """Validates whether the specified template is syntactically correct and - will be accepted by Azure Resource Manager.. + cancel.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore - :param resource_group_name: The name of the resource group the - template will be deployed to. The name is case insensitive. + def validate( + self, + resource_group_name, # type: str + deployment_name, # type: str + properties, # type: "models.DeploymentProperties" + location=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentValidateResult" + """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. :type resource_group_name: str :param deployment_name: The name of the deployment. :type deployment_name: str :param properties: The deployment properties. - :type properties: - ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentProperties + :type properties: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentProperties :param location: The location to store the deployment data. :type location: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentValidateResult or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentValidateResult - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentValidateResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentValidateResult + :raises: ~azure.core.exceptions.HttpResponseError """ - parameters = models.Deployment(location=location, properties=properties) + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentValidateResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.Deployment(location=location, properties=properties) + api_version = "2019-08-01" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.validate.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'Deployment') # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 400]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', response) + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', response) + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - validate.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} - + validate.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore def _what_if_initial( - self, resource_group_name, deployment_name, properties, location=None, custom_headers=None, raw=False, **operation_config): - parameters = models.DeploymentWhatIf(location=location, properties=properties) + self, + resource_group_name, # type: str + deployment_name, # type: str + properties, # type: "models.DeploymentWhatIfProperties" + location=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.WhatIfOperationResult" + cls = kwargs.pop('cls', None) # type: ClsType["models.WhatIfOperationResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.DeploymentWhatIf(location=location, properties=properties) + api_version = "2019-08-01" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.what_if.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'DeploymentWhatIf') # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 202]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} deserialized = None - header_dict = {} - if response.status_code == 200: - deserialized = self._deserialize('WhatIfOperationResult', response) - header_dict = { - 'Location': 'str', - 'Retry-After': 'str', - } + deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_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')) - return deserialized - - def what_if( - self, resource_group_name, deployment_name, properties, location=None, custom_headers=None, raw=False, polling=True, **operation_config): - """Returns changes that will be made by the deployment if executed at the - scope of the resource group. + if cls: + return cls(pipeline_response, deserialized, response_headers) - :param resource_group_name: The name of the resource group the - template will be deployed to. The name is case insensitive. + return deserialized + _what_if_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + + def begin_what_if( + self, + resource_group_name, # type: str + deployment_name, # type: str + properties, # type: "models.DeploymentWhatIfProperties" + location=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """Returns changes that will be made by the deployment if executed at the scope of the resource group. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. :type resource_group_name: str :param deployment_name: The name of the deployment. :type deployment_name: str :param properties: The deployment properties. - :type properties: - ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentWhatIfProperties + :type properties: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentWhatIfProperties :param location: The location to store the deployment data. :type location: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy + :paramtype polling: bool or ~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 WhatIfOperationResult - or ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.resource.resources.v2019_08_01.models.WhatIfOperationResult] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.resource.resources.v2019_08_01.models.WhatIfOperationResult]] - :raises: :class:`CloudError` + :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] + cls = kwargs.pop('cls', None) # type: ClsType["models.WhatIfOperationResult"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._what_if_initial( resource_group_name=resource_group_name, deployment_name=deployment_name, properties=properties, location=location, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - header_dict = { - 'Location': 'str', - 'Retry-After': 'str', - } - deserialized = self._deserialize('WhatIfOperationResult', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **operation_config) + 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 return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - what_if.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} + begin_what_if.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore def export_template( - self, resource_group_name, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentExportResult" """Exports the template used for specified deployment. - :param resource_group_name: The name of the resource group. The name - is case insensitive. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentExportResult or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExportResult - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExportResult + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExportResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + # Construct URL - url = self.export_template.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentExportResult', response) + deserialized = self._deserialize('DeploymentExportResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} + export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore def list_by_resource_group( - self, resource_group_name, filter=None, top=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.DeploymentListResult"] """Get all the deployments for a resource group. - :param resource_group_name: The name of the resource group with the - deployments to get. The name is case insensitive. + :param resource_group_name: The name of the resource group with the deployments to get. The + name is case insensitive. :type resource_group_name: str - :param filter: The filter to apply on the operation. For example, you - can use $filter=provisioningState eq '{state}'. + :param filter: The filter to apply on the operation. For example, you can use + $filter=provisioningState eq '{state}'. :type filter: str - :param top: The number of results to get. If null is passed, returns - all deployments. + :param top: The number of results to get. If null is passed, returns all deployments. :type top: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of DeploymentExtended - :rtype: - ~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtendedPaged[~azure.mgmt.resource.resources.v2019_08_01.models.DeploymentExtended] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_by_resource_group.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.DeploymentExtendedPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/'} + return ItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/'} # type: ignore def calculate_template_hash( - self, template, custom_headers=None, raw=False, **operation_config): + self, + template, # type: object + **kwargs # type: Any + ): + # type: (...) -> "models.TemplateHashResult" """Calculate the hash of the given template. :param template: The template provided to calculate hash. :type template: object - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: TemplateHashResult or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_08_01.models.TemplateHashResult - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateHashResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.TemplateHashResult + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TemplateHashResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + content_type = kwargs.pop("content_type", "application/json") + # Construct URL - url = self.calculate_template_hash.metadata['url'] + url = self.calculate_template_hash.metadata['url'] # type: ignore # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(template, 'object') # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('TemplateHashResult', response) + deserialized = self._deserialize('TemplateHashResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - calculate_template_hash.metadata = {'url': '/providers/Microsoft.Resources/calculateTemplateHash'} + 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 beafb6d9a5de..c0a61c8236ba 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 @@ -1,102 +1,106 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class Operations(object): """Operations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2019_08_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for this operation. Constant value: "2019-08-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-08-01" - - self.config = config + self._config = config def list( - self, custom_headers=None, raw=False, **operation_config): + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.OperationListResult"] """Lists all of the available Microsoft.Resources REST API operations. - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of Operation - :rtype: - ~azure.mgmt.resource.resources.v2019_08_01.models.OperationPaged[~azure.mgmt.resource.resources.v2019_08_01.models.Operation] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of OperationListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['url'] - + url = self.list.metadata['url'] # type: ignore # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('OperationListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.OperationPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list.metadata = {'url': '/providers/Microsoft.Resources/operations'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.Resources/operations'} # type: ignore 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 80eb092b83ba..29f3b48e23e7 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 @@ -1,437 +1,417 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class ProvidersOperations(object): """ProvidersOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2019_08_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for this operation. Constant value: "2019-08-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-08-01" - - self.config = config + self._config = config def unregister( - self, resource_provider_namespace, custom_headers=None, raw=False, **operation_config): + self, + resource_provider_namespace, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.Provider" """Unregisters a subscription from a resource provider. - :param resource_provider_namespace: The namespace of the resource - provider to unregister. + :param resource_provider_namespace: The namespace of the resource provider to unregister. :type resource_provider_namespace: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: Provider or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.Provider or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Provider or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.Provider + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Provider"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + # Construct URL - url = self.unregister.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('Provider', response) + deserialized = self._deserialize('Provider', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - unregister.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister'} + unregister.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister'} # type: ignore def register( - self, resource_provider_namespace, custom_headers=None, raw=False, **operation_config): + self, + resource_provider_namespace, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.Provider" """Registers a subscription with a resource provider. - :param resource_provider_namespace: The namespace of the resource - provider to register. + :param resource_provider_namespace: The namespace of the resource provider to register. :type resource_provider_namespace: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: Provider or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.Provider or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Provider or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.Provider + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Provider"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + # Construct URL - url = self.register.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('Provider', response) + deserialized = self._deserialize('Provider', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - register.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register'} + register.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register'} # type: ignore def list( - self, top=None, expand=None, custom_headers=None, raw=False, **operation_config): + self, + top=None, # type: Optional[int] + expand=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.ProviderListResult"] """Gets all resource providers for a subscription. - :param top: The number of results to return. If null is passed returns - all deployments. + :param top: The number of results to return. If null is passed returns all deployments. :type top: int - :param expand: The properties to include in the results. For example, - use &$expand=metadata in the query string to retrieve resource - provider metadata. To include property aliases in response, use - $expand=resourceTypes/aliases. + :param expand: The properties to include in the results. For example, use &$expand=metadata in + the query string to retrieve resource provider metadata. To include property aliases in + response, use $expand=resourceTypes/aliases. :type expand: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of Provider - :rtype: - ~azure.mgmt.resource.resources.v2019_08_01.models.ProviderPaged[~azure.mgmt.resource.resources.v2019_08_01.models.Provider] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of ProviderListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['url'] + url = self.list.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_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 = {} + 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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('ProviderListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.ProviderPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers'} # type: ignore def list_at_tenant_scope( - self, top=None, expand=None, custom_headers=None, raw=False, **operation_config): + self, + top=None, # type: Optional[int] + expand=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.ProviderListResult"] """Gets all resource providers for the tenant. - :param top: The number of results to return. If null is passed returns - all providers. + :param top: The number of results to return. If null is passed returns all providers. :type top: int - :param expand: The properties to include in the results. For example, - use &$expand=metadata in the query string to retrieve resource - provider metadata. To include property aliases in response, use - $expand=resourceTypes/aliases. + :param expand: The properties to include in the results. For example, use &$expand=metadata in + the query string to retrieve resource provider metadata. To include property aliases in + response, use $expand=resourceTypes/aliases. :type expand: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of Provider - :rtype: - ~azure.mgmt.resource.resources.v2019_08_01.models.ProviderPaged[~azure.mgmt.resource.resources.v2019_08_01.models.Provider] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of ProviderListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_at_tenant_scope.metadata['url'] - + url = self.list_at_tenant_scope.metadata['url'] # type: ignore # Construct parameters - query_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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('ProviderListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.ProviderPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_at_tenant_scope.metadata = {'url': '/providers'} + return ItemPaged( + get_next, extract_data + ) + list_at_tenant_scope.metadata = {'url': '/providers'} # type: ignore def get( - self, resource_provider_namespace, expand=None, custom_headers=None, raw=False, **operation_config): + self, + resource_provider_namespace, # type: str + expand=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.Provider" """Gets the specified resource provider. - :param resource_provider_namespace: The namespace of the resource - provider. + :param resource_provider_namespace: The namespace of the resource provider. :type resource_provider_namespace: str - :param expand: The $expand query parameter. For example, to include - property aliases in response, use $expand=resourceTypes/aliases. + :param expand: The $expand query parameter. For example, to include property aliases in + response, use $expand=resourceTypes/aliases. :type expand: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: Provider or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.Provider or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Provider or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.Provider + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Provider"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + # Construct URL - url = self.get.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('Provider', response) + deserialized = self._deserialize('Provider', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}'} # type: ignore def get_at_tenant_scope( - self, resource_provider_namespace, expand=None, custom_headers=None, raw=False, **operation_config): + self, + resource_provider_namespace, # type: str + expand=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.Provider" """Gets the specified resource provider at the tenant level. - :param resource_provider_namespace: The namespace of the resource - provider. + :param resource_provider_namespace: The namespace of the resource provider. :type resource_provider_namespace: str - :param expand: The $expand query parameter. For example, to include - property aliases in response, use $expand=resourceTypes/aliases. + :param expand: The $expand query parameter. For example, to include property aliases in + response, use $expand=resourceTypes/aliases. :type expand: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: Provider or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.Provider or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Provider or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.Provider + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Provider"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + # Construct URL - url = self.get_at_tenant_scope.metadata['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') + 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('Provider', response) + deserialized = self._deserialize('Provider', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get_at_tenant_scope.metadata = {'url': '/providers/{resourceProviderNamespace}'} + 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 e7d76639c443..9711ee0f7fd7 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 @@ -1,563 +1,558 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError -from msrest.polling import LROPoller, NoPolling -from msrestazure.polling.arm_polling import ARMPolling +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, List, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class ResourceGroupsOperations(object): """ResourceGroupsOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2019_08_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for this operation. Constant value: "2019-08-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-08-01" - - self.config = config + self._config = config def check_existence( - self, resource_group_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Checks whether a resource group exists. - :param resource_group_name: The name of the resource group to check. - The name is case insensitive. + :param resource_group_name: The name of the resource group to check. The name is case + insensitive. :type resource_group_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: bool or ClientRawResponse if raw=true - :rtype: bool or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + # Construct URL - url = self.check_existence.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204, 404]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = (response.status_code == 204) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - return deserialized - check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore def create_or_update( - self, resource_group_name, parameters, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + parameters, # type: "models.ResourceGroup" + **kwargs # type: Any + ): + # type: (...) -> "models.ResourceGroup" """Creates or updates a resource group. - :param resource_group_name: The name of the resource group to create - or update. Can include alphanumeric, underscore, parentheses, hyphen, - period (except at end), and Unicode characters that match the allowed - characters. + :param resource_group_name: The name of the resource group to create or update. Can include + alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters + that match the allowed characters. :type resource_group_name: str - :param parameters: Parameters supplied to the create or update a - resource group. - :type parameters: - ~azure.mgmt.resource.resources.v2019_08_01.models.ResourceGroup - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: ResourceGroup or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_08_01.models.ResourceGroup or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :param parameters: Parameters supplied to the create or update a resource group. + :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.ResourceGroup + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.ResourceGroup + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceGroup"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + content_type = kwargs.pop("content_type", "application/json") + # Construct URL - url = self.create_or_update.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'ResourceGroup') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 201]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ResourceGroup', response) + deserialized = self._deserialize('ResourceGroup', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('ResourceGroup', response) + deserialized = self._deserialize('ResourceGroup', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} - + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore def _delete_initial( - self, resource_group_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + # Construct URL - url = self.delete.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 202]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + if cls: + return cls(pipeline_response, None, {}) - def delete( - self, resource_group_name, custom_headers=None, raw=False, polling=True, **operation_config): - """Deletes a resource group. + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore - When you delete a resource group, all of its resources are also - deleted. Deleting a resource group deletes all of its template - deployments and currently stored operations. + def begin_delete( + self, + resource_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """When you delete a resource group, all of its resources are also deleted. Deleting a resource group deletes all of its template deployments and currently stored operations. - :param resource_group_name: The name of the resource group to delete. - The name is case insensitive. + Deletes a resource group. + + :param resource_group_name: The name of the resource group to delete. The name is case + insensitive. :type resource_group_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns None or - ClientRawResponse if raw==True - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._delete_initial( resource_group_name=resource_group_name, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore def get( - self, resource_group_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.ResourceGroup" """Gets a resource group. - :param resource_group_name: The name of the resource group to get. The - name is case insensitive. + :param resource_group_name: The name of the resource group to get. The name is case + insensitive. :type resource_group_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: ResourceGroup or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_08_01.models.ResourceGroup or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.ResourceGroup + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceGroup"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + # Construct URL - url = self.get.metadata['url'] + url = self.get.metadata['url'] # type: 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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('ResourceGroup', response) + deserialized = self._deserialize('ResourceGroup', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore def update( - self, resource_group_name, parameters, custom_headers=None, raw=False, **operation_config): - """Updates a resource group. - - Resource groups can be updated through a simple PATCH operation to a - group address. The format of the request is the same as that for - creating a resource group. If a field is unspecified, the current value - is retained. - - :param resource_group_name: The name of the resource group to update. - The name is case insensitive. + self, + resource_group_name, # type: str + parameters, # type: "models.ResourceGroupPatchable" + **kwargs # type: Any + ): + # type: (...) -> "models.ResourceGroup" + """Resource groups can be updated through a simple PATCH operation to a group address. The format of the request is the same as that for creating a resource group. If a field is unspecified, the current value is retained. + + Updates a resource group. + + :param resource_group_name: The name of the resource group to update. The name is case + insensitive. :type resource_group_name: str :param parameters: Parameters supplied to update a resource group. - :type parameters: - ~azure.mgmt.resource.resources.v2019_08_01.models.ResourceGroupPatchable - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: ResourceGroup or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_08_01.models.ResourceGroup or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :type parameters: ~azure.mgmt.resource.resources.v2019_08_01.models.ResourceGroupPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.ResourceGroup + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceGroup"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + content_type = kwargs.pop("content_type", "application/json") + # Construct URL - url = self.update.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'ResourceGroupPatchable') # Construct and send request - request = self._client.patch(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('ResourceGroup', response) + deserialized = self._deserialize('ResourceGroup', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} - + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore def _export_template_initial( - self, resource_group_name, resources=None, options=None, custom_headers=None, raw=False, **operation_config): - parameters = models.ExportTemplateRequest(resources=resources, options=options) + self, + resource_group_name, # type: str + resources=None, # type: Optional[List[str]] + options=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.ResourceGroupExportResult" + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceGroupExportResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.ExportTemplateRequest(resources=resources, options=options) + api_version = "2019-08-01" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.export_template.metadata['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, pattern=r'^[-\w\._\(\)]+$') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'ExportTemplateRequest') # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 202]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('ResourceGroupExportResult', response) + deserialized = self._deserialize('ResourceGroupExportResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - - def export_template( - self, resource_group_name, resources=None, options=None, custom_headers=None, raw=False, polling=True, **operation_config): + _export_template_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate'} # type: ignore + + def begin_export_template( + self, + resource_group_name, # type: str + resources=None, # type: Optional[List[str]] + options=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> LROPoller """Captures the specified resource group as a template. - :param resource_group_name: The name of the resource group. The name - is case insensitive. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str - :param resources: The IDs of the resources to filter the export by. To - export all resources, supply an array with single entry '*'. + :param 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', - 'SkipResourceNameParameterization', 'SkipAllParameterization' + :param options: The export template options. A CSV-formatted list containing zero or more of + the following: 'IncludeParameterDefaultValue', 'IncludeComments', + 'SkipResourceNameParameterization', 'SkipAllParameterization'. :type options: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns - ResourceGroupExportResult or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.resource.resources.v2019_08_01.models.ResourceGroupExportResult] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.resource.resources.v2019_08_01.models.ResourceGroupExportResult]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 ResourceGroupExportResult + :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] + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceGroupExportResult"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._export_template_initial( resource_group_name=resource_group_name, resources=resources, options=options, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - deserialized = self._deserialize('ResourceGroupExportResult', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ResourceGroupExportResult', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **operation_config) + 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 return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate'} + begin_export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate'} # type: ignore def list( - self, filter=None, top=None, custom_headers=None, raw=False, **operation_config): + self, + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.ResourceGroupListResult"] """Gets all the resource groups for a subscription. - :param filter: The filter to apply on the operation.

You can - filter by tag names and values. For example, to filter for a tag name - and value, use $filter=tagName eq 'tag1' and tagValue eq 'Value1' + :param filter: The filter to apply on the operation.:code:`
`:code:`
`You can filter by + tag names and values. For example, to filter for a tag name and value, use $filter=tagName eq + 'tag1' and tagValue eq 'Value1'. :type filter: str - :param top: The number of results to return. If null is passed, - returns all resource groups. + :param top: The number of results to return. If null is passed, returns all resource groups. :type top: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of ResourceGroup - :rtype: - ~azure.mgmt.resource.resources.v2019_08_01.models.ResourceGroupPaged[~azure.mgmt.resource.resources.v2019_08_01.models.ResourceGroup] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['url'] + url = self.list.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_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 = {} + 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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('ResourceGroupListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.ResourceGroupPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups'} # type: ignore 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 9d601c73063e..a11f488267bf 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 @@ -1,560 +1,579 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError -from msrest.polling import LROPoller, NoPolling -from msrestazure.polling.arm_polling import ARMPolling +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, List, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class ResourcesOperations(object): """ResourcesOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2019_08_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for this operation. Constant value: "2019-08-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-08-01" - - self.config = config + self._config = config def list_by_resource_group( - self, resource_group_name, filter=None, expand=None, top=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + filter=None, # type: Optional[str] + expand=None, # type: Optional[str] + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.ResourceListResult"] """Get all the resources for a resource group. - :param resource_group_name: The resource group with the resources to - get. + :param resource_group_name: The resource group with the resources to get. :type resource_group_name: str - :param filter: The filter to apply on the operation.

The - properties you can use for eq (equals) or ne (not equals) are: - location, resourceType, name, resourceGroup, identity, - identity/principalId, plan, plan/publisher, plan/product, plan/name, - plan/version, and plan/promotionCode.

For example, to filter by - a resource type, use: $filter=resourceType eq - 'Microsoft.Network/virtualNetworks'

You can use - substringof(value, property) in the filter. The properties you can use - for substring are: name and resourceGroup.

For example, to get - all resources with 'demo' anywhere in the name, use: - $filter=substringof('demo', name)

You can link more than one - substringof together by adding and/or operators.

You can filter - by tag names and values. For example, to filter for a tag name and - value, use $filter=tagName eq 'tag1' and tagValue eq 'Value1'. When - you filter by a tag name and value, the tags for each resource are not - returned in the results.

You can use some properties together - when filtering. The combinations you can use are: substringof and/or - resourceType, plan and plan/publisher and plan/name, identity and - identity/principalId. + :param filter: The filter to apply on the operation.:code:`
`:code:`
`The properties you + can use for eq (equals) or ne (not equals) are: location, resourceType, name, resourceGroup, + identity, identity/principalId, plan, plan/publisher, plan/product, plan/name, plan/version, + and plan/promotionCode.:code:`
`:code:`
`For example, to filter by a resource type, use: + $filter=resourceType eq 'Microsoft.Network/virtualNetworks':code:`
`:code:`
`You can use + substringof(value, property) in the filter. The properties you can use for substring are: name + and resourceGroup.:code:`
`:code:`
`For example, to get all resources with 'demo' + anywhere in the name, use: $filter=substringof('demo', name):code:`
`:code:`
`You can + link more than one substringof together by adding and/or operators.:code:`
`:code:`
`You + can filter by tag names and values. For example, to filter for a tag name and value, use + $filter=tagName eq 'tag1' and tagValue eq 'Value1'. When you filter by a tag name and value, + the tags for each resource are not returned in the results.:code:`
`:code:`
`You can use + some properties together when filtering. The combinations you can use are: substringof and/or + resourceType, plan and plan/publisher and plan/name, identity and identity/principalId. :type filter: str - :param expand: Comma-separated list of additional properties to be - included in the response. Valid values include `createdTime`, - `changedTime` and `provisioningState`. For example, - `$expand=createdTime,changedTime`. + :param expand: Comma-separated list of additional properties to be included in the response. + Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, + ``$expand=createdTime,changedTime``. :type expand: str - :param top: The 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 - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of GenericResourceExpanded - :rtype: - ~azure.mgmt.resource.resources.v2019_08_01.models.GenericResourceExpandedPaged[~azure.mgmt.resource.resources.v2019_08_01.models.GenericResourceExpanded] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of ResourceListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_by_resource_group.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('ResourceListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response - - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.GenericResourceExpandedPaged(internal_paging, self._deserialize.dependencies, header_dict) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return deserialized - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources'} + return pipeline_response + return ItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources'} # type: ignore def _move_resources_initial( - self, source_resource_group_name, resources=None, target_resource_group=None, custom_headers=None, raw=False, **operation_config): - parameters = models.ResourcesMoveInfo(resources=resources, target_resource_group=target_resource_group) + self, + source_resource_group_name, # type: str + resources=None, # type: Optional[List[str]] + target_resource_group=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.ResourcesMoveInfo(resources=resources, target_resource_group=target_resource_group) + api_version = "2019-08-01" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.move_resources.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'ResourcesMoveInfo') + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [202, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - - def move_resources( - self, source_resource_group_name, resources=None, target_resource_group=None, custom_headers=None, raw=False, polling=True, **operation_config): - """Moves resources from one resource group to another resource group. - - The resources to move must be in the same source resource group. The - target resource group may be in a different subscription. When moving - resources, both the source group and the target group are locked for - the duration of the operation. Write and delete operations are blocked - on the groups until the move completes. . - - :param source_resource_group_name: The name of the resource group - containing the resources to move. + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore + + def begin_move_resources( + self, + source_resource_group_name, # type: str + resources=None, # type: Optional[List[str]] + target_resource_group=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """The resources to move must be in the same source resource group. The target resource group may be in a different subscription. When moving resources, both the source group and the target group are locked for the duration of the operation. Write and delete operations are blocked on the groups until the move completes. + + Moves resources from one resource group to another resource group. + + :param source_resource_group_name: The name of the resource group containing the resources to + move. :type source_resource_group_name: str :param resources: The IDs of the resources. :type resources: list[str] :param target_resource_group: The target resource group. :type target_resource_group: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns None or - ClientRawResponse if raw==True - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._move_resources_initial( source_resource_group_name=source_resource_group_name, resources=resources, target_resource_group=target_resource_group, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} - + begin_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore def _validate_move_resources_initial( - self, source_resource_group_name, resources=None, target_resource_group=None, custom_headers=None, raw=False, **operation_config): - parameters = models.ResourcesMoveInfo(resources=resources, target_resource_group=target_resource_group) + self, + source_resource_group_name, # type: str + resources=None, # type: Optional[List[str]] + target_resource_group=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.ResourcesMoveInfo(resources=resources, target_resource_group=target_resource_group) + api_version = "2019-08-01" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.validate_move_resources.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'ResourcesMoveInfo') + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [202, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - - def validate_move_resources( - self, source_resource_group_name, resources=None, target_resource_group=None, custom_headers=None, raw=False, polling=True, **operation_config): - """Validates whether resources can be moved from one resource group to - another resource group. - - This operation checks whether the specified resources can be moved to - the target. The resources to move must be in the same source resource - group. The target resource group may be in a different subscription. If - validation succeeds, it returns HTTP response code 204 (no content). If - validation fails, it returns HTTP response code 409 (Conflict) with an - error message. Retrieve the URL in the Location header value to check - the result of the long-running operation. - - :param source_resource_group_name: The name of the resource group - containing the resources to validate for move. + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _validate_move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} # type: ignore + + def begin_validate_move_resources( + self, + source_resource_group_name, # type: str + resources=None, # type: Optional[List[str]] + target_resource_group=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """This operation checks whether the specified resources can be moved to the target. The resources to move must be in the same source resource group. The target resource group may be in a different subscription. If validation succeeds, it returns HTTP response code 204 (no content). If validation fails, it returns HTTP response code 409 (Conflict) with an error message. Retrieve the URL in the Location header value to check the result of the long-running operation. + + Validates whether resources can be moved from one resource group to another resource group. + + :param source_resource_group_name: The name of the resource group containing the resources to + validate for move. :type source_resource_group_name: str :param resources: The IDs of the resources. :type resources: list[str] :param target_resource_group: The target resource group. :type target_resource_group: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns None or - ClientRawResponse if raw==True - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._validate_move_resources_initial( source_resource_group_name=source_resource_group_name, resources=resources, target_resource_group=target_resource_group, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - validate_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} + begin_validate_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} # type: ignore def list( - self, filter=None, expand=None, top=None, custom_headers=None, raw=False, **operation_config): + self, + filter=None, # type: Optional[str] + expand=None, # type: Optional[str] + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.ResourceListResult"] """Get all the resources in a subscription. - :param filter: The filter to apply on the operation.

The - properties you can use for eq (equals) or ne (not equals) are: - location, resourceType, name, resourceGroup, identity, - identity/principalId, plan, plan/publisher, plan/product, plan/name, - plan/version, and plan/promotionCode.

For example, to filter by - a resource type, use: $filter=resourceType eq - 'Microsoft.Network/virtualNetworks'

You can use - substringof(value, property) in the filter. The properties you can use - for substring are: name and resourceGroup.

For example, to get - all resources with 'demo' anywhere in the name, use: - $filter=substringof('demo', name)

You can link more than one - substringof together by adding and/or operators.

You can filter - by tag names and values. For example, to filter for a tag name and - value, use $filter=tagName eq 'tag1' and tagValue eq 'Value1'. When - you filter by a tag name and value, the tags for each resource are not - returned in the results.

You can use some properties together - when filtering. The combinations you can use are: substringof and/or - resourceType, plan and plan/publisher and plan/name, identity and - identity/principalId. + :param filter: The filter to apply on the operation.:code:`
`:code:`
`The properties you + can use for eq (equals) or ne (not equals) are: location, resourceType, name, resourceGroup, + identity, identity/principalId, plan, plan/publisher, plan/product, plan/name, plan/version, + and plan/promotionCode.:code:`
`:code:`
`For example, to filter by a resource type, use: + $filter=resourceType eq 'Microsoft.Network/virtualNetworks':code:`
`:code:`
`You can use + substringof(value, property) in the filter. The properties you can use for substring are: name + and resourceGroup.:code:`
`:code:`
`For example, to get all resources with 'demo' + anywhere in the name, use: $filter=substringof('demo', name):code:`
`:code:`
`You can + link more than one substringof together by adding and/or operators.:code:`
`:code:`
`You + can filter by tag names and values. For example, to filter for a tag name and value, use + $filter=tagName eq 'tag1' and tagValue eq 'Value1'. When you filter by a tag name and value, + the tags for each resource are not returned in the results.:code:`
`:code:`
`You can use + some properties together when filtering. The combinations you can use are: substringof and/or + resourceType, plan and plan/publisher and plan/name, identity and identity/principalId. :type filter: str - :param expand: Comma-separated list of additional properties to be - included in the response. Valid values include `createdTime`, - `changedTime` and `provisioningState`. For example, - `$expand=createdTime,changedTime`. + :param expand: Comma-separated list of additional properties to be included in the response. + Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, + ``$expand=createdTime,changedTime``. :type expand: str - :param top: The number of results to return. If null is passed, - returns all resource groups. + :param top: The number of results to return. If null is passed, returns all resource groups. :type top: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of GenericResourceExpanded - :rtype: - ~azure.mgmt.resource.resources.v2019_08_01.models.GenericResourceExpandedPaged[~azure.mgmt.resource.resources.v2019_08_01.models.GenericResourceExpanded] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of ResourceListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['url'] + url = self.list.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_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 = {} + 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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('ResourceListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.GenericResourceExpandedPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resources'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resources'} # type: ignore def check_existence( - self, resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, api_version, custom_headers=None, raw=False, **operation_config): + self, + 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: (...) -> None """Checks whether a resource exists. - :param resource_group_name: The name of the resource group containing - the resource to check. The name is case insensitive. + :param resource_group_name: The name of the resource group containing the resource to check. + The name is case insensitive. :type resource_group_name: str - :param resource_provider_namespace: The resource provider of the - resource to check. + :param resource_provider_namespace: The resource provider of the resource to check. :type resource_provider_namespace: str :param parent_resource_path: The parent resource identity. :type parent_resource_path: str :param resource_type: The resource type. :type resource_type: str - :param resource_name: The name of the resource to check whether it - exists. + :param resource_name: The name of the resource to check whether it exists. :type resource_name: str - :param api_version: The API version to use for the operation. - :type api_version: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: bool or ClientRawResponse if raw=true - :rtype: bool or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + # Construct URL - url = self.check_existence.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204, 404]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = (response.status_code == 204) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - return deserialized - check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + 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, resource_provider_namespace, parent_resource_path, resource_type, resource_name, api_version, custom_headers=None, raw=False, **operation_config): + self, + 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: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + # Construct URL - url = self.delete.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - - def delete( - self, resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, api_version, custom_headers=None, raw=False, polling=True, **operation_config): + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + def begin_delete( + self, + 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: (...) -> LROPoller """Deletes a resource. - :param resource_group_name: The name of the resource group that - contains the resource to delete. The name is case insensitive. + :param resource_group_name: The name of the resource group that contains the resource to + delete. The name is case insensitive. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource - provider. + :param resource_provider_namespace: The namespace of the resource provider. :type resource_provider_namespace: str :param parent_resource_path: The parent resource identity. :type parent_resource_path: str @@ -562,109 +581,122 @@ def delete( :type resource_type: str :param resource_name: The name of the resource to delete. :type resource_name: str - :param api_version: The API version to use for the operation. - :type api_version: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns None or - ClientRawResponse if raw==True - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._delete_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, - api_version=api_version, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} - + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore def _create_or_update_initial( - self, resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, api_version, parameters, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + parameters, # type: "models.GenericResource" + **kwargs # type: Any + ): + # type: (...) -> "models.GenericResource" + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + content_type = kwargs.pop("content_type", "application/json") + # Construct URL - url = self.create_or_update.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'GenericResource') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 201, 202]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('GenericResource', response) + deserialized = self._deserialize('GenericResource', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('GenericResource', response) + deserialized = self._deserialize('GenericResource', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - - def create_or_update( - self, resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, api_version, parameters, custom_headers=None, raw=False, polling=True, **operation_config): + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + def begin_create_or_update( + self, + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + parameters, # type: "models.GenericResource" + **kwargs # type: Any + ): + # type: (...) -> LROPoller """Creates a resource. - :param resource_group_name: The name of the resource group for the - resource. The name is case insensitive. + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource - provider. + :param resource_provider_namespace: The namespace of the resource provider. :type resource_provider_namespace: str :param parent_resource_path: The parent resource identity. :type parent_resource_path: str @@ -672,117 +704,125 @@ def create_or_update( :type resource_type: str :param resource_name: The name of the resource to create. :type resource_name: str - :param api_version: The API version to use for the operation. - :type api_version: str :param parameters: Parameters for creating or updating the resource. - :type parameters: - ~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :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 polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns GenericResource or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 GenericResource + :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] + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._create_or_update_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, - api_version=api_version, parameters=parameters, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - deserialized = self._deserialize('GenericResource', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('GenericResource', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} - + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore def _update_initial( - self, resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, api_version, parameters, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + parameters, # type: "models.GenericResource" + **kwargs # type: Any + ): + # type: (...) -> "models.GenericResource" + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + content_type = kwargs.pop("content_type", "application/json") + # Construct URL - url = self.update.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'GenericResource') # Construct and send request - request = self._client.patch(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 202]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('GenericResource', response) + deserialized = self._deserialize('GenericResource', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - - def update( - self, resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, api_version, parameters, custom_headers=None, raw=False, polling=True, **operation_config): + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + def begin_update( + self, + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + parameters, # type: "models.GenericResource" + **kwargs # type: Any + ): + # type: (...) -> LROPoller """Updates a resource. - :param resource_group_name: The name of the resource group for the - resource. The name is case insensitive. + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource - provider. + :param resource_provider_namespace: The namespace of the resource provider. :type resource_provider_namespace: str :param parent_resource_path: The parent resource identity. :type parent_resource_path: str @@ -790,64 +830,63 @@ def update( :type resource_type: str :param resource_name: The name of the resource to update. :type resource_name: str - :param api_version: The API version to use for the operation. - :type api_version: str :param parameters: Parameters for updating the resource. - :type parameters: - ~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :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 polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns GenericResource or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 GenericResource + :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] + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._update_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, - api_version=api_version, parameters=parameters, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - deserialized = self._deserialize('GenericResource', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('GenericResource', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore def get( - self, resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, api_version, custom_headers=None, raw=False, **operation_config): + self, + 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: (...) -> "models.GenericResource" """Gets a resource. - :param resource_group_name: The name of the resource group containing - the resource to get. The name is case insensitive. + :param resource_group_name: The name of the resource group containing the resource to get. The + name is case insensitive. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource - provider. + :param resource_provider_namespace: The namespace of the resource provider. :type resource_provider_namespace: str :param parent_resource_path: The parent resource identity. :type parent_resource_path: str @@ -855,461 +894,443 @@ def get( :type resource_type: str :param resource_name: The name of the resource to get. :type resource_name: str - :param api_version: The API version to use for the operation. - :type api_version: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: GenericResource or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GenericResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + # Construct URL - url = self.get.metadata['url'] + url = self.get.metadata['url'] # type: 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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('GenericResource', response) + deserialized = self._deserialize('GenericResource', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore def check_existence_by_id( - self, resource_id, api_version, custom_headers=None, raw=False, **operation_config): + self, + resource_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Checks by ID whether a resource exists. - :param resource_id: The fully qualified ID of the resource, including - the resource name and resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. :type resource_id: str - :param api_version: The API version to use for the operation. - :type api_version: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: bool or ClientRawResponse if raw=true - :rtype: bool or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + # Construct URL - url = self.check_existence_by_id.metadata['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) + '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 = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204, 404]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = (response.status_code == 204) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - return deserialized - check_existence_by_id.metadata = {'url': '/{resourceId}'} + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + return 200 <= response.status_code <= 299 + check_existence_by_id.metadata = {'url': '/{resourceId}'} # type: ignore def _delete_by_id_initial( - self, resource_id, api_version, custom_headers=None, raw=False, **operation_config): + self, + resource_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + # Construct URL - url = self.delete_by_id.metadata['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) + '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 = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + _delete_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore - def delete_by_id( - self, resource_id, api_version, custom_headers=None, raw=False, polling=True, **operation_config): + def begin_delete_by_id( + self, + resource_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> LROPoller """Deletes a resource by ID. - :param resource_id: The fully qualified ID of the resource, including - the resource name and resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. :type resource_id: str - :param api_version: The API version to use for the operation. - :type api_version: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns None or - ClientRawResponse if raw==True - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._delete_by_id_initial( resource_id=resource_id, - api_version=api_version, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - delete_by_id.metadata = {'url': '/{resourceId}'} - + begin_delete_by_id.metadata = {'url': '/{resourceId}'} # type: ignore def _create_or_update_by_id_initial( - self, resource_id, api_version, parameters, custom_headers=None, raw=False, **operation_config): + self, + resource_id, # type: str + parameters, # type: "models.GenericResource" + **kwargs # type: Any + ): + # type: (...) -> "models.GenericResource" + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + content_type = kwargs.pop("content_type", "application/json") + # Construct URL - url = self.create_or_update_by_id.metadata['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) + '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 = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'GenericResource') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 201, 202]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('GenericResource', response) + deserialized = self._deserialize('GenericResource', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('GenericResource', response) + deserialized = self._deserialize('GenericResource', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - - def create_or_update_by_id( - self, resource_id, api_version, parameters, custom_headers=None, raw=False, polling=True, **operation_config): + _create_or_update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + def begin_create_or_update_by_id( + self, + resource_id, # type: str + parameters, # type: "models.GenericResource" + **kwargs # type: Any + ): + # type: (...) -> LROPoller """Create a resource by ID. - :param resource_id: The fully qualified ID of the resource, including - the resource name and resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. :type resource_id: str - :param api_version: The API version to use for the operation. - :type api_version: str :param parameters: Create or update resource parameters. - :type parameters: - ~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :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 polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns GenericResource or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 GenericResource + :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] + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._create_or_update_by_id_initial( resource_id=resource_id, - api_version=api_version, parameters=parameters, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - deserialized = self._deserialize('GenericResource', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('GenericResource', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - create_or_update_by_id.metadata = {'url': '/{resourceId}'} - + begin_create_or_update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore def _update_by_id_initial( - self, resource_id, api_version, parameters, custom_headers=None, raw=False, **operation_config): + self, + resource_id, # type: str + parameters, # type: "models.GenericResource" + **kwargs # type: Any + ): + # type: (...) -> "models.GenericResource" + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + content_type = kwargs.pop("content_type", "application/json") + # Construct URL - url = self.update_by_id.metadata['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) + '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 = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'GenericResource') # Construct and send request - request = self._client.patch(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 202]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('GenericResource', response) + deserialized = self._deserialize('GenericResource', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - - def update_by_id( - self, resource_id, api_version, parameters, custom_headers=None, raw=False, polling=True, **operation_config): + _update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + def begin_update_by_id( + self, + resource_id, # type: str + parameters, # type: "models.GenericResource" + **kwargs # type: Any + ): + # type: (...) -> LROPoller """Updates a resource by ID. - :param resource_id: The fully qualified ID of the resource, including - the resource name and resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. :type resource_id: str - :param api_version: The API version to use for the operation. - :type api_version: str :param parameters: Update resource parameters. - :type parameters: - ~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :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 polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns GenericResource or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 GenericResource + :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] + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._update_by_id_initial( resource_id=resource_id, - api_version=api_version, parameters=parameters, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - deserialized = self._deserialize('GenericResource', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('GenericResource', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - update_by_id.metadata = {'url': '/{resourceId}'} + begin_update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore def get_by_id( - self, resource_id, api_version, custom_headers=None, raw=False, **operation_config): + self, + resource_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.GenericResource" """Gets a resource by ID. - :param resource_id: The fully qualified ID of the resource, including - the resource name and resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. :type resource_id: str - :param api_version: The API version to use for the operation. - :type api_version: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: GenericResource or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GenericResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.GenericResource + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + # Construct URL - url = self.get_by_id.metadata['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) + '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 = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('GenericResource', response) + deserialized = self._deserialize('GenericResource', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/{resourceId}'} + 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 fa5a6f732743..f9932ae27e8d 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 @@ -1,340 +1,336 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class TagsOperations(object): """TagsOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2019_08_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for this operation. Constant value: "2019-08-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-08-01" - - self.config = config + self._config = config def delete_value( - self, tag_name, tag_value, custom_headers=None, raw=False, **operation_config): + self, + tag_name, # type: str + tag_value, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Deletes a tag value. :param tag_name: The name of the tag. :type tag_name: str :param tag_value: The value of the tag to delete. :type tag_value: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + # Construct URL - url = self.delete_value.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} + delete_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore def create_or_update_value( - self, tag_name, tag_value, custom_headers=None, raw=False, **operation_config): + self, + tag_name, # type: str + tag_value, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.TagValue" """Creates a tag value. The name of the tag must already exist. :param tag_name: The name of the tag. :type tag_name: str :param tag_value: The value of the tag to create. :type tag_value: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: TagValue or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.TagValue or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagValue or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.TagValue + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TagValue"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + # Construct URL - url = self.create_or_update_value.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.put(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 201]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('TagValue', response) + deserialized = self._deserialize('TagValue', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('TagValue', response) + deserialized = self._deserialize('TagValue', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} + create_or_update_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore def create_or_update( - self, tag_name, custom_headers=None, raw=False, **operation_config): - """Creates a tag in the subscription. + self, + tag_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.TagDetails" + """The tag name can have a maximum of 512 characters and is case insensitive. Tag names created by Azure have prefixes of microsoft, azure, or windows. You cannot create tags with one of these prefixes. - The tag name can have a maximum of 512 characters and is case - insensitive. Tag names created by Azure have prefixes of microsoft, - azure, or windows. You cannot create tags with one of these prefixes. + Creates a tag in the subscription. :param tag_name: The name of the tag to create. :type tag_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: TagDetails or ClientRawResponse if raw=true + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagDetails or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_08_01.models.TagDetails - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TagDetails"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + # Construct URL - url = self.create_or_update.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.put(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 201]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('TagDetails', response) + deserialized = self._deserialize('TagDetails', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('TagDetails', response) + deserialized = self._deserialize('TagDetails', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore def delete( - self, tag_name, custom_headers=None, raw=False, **operation_config): - """Deletes a tag from the subscription. + self, + tag_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """You must remove all values from a resource tag before you can delete it. - You must remove all values from a resource tag before you can delete - it. + Deletes a tag from the subscription. :param tag_name: The name of the tag. :type tag_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + # Construct URL - url = self.delete.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} + delete.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore def list( - self, custom_headers=None, raw=False, **operation_config): - """Gets the names and values of all resource tags that are defined in a - subscription. - - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of TagDetails - :rtype: - ~azure.mgmt.resource.resources.v2019_08_01.models.TagDetailsPaged[~azure.mgmt.resource.resources.v2019_08_01.models.TagDetails] - :raises: :class:`CloudError` + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.TagsListResult"] + """Gets the names and values of all resource tags that are defined in a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of TagsListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-08-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['url'] + url = self.list.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('TagsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.TagDetailsPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/py.typed b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file 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 deleted file mode 100644 index b99c58c616c0..000000000000 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_08_01/version.py +++ /dev/null @@ -1,13 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -VERSION = "2019-08-01" - 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 68bc897193ac..fde2ed4c3b83 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 @@ -1,19 +1,16 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._configuration import ResourceManagementClientConfiguration from ._resource_management_client import ResourceManagementClient -__all__ = ['ResourceManagementClient', 'ResourceManagementClientConfiguration'] - -from .version import VERSION - -__version__ = VERSION +__all__ = ['ResourceManagementClient'] +try: + from ._patch import patch_sdk + patch_sdk() +except ImportError: + pass 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 3b326f792363..11e850ae2fd4 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 @@ -1,48 +1,69 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrestazure import AzureConfiguration -from .version import VERSION +from typing import TYPE_CHECKING +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + + from azure.core.credentials import TokenCredential + +VERSION = "unknown" + +class ResourceManagementClientConfiguration(Configuration): + """Configuration for ResourceManagementClient. -class ResourceManagementClientConfiguration(AzureConfiguration): - """Configuration for ResourceManagementClient Note that all parameters used to create this instance are saved as instance attributes. - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` + :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 """ def __init__( - self, credentials, subscription_id, base_url=None): - - if credentials is None: - raise ValueError("Parameter 'credentials' must not be None.") + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + 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.") - if not base_url: - base_url = 'https://management.azure.com' + super(ResourceManagementClientConfiguration, self).__init__(**kwargs) - super(ResourceManagementClientConfiguration, self).__init__(base_url) - - # Starting Autorest.Python 4.0.64, make connection pool activated by default - self.keep_alive = True - - self.add_user_agent('azure-mgmt-resource/{}'.format(VERSION)) - self.add_user_agent('Azure-SDK-For-Python') - - self.credentials = credentials + self.credential = credential self.subscription_id = subscription_id + self.api_version = "2019-10-01" + self.credential_scopes = ['https://management.azure.com/.default'] + self.credential_scopes.extend(kwargs.pop('credential_scopes', [])) + kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + 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) 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 new file mode 100644 index 000000000000..540c0ac61961 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/_metadata.json @@ -0,0 +1,59 @@ +{ + "chosen_version": "2019-10-01", + "total_api_version_list": ["2019-10-01"], + "client": { + "name": "ResourceManagementClient", + "filename": "_resource_management_client", + "description": "Provides operations for working with resources and resource groups." + }, + "global_parameters": { + "sync_method": { + "credential": { + "method_signature": "credential, # type: \"TokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials.TokenCredential", + "required": true + }, + "subscription_id": { + "method_signature": "subscription_id, # type: str", + "description": "The ID of the target subscription.", + "docstring_type": "str", + "required": true + } + }, + "async_method": { + "credential": { + "method_signature": "credential, # type: \"AsyncTokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + }, + "subscription_id": { + "method_signature": "subscription_id, # type: str", + "description": "The ID of the target subscription.", + "docstring_type": "str", + "required": true + } + }, + "constant": { + }, + "call": "credential, subscription_id" + }, + "config": { + "credential": true, + "credential_scopes": ["https://management.azure.com/.default"] + }, + "operation_groups": { + "operations": "Operations", + "deployments": "DeploymentsOperations", + "providers": "ProvidersOperations", + "resources": "ResourcesOperations", + "resource_groups": "ResourceGroupsOperations", + "tags": "TagsOperations", + "deployment_operations": "DeploymentOperationsOperations" + }, + "operation_mixins": { + }, + "sync_imports": "None", + "async_imports": "None" +} \ 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 97da73a86699..41ead22e6f3b 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 @@ -1,16 +1,19 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.service_client import SDKClient -from msrest import Serializer, Deserializer +from typing import TYPE_CHECKING + +from azure.mgmt.core import ARMPipelineClient +from msrest import Deserializer, Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional from ._configuration import ResourceManagementClientConfiguration from .operations import Operations @@ -19,61 +22,76 @@ from .operations import ResourcesOperations from .operations import ResourceGroupsOperations from .operations import TagsOperations -from .operations import DeploymentOperations +from .operations import DeploymentOperationsOperations from . import models -class ResourceManagementClient(SDKClient): +class ResourceManagementClient(object): """Provides operations for working with resources and resource groups. - :ivar config: Configuration for client. - :vartype config: ResourceManagementClientConfiguration - :ivar operations: Operations operations :vartype operations: azure.mgmt.resource.resources.v2019_10_01.operations.Operations - :ivar deployments: Deployments operations + :ivar deployments: DeploymentsOperations operations :vartype deployments: azure.mgmt.resource.resources.v2019_10_01.operations.DeploymentsOperations - :ivar providers: Providers operations + :ivar providers: ProvidersOperations operations :vartype providers: azure.mgmt.resource.resources.v2019_10_01.operations.ProvidersOperations - :ivar resources: Resources operations + :ivar resources: ResourcesOperations operations :vartype resources: azure.mgmt.resource.resources.v2019_10_01.operations.ResourcesOperations - :ivar resource_groups: ResourceGroups operations + :ivar resource_groups: ResourceGroupsOperations operations :vartype resource_groups: azure.mgmt.resource.resources.v2019_10_01.operations.ResourceGroupsOperations - :ivar tags: Tags operations + :ivar tags: TagsOperations operations :vartype tags: azure.mgmt.resource.resources.v2019_10_01.operations.TagsOperations - :ivar deployment_operations: DeploymentOperations operations - :vartype deployment_operations: azure.mgmt.resource.resources.v2019_10_01.operations.DeploymentOperations - - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` + :ivar deployment_operations: DeploymentOperationsOperations operations + :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. """ def __init__( - self, credentials, subscription_id, base_url=None): - - self.config = ResourceManagementClientConfiguration(credentials, subscription_id, base_url) - super(ResourceManagementClient, self).__init__(self.config.credentials, self.config) + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = 'https://management.azure.com' + self._config = ResourceManagementClientConfiguration(credential, 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.api_version = '2019-10-01' self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self.operations = Operations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.deployments = DeploymentsOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.providers = ProvidersOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.resources = ResourcesOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.resource_groups = ResourceGroupsOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.tags = TagsOperations( - self._client, self.config, self._serialize, self._deserialize) - self.deployment_operations = DeploymentOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) + self.deployment_operations = DeploymentOperationsOperations( + self._client, self._config, self._serialize, self._deserialize) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> ResourceManagementClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) 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 new file mode 100644 index 000000000000..7f9b1bac71c5 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/__init__.py @@ -0,0 +1,10 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._resource_management_client_async import ResourceManagementClient +__all__ = ['ResourceManagementClient'] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/_configuration_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/_configuration_async.py new file mode 100644 index 000000000000..65a506db2a7c --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/_configuration_async.py @@ -0,0 +1,65 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + +VERSION = "unknown" + +class ResourceManagementClientConfiguration(Configuration): + """Configuration for ResourceManagementClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :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 + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + 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 + self.api_version = "2019-10-01" + self.credential_scopes = ['https://management.azure.com/.default'] + self.credential_scopes.extend(kwargs.pop('credential_scopes', [])) + kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs: Any + ) -> None: + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + 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) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/_resource_management_client_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/_resource_management_client_async.py new file mode 100644 index 000000000000..0c5f83e4d3f6 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/_resource_management_client_async.py @@ -0,0 +1,89 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, Optional + +from azure.mgmt.core import AsyncARMPipelineClient +from msrest import Deserializer, Serializer + +from ._configuration_async import ResourceManagementClientConfiguration +from .operations_async import Operations +from .operations_async import DeploymentsOperations +from .operations_async import ProvidersOperations +from .operations_async import ResourcesOperations +from .operations_async import ResourceGroupsOperations +from .operations_async import TagsOperations +from .operations_async import DeploymentOperationsOperations +from .. import models + + +class ResourceManagementClient(object): + """Provides operations for working with resources and resource groups. + + :ivar operations: Operations operations + :vartype operations: azure.mgmt.resource.resources.v2019_10_01.aio.operations_async.Operations + :ivar deployments: DeploymentsOperations operations + :vartype deployments: azure.mgmt.resource.resources.v2019_10_01.aio.operations_async.DeploymentsOperations + :ivar providers: ProvidersOperations operations + :vartype providers: azure.mgmt.resource.resources.v2019_10_01.aio.operations_async.ProvidersOperations + :ivar resources: ResourcesOperations operations + :vartype resources: azure.mgmt.resource.resources.v2019_10_01.aio.operations_async.ResourcesOperations + :ivar resource_groups: ResourceGroupsOperations operations + :vartype resource_groups: azure.mgmt.resource.resources.v2019_10_01.aio.operations_async.ResourceGroupsOperations + :ivar tags: TagsOperations operations + :vartype tags: azure.mgmt.resource.resources.v2019_10_01.aio.operations_async.TagsOperations + :ivar deployment_operations: DeploymentOperationsOperations operations + :vartype deployment_operations: azure.mgmt.resource.resources.v2019_10_01.aio.operations_async.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. + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: Optional[str] = None, + **kwargs: 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) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + + self.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 close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "ResourceManagementClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/operations_async/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/operations_async/__init__.py new file mode 100644 index 000000000000..f1fd8637fa69 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/operations_async/__init__.py @@ -0,0 +1,25 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._operations_async import Operations +from ._deployments_operations_async import DeploymentsOperations +from ._providers_operations_async import ProvidersOperations +from ._resources_operations_async import ResourcesOperations +from ._resource_groups_operations_async import ResourceGroupsOperations +from ._tags_operations_async import TagsOperations +from ._deployment_operations_operations_async import DeploymentOperationsOperations + +__all__ = [ + 'Operations', + 'DeploymentsOperations', + 'ProvidersOperations', + 'ResourcesOperations', + 'ResourceGroupsOperations', + 'TagsOperations', + 'DeploymentOperationsOperations', +] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/operations_async/_deployment_operations_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/operations_async/_deployment_operations_operations_async.py new file mode 100644 index 000000000000..82781c290817 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/operations_async/_deployment_operations_operations_async.py @@ -0,0 +1,700 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import 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 ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class DeploymentOperationsOperations: + """DeploymentOperationsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2019_10_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def get_at_scope( + self, + scope: str, + deployment_name: str, + operation_id: str, + **kwargs + ) -> "models.DeploymentOperation": + """Gets a deployments operation. + + :param scope: The resource scope. + :type scope: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param operation_id: The ID of the operation to get. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentOperation or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentOperation + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentOperation"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentOperation', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + def list_at_scope( + self, + scope: str, + deployment_name: str, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.DeploymentOperationsListResult"]: + """Gets all deployments operations for a deployment. + + :param scope: The resource scope. + :type scope: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentOperationsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} # type: ignore + + async def get_at_tenant_scope( + self, + deployment_name: str, + operation_id: str, + **kwargs + ) -> "models.DeploymentOperation": + """Gets a deployments operation. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param operation_id: The ID of the operation to get. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentOperation or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentOperation + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentOperation"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentOperation', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + def list_at_tenant_scope( + self, + deployment_name: str, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.DeploymentOperationsListResult"]: + """Gets all deployments operations for a deployment. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentOperationsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} # type: ignore + + async def get_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + operation_id: str, + **kwargs + ) -> "models.DeploymentOperation": + """Gets a deployments operation. + + :param group_id: The management group ID. + :type group_id: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param operation_id: The ID of the operation to get. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentOperation or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentOperation + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentOperation"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentOperation', pipeline_response) + + if cls: + 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 + + def list_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.DeploymentOperationsListResult"]: + """Gets all deployments operations for a deployment. + + :param group_id: The management group ID. + :type group_id: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentOperationsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + 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 + + async def get_at_subscription_scope( + self, + deployment_name: str, + operation_id: str, + **kwargs + ) -> "models.DeploymentOperation": + """Gets a deployments operation. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param operation_id: The ID of the operation to get. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentOperation or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentOperation + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentOperation"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentOperation', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + def list_at_subscription_scope( + self, + deployment_name: str, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.DeploymentOperationsListResult"]: + """Gets all deployments operations for a deployment. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentOperationsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + 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 + + async def get( + self, + resource_group_name: str, + deployment_name: str, + operation_id: str, + **kwargs + ) -> "models.DeploymentOperation": + """Gets a deployments operation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param operation_id: The ID of the operation to get. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentOperation or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentOperation + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentOperation"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + + # Construct URL + url = self.get.metadata['url'] # type: 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentOperation', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + def list( + self, + resource_group_name: str, + deployment_name: str, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.DeploymentOperationsListResult"]: + """Gets all deployments operations for a deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentOperationsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/operations_async/_deployments_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/operations_async/_deployments_operations_async.py new file mode 100644 index 000000000000..758cf8e988ac --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/operations_async/_deployments_operations_async.py @@ -0,0 +1,3238 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.polling import AsyncNoPolling, AsyncPollingMethod, async_poller +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class DeploymentsOperations: + """DeploymentsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2019_10_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def _delete_at_scope_initial( + self, + scope: str, + deployment_name: str, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + + # 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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_at_scope_initial.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def delete_at_scope( + self, + scope: str, + deployment_name: str, + **kwargs + ) -> None: + """A template deployment that is currently running cannot be deleted. Deleting a template deployment removes the associated deployment operations. This is an asynchronous operation that returns a status of 202 until the template deployment is successfully deleted. The Location response header contains the URI that is used to obtain the status of the process. While the process is running, a call to the URI in the Location header returns a status of 202. When the process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. + + Deletes a deployment from the deployment history. + + :param scope: The resource scope. + :type scope: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._delete_at_scope_initial( + scope=scope, + deployment_name=deployment_name, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + delete_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def check_existence_at_scope( + self, + scope: str, + deployment_name: str, + **kwargs + ) -> None: + """Checks whether the deployment exists. + + :param scope: The resource scope. + :type scope: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + + # 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] + + # Construct and send request + 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 + + if response.status_code not in [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + 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, + deployment_name: str, + parameters: "models.Deployment", + **kwargs + ) -> "models.DeploymentExtended": + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_at_scope_initial.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def create_or_update_at_scope( + self, + scope: str, + deployment_name: str, + parameters: "models.Deployment", + **kwargs + ) -> "models.DeploymentExtended": + """You can provide the template and parameters directly in the request or link to JSON files. + + Deploys resources at a given scope. + + :param scope: The resource scope. + :type scope: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. + :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 polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: DeploymentExtended + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._create_or_update_at_scope_initial( + scope=scope, + deployment_name=deployment_name, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + create_or_update_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def get_at_scope( + self, + scope: str, + deployment_name: str, + **kwargs + ) -> "models.DeploymentExtended": + """Gets a deployment. + + :param scope: The resource scope. + :type scope: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExtended or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def cancel_at_scope( + self, + scope: str, + deployment_name: str, + **kwargs + ) -> None: + """You can cancel a deployment only if the provisioningState is Accepted or Running. After the deployment is canceled, the provisioningState is set to Canceled. Canceling a template deployment stops the currently running template deployment and leaves the resources partially deployed. + + Cancels a currently running template deployment. + + :param scope: The resource scope. + :type scope: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + + # 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] + + # Construct and send request + 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 [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + cancel_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + + async def _validate_at_scope_initial( + self, + scope: str, + deployment_name: str, + parameters: "models.Deployment", + **kwargs + ) -> "models.DeploymentValidateResult": + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentValidateResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + content_type = kwargs.pop("content_type", "application/json") + + # Construct URL + url = self._validate_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['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 202, 400]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + + if response.status_code == 400: + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _validate_at_scope_initial.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + async def validate_at_scope( + self, + scope: str, + deployment_name: str, + parameters: "models.Deployment", + **kwargs + ) -> "models.DeploymentValidateResult": + """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. + + :param scope: The resource scope. + :type scope: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param parameters: Parameters to 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 polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: DeploymentValidateResult + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentValidateResult"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._validate_at_scope_initial( + scope=scope, + deployment_name=deployment_name, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + validate_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + async def export_template_at_scope( + self, + scope: str, + deployment_name: str, + **kwargs + ) -> "models.DeploymentExportResult": + """Exports the template used for specified deployment. + + :param scope: The resource scope. + :type scope: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExportResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExportResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + + # 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'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + export_template_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + def list_at_scope( + self, + scope: str, + filter: Optional[str] = None, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.DeploymentListResult"]: + """Get all the deployments at the given scope. + + :param scope: The resource scope. + :type scope: str + :param filter: The filter to apply on the operation. For example, you can use + $filter=provisioningState eq '{state}'. + :type filter: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/'} # type: ignore + + async def _delete_at_tenant_scope_initial( + self, + deployment_name: str, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + + # 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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_at_tenant_scope_initial.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def delete_at_tenant_scope( + self, + deployment_name: str, + **kwargs + ) -> None: + """A template deployment that is currently running cannot be deleted. Deleting a template deployment removes the associated deployment operations. This is an asynchronous operation that returns a status of 202 until the template deployment is successfully deleted. The Location response header contains the URI that is used to obtain the status of the process. While the process is running, a call to the URI in the Location header returns a status of 202. When the process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. + + Deletes a deployment from the deployment history. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._delete_at_tenant_scope_initial( + deployment_name=deployment_name, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + delete_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def check_existence_at_tenant_scope( + self, + deployment_name: str, + **kwargs + ) -> None: + """Checks whether the deployment exists. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + + # 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] + + # Construct and send request + 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 + + if response.status_code not in [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + 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, + parameters: "models.ScopedDeployment", + **kwargs + ) -> "models.DeploymentExtended": + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_at_tenant_scope_initial.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def create_or_update_at_tenant_scope( + self, + deployment_name: str, + parameters: "models.ScopedDeployment", + **kwargs + ) -> "models.DeploymentExtended": + """You can provide the template and parameters directly in the request or link to JSON files. + + Deploys resources at tenant scope. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. + :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 polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: DeploymentExtended + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._create_or_update_at_tenant_scope_initial( + deployment_name=deployment_name, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + create_or_update_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def get_at_tenant_scope( + self, + deployment_name: str, + **kwargs + ) -> "models.DeploymentExtended": + """Gets a deployment. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExtended or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def cancel_at_tenant_scope( + self, + deployment_name: str, + **kwargs + ) -> None: + """You can cancel a deployment only if the provisioningState is Accepted or Running. After the deployment is canceled, the provisioningState is set to Canceled. Canceling a template deployment stops the currently running template deployment and leaves the resources partially deployed. + + Cancels a currently running template deployment. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + + # 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] + + # Construct and send request + 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 [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + 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, + parameters: "models.ScopedDeployment", + **kwargs + ) -> "models.DeploymentValidateResult": + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentValidateResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 202, 400]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + + if response.status_code == 400: + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _validate_at_tenant_scope_initial.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + async def validate_at_tenant_scope( + self, + deployment_name: str, + parameters: "models.ScopedDeployment", + **kwargs + ) -> "models.DeploymentValidateResult": + """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param parameters: Parameters to validate. + :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 polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: DeploymentValidateResult + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentValidateResult"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._validate_at_tenant_scope_initial( + deployment_name=deployment_name, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + validate_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + async def export_template_at_tenant_scope( + self, + deployment_name: str, + **kwargs + ) -> "models.DeploymentExportResult": + """Exports the template used for specified deployment. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExportResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExportResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + + # 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'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + export_template_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + def list_at_tenant_scope( + self, + filter: Optional[str] = None, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.DeploymentListResult"]: + """Get all the deployments at the tenant scope. + + :param filter: The filter to apply on the operation. For example, you can use + $filter=provisioningState eq '{state}'. + :type filter: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/'} # type: ignore + + async def _delete_at_management_group_scope_initial( + self, + group_id: str, + deployment_name: str, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_at_management_group_scope_initial.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def delete_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + **kwargs + ) -> None: + """A template deployment that is currently running cannot be deleted. Deleting a template deployment removes the associated deployment operations. This is an asynchronous operation that returns a status of 202 until the template deployment is successfully deleted. The Location response header contains the URI that is used to obtain the status of the process. While the process is running, a call to the URI in the Location header returns a status of 202. When the process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. + + Deletes a deployment from the deployment history. + + :param group_id: The management group ID. + :type group_id: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._delete_at_management_group_scope_initial( + group_id=group_id, + deployment_name=deployment_name, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + delete_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def check_existence_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + **kwargs + ) -> None: + """Checks whether the deployment exists. + + :param group_id: The management group ID. + :type group_id: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-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] + + # Construct and send request + 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 + + if response.status_code not in [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + 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, + deployment_name: str, + parameters: "models.ScopedDeployment", + **kwargs + ) -> "models.DeploymentExtended": + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + 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 + + async def create_or_update_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + parameters: "models.ScopedDeployment", + **kwargs + ) -> "models.DeploymentExtended": + """You can provide the template and parameters directly in the request or link to JSON files. + + Deploys resources at management group scope. + + :param group_id: The management group ID. + :type group_id: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. + :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 polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: DeploymentExtended + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._create_or_update_at_management_group_scope_initial( + group_id=group_id, + deployment_name=deployment_name, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + create_or_update_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def get_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + **kwargs + ) -> "models.DeploymentExtended": + """Gets a deployment. + + :param group_id: The management group ID. + :type group_id: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExtended or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + 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 + + async def cancel_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + **kwargs + ) -> None: + """You can cancel a deployment only if the provisioningState is Accepted or Running. After the deployment is canceled, the provisioningState is set to Canceled. Canceling a template deployment stops the currently running template deployment and leaves the resources partially deployed. + + Cancels a currently running template deployment. + + :param group_id: The management group ID. + :type group_id: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-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] + + # Construct and send request + 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 [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + 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, + deployment_name: str, + parameters: "models.ScopedDeployment", + **kwargs + ) -> "models.DeploymentValidateResult": + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentValidateResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 202, 400]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + + if response.status_code == 400: + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + + if cls: + 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 + + async def validate_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + parameters: "models.ScopedDeployment", + **kwargs + ) -> "models.DeploymentValidateResult": + """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. + + :param group_id: The management group ID. + :type group_id: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param parameters: Parameters to validate. + :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 polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: DeploymentValidateResult + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentValidateResult"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._validate_at_management_group_scope_initial( + group_id=group_id, + deployment_name=deployment_name, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + validate_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + async def export_template_at_management_group_scope( + self, + group_id: str, + deployment_name: str, + **kwargs + ) -> "models.DeploymentExportResult": + """Exports the template used for specified deployment. + + :param group_id: The management group ID. + :type group_id: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExportResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExportResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + + # 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'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + + if cls: + 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 + + def list_at_management_group_scope( + self, + group_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.DeploymentListResult"]: + """Get all the deployments for a management group. + + :param group_id: The management group ID. + :type group_id: str + :param filter: The filter to apply on the operation. For example, you can use + $filter=provisioningState eq '{state}'. + :type filter: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + 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/'} # type: ignore + + async def _delete_at_subscription_scope_initial( + self, + deployment_name: str, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def delete_at_subscription_scope( + self, + deployment_name: str, + **kwargs + ) -> None: + """A template deployment that is currently running cannot be deleted. Deleting a template deployment removes the associated deployment operations. This is an asynchronous operation that returns a status of 202 until the template deployment is successfully deleted. The Location response header contains the URI that is used to obtain the status of the process. While the process is running, a call to the URI in the Location header returns a status of 202. When the process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. + + Deletes a deployment from the deployment history. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._delete_at_subscription_scope_initial( + deployment_name=deployment_name, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + delete_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def check_existence_at_subscription_scope( + self, + deployment_name: str, + **kwargs + ) -> None: + """Checks whether the deployment exists. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-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] + + # Construct and send request + 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 + + if response.status_code not in [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + 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, + parameters: "models.Deployment", + **kwargs + ) -> "models.DeploymentExtended": + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + 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 + + async def create_or_update_at_subscription_scope( + self, + deployment_name: str, + parameters: "models.Deployment", + **kwargs + ) -> "models.DeploymentExtended": + """You can provide the template and parameters directly in the request or link to JSON files. + + Deploys resources at subscription scope. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. + :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 polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: DeploymentExtended + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._create_or_update_at_subscription_scope_initial( + deployment_name=deployment_name, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + create_or_update_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def get_at_subscription_scope( + self, + deployment_name: str, + **kwargs + ) -> "models.DeploymentExtended": + """Gets a deployment. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExtended or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def cancel_at_subscription_scope( + self, + deployment_name: str, + **kwargs + ) -> None: + """You can cancel a deployment only if the provisioningState is Accepted or Running. After the deployment is canceled, the provisioningState is set to Canceled. Canceling a template deployment stops the currently running template deployment and leaves the resources partially deployed. + + Cancels a currently running template deployment. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-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] + + # Construct and send request + 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 [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + 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, + parameters: "models.Deployment", + **kwargs + ) -> "models.DeploymentValidateResult": + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentValidateResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 202, 400]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + + if response.status_code == 400: + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _validate_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + async def validate_at_subscription_scope( + self, + deployment_name: str, + parameters: "models.Deployment", + **kwargs + ) -> "models.DeploymentValidateResult": + """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param parameters: Parameters to 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 polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: DeploymentValidateResult + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentValidateResult"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._validate_at_subscription_scope_initial( + deployment_name=deployment_name, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + 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, + properties: "models.DeploymentWhatIfProperties", + location: Optional[str] = None, + **kwargs + ) -> "models.WhatIfOperationResult": + cls = kwargs.pop('cls', None) # type: ClsType["models.WhatIfOperationResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.DeploymentWhatIf(location=location, properties=properties) + api_version = "2019-10-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + deserialized = None + 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 + + async def what_if_at_subscription_scope( + self, + deployment_name: str, + properties: "models.DeploymentWhatIfProperties", + location: Optional[str] = None, + **kwargs + ) -> "models.WhatIfOperationResult": + """Returns changes that will be made by the deployment if executed at the scope of the subscription. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param properties: The deployment properties. + :type properties: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentWhatIfProperties + :param location: The location to store the deployment data. + :type location: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: WhatIfOperationResult + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.WhatIfOperationResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.WhatIfOperationResult"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._what_if_at_subscription_scope_initial( + deployment_name=deployment_name, + properties=properties, + location=location, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + 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 + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + what_if_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + + async def export_template_at_subscription_scope( + self, + deployment_name: str, + **kwargs + ) -> "models.DeploymentExportResult": + """Exports the template used for specified deployment. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExportResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExportResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + + # 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'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + export_template_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + def list_at_subscription_scope( + self, + filter: Optional[str] = None, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.DeploymentListResult"]: + """Get all the deployments for a subscription. + + :param filter: The filter to apply on the operation. For example, you can use + $filter=provisioningState eq '{state}'. + :type filter: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/'} # type: ignore + + async def _delete_initial( + self, + resource_group_name: str, + deployment_name: str, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def delete( + self, + resource_group_name: str, + deployment_name: str, + **kwargs + ) -> None: + """A template deployment that is currently running cannot be deleted. Deleting a template deployment removes the associated deployment operations. Deleting a template deployment does not affect the state of the resource group. This is an asynchronous operation that returns a status of 202 until the template deployment is successfully deleted. The Location response header contains the URI that is used to obtain the status of the process. While the process is running, a call to the URI in the Location header returns a status of 202. When the process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. + + Deletes a deployment from the deployment history. + + :param resource_group_name: The name of the resource group with the deployment to delete. The + name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def check_existence( + self, + resource_group_name: str, + deployment_name: str, + **kwargs + ) -> None: + """Checks whether the deployment exists. + + :param resource_group_name: The name of the resource group with the deployment to check. The + name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-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] + + # Construct and send request + 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 + + if response.status_code not in [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + 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, + deployment_name: str, + parameters: "models.Deployment", + **kwargs + ) -> "models.DeploymentExtended": + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def create_or_update( + self, + resource_group_name: str, + deployment_name: str, + parameters: "models.Deployment", + **kwargs + ) -> "models.DeploymentExtended": + """You can provide the template and parameters directly in the request or link to JSON files. + + Deploys resources to a resource group. + + :param resource_group_name: The name of the resource group to deploy the resources to. The name + is case insensitive. The resource group must already exist. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param parameters: Additional parameters supplied to the operation. + :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 polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: DeploymentExtended + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def get( + self, + resource_group_name: str, + deployment_name: str, + **kwargs + ) -> "models.DeploymentExtended": + """Gets a deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExtended or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + + # Construct URL + url = self.get.metadata['url'] # type: 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + async def cancel( + self, + resource_group_name: str, + deployment_name: str, + **kwargs + ) -> None: + """You can cancel a deployment only if the provisioningState is Accepted or Running. After the deployment is canceled, the provisioningState is set to Canceled. Canceling a template deployment stops the currently running template deployment and leaves the resource group partially deployed. + + Cancels a currently running template deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-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] + + # Construct and send request + 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 [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + cancel.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + + async def _validate_initial( + self, + resource_group_name: str, + deployment_name: str, + parameters: "models.Deployment", + **kwargs + ) -> "models.DeploymentValidateResult": + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentValidateResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 202, 400]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + + if response.status_code == 400: + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _validate_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + async def validate( + self, + resource_group_name: str, + deployment_name: str, + parameters: "models.Deployment", + **kwargs + ) -> "models.DeploymentValidateResult": + """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param parameters: Parameters to 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 polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: DeploymentValidateResult + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentValidateResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentValidateResult"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._validate_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + 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, + deployment_name: str, + properties: "models.DeploymentWhatIfProperties", + location: Optional[str] = None, + **kwargs + ) -> "models.WhatIfOperationResult": + cls = kwargs.pop('cls', None) # type: ClsType["models.WhatIfOperationResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.DeploymentWhatIf(location=location, properties=properties) + api_version = "2019-10-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + deserialized = None + 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 + + async def what_if( + self, + resource_group_name: str, + deployment_name: str, + properties: "models.DeploymentWhatIfProperties", + location: Optional[str] = None, + **kwargs + ) -> "models.WhatIfOperationResult": + """Returns changes that will be made by the deployment if executed at the scope of the resource group. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param properties: The deployment properties. + :type properties: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentWhatIfProperties + :param location: The location to store the deployment data. + :type location: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: WhatIfOperationResult + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.WhatIfOperationResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.WhatIfOperationResult"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._what_if_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + properties=properties, + location=location, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + 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 + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + what_if.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + + async def export_template( + self, + resource_group_name: str, + deployment_name: str, + **kwargs + ) -> "models.DeploymentExportResult": + """Exports the template used for specified deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExportResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExportResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + + # 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'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentExportResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore + + def list_by_resource_group( + self, + resource_group_name: str, + filter: Optional[str] = None, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.DeploymentListResult"]: + """Get all the deployments for a resource group. + + :param resource_group_name: The name of the resource group with the deployments to get. The + name is case insensitive. + :type resource_group_name: str + :param filter: The filter to apply on the operation. For example, you can use + $filter=provisioningState eq '{state}'. + :type filter: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + 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 + + async def calculate_template_hash( + self, + template: object, + **kwargs + ) -> "models.TemplateHashResult": + """Calculate the hash of the given template. + + :param template: The template provided to calculate hash. + :type template: object + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateHashResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.TemplateHashResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TemplateHashResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + content_type = kwargs.pop("content_type", "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'] = 'application/json' + + # Construct and send request + 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) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('TemplateHashResult', pipeline_response) + + if cls: + 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_async/_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/operations_async/_operations_async.py new file mode 100644 index 000000000000..c129d59bd6cc --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/operations_async/_operations_async.py @@ -0,0 +1,101 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import 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 ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class Operations: + """Operations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2019_10_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + **kwargs + ) -> AsyncIterable["models.OperationListResult"]: + """Lists all of the available Microsoft.Resources REST API operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of OperationListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('OperationListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.Resources/operations'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/operations_async/_providers_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/operations_async/_providers_operations_async.py new file mode 100644 index 000000000000..ae5c5f92d48f --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/operations_async/_providers_operations_async.py @@ -0,0 +1,407 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import 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 ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ProvidersOperations: + """ProvidersOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2019_10_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def unregister( + self, + resource_provider_namespace: str, + **kwargs + ) -> "models.Provider": + """Unregisters a subscription from a resource provider. + + :param resource_provider_namespace: The namespace of the resource provider to unregister. + :type resource_provider_namespace: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Provider or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.Provider + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Provider"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + + # 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'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Provider', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + unregister.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister'} # type: ignore + + async def register( + self, + resource_provider_namespace: str, + **kwargs + ) -> "models.Provider": + """Registers a subscription with a resource provider. + + :param resource_provider_namespace: The namespace of the resource provider to register. + :type resource_provider_namespace: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Provider or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.Provider + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Provider"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + + # 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'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Provider', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + register.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register'} # type: ignore + + def list( + self, + top: Optional[int] = None, + expand: Optional[str] = None, + **kwargs + ) -> AsyncIterable["models.ProviderListResult"]: + """Gets all resource providers for a subscription. + + :param top: The number of results to return. If null is passed returns all deployments. + :type top: int + :param expand: The properties to include in the results. For example, use &$expand=metadata in + the query string to retrieve resource provider metadata. To include property aliases in + response, use $expand=resourceTypes/aliases. + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of ProviderListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ProviderListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers'} # type: ignore + + def list_at_tenant_scope( + self, + top: Optional[int] = None, + expand: Optional[str] = None, + **kwargs + ) -> AsyncIterable["models.ProviderListResult"]: + """Gets all resource providers for the tenant. + + :param top: The number of results to return. If null is passed returns all providers. + :type top: int + :param expand: The properties to include in the results. For example, use &$expand=metadata in + the query string to retrieve resource provider metadata. To include property aliases in + response, use $expand=resourceTypes/aliases. + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of ProviderListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ProviderListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_at_tenant_scope.metadata = {'url': '/providers'} # type: ignore + + async def get( + self, + resource_provider_namespace: str, + expand: Optional[str] = None, + **kwargs + ) -> "models.Provider": + """Gets the specified resource provider. + + :param resource_provider_namespace: The namespace of the resource provider. + :type resource_provider_namespace: str + :param expand: The $expand query parameter. For example, to include property aliases in + response, use $expand=resourceTypes/aliases. + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Provider or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.Provider + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Provider"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Provider', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}'} # type: ignore + + async def get_at_tenant_scope( + self, + resource_provider_namespace: str, + expand: Optional[str] = None, + **kwargs + ) -> "models.Provider": + """Gets the specified resource provider at the tenant level. + + :param resource_provider_namespace: The namespace of the resource provider. + :type resource_provider_namespace: str + :param expand: The $expand query parameter. For example, to include property aliases in + response, use $expand=resourceTypes/aliases. + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Provider or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.Provider + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Provider"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Provider', pipeline_response) + + if cls: + 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_async/_resource_groups_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/operations_async/_resource_groups_operations_async.py new file mode 100644 index 000000000000..cdacd0dca9d7 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/operations_async/_resource_groups_operations_async.py @@ -0,0 +1,545 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, List, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.polling import AsyncNoPolling, AsyncPollingMethod, async_poller +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ResourceGroupsOperations: + """ResourceGroupsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2019_10_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def check_existence( + self, + resource_group_name: str, + **kwargs + ) -> None: + """Checks whether a resource group exists. + + :param resource_group_name: The name of the resource group to check. 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: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-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] + + # Construct and send request + 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 + + if response.status_code not in [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + async def create_or_update( + self, + resource_group_name: str, + parameters: "models.ResourceGroup", + **kwargs + ) -> "models.ResourceGroup": + """Creates or updates a resource group. + + :param resource_group_name: The name of the resource group to create or update. Can include + alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters + that match the allowed characters. + :type resource_group_name: str + :param parameters: Parameters supplied to the create or update a resource group. + :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.ResourceGroup + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.ResourceGroup + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceGroup"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ResourceGroup', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ResourceGroup', pipeline_response) + + if cls: + 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, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-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] + + # Construct and send request + 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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + async def delete( + self, + resource_group_name: str, + **kwargs + ) -> None: + """When you delete a resource group, all of its resources are also deleted. Deleting a resource group deletes all of its template deployments and currently stored operations. + + Deletes a resource group. + + :param resource_group_name: The name of the resource group to delete. 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 + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + async def get( + self, + resource_group_name: str, + **kwargs + ) -> "models.ResourceGroup": + """Gets a resource group. + + :param resource_group_name: The name of the resource group to get. 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: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.ResourceGroup + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceGroup"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + + # Construct URL + url = self.get.metadata['url'] # type: 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ResourceGroup', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore + + async def update( + self, + resource_group_name: str, + parameters: "models.ResourceGroupPatchable", + **kwargs + ) -> "models.ResourceGroup": + """Resource groups can be updated through a simple PATCH operation to a group address. The format of the request is the same as that for creating a resource group. If a field is unspecified, the current value is retained. + + Updates a resource group. + + :param resource_group_name: The name of the resource group to update. The name is case + insensitive. + :type resource_group_name: str + :param parameters: Parameters supplied to update a resource group. + :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.ResourceGroupPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.ResourceGroup + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceGroup"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + content_type = kwargs.pop("content_type", "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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ResourceGroup', pipeline_response) + + if cls: + 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, + resources: Optional[List[str]] = None, + options: Optional[str] = None, + **kwargs + ) -> "models.ResourceGroupExportResult": + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceGroupExportResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.ExportTemplateRequest(resources=resources, options=options) + api_version = "2019-10-01" + content_type = kwargs.pop("content_type", "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, pattern=r'^[-\w\._\(\)]+$'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ResourceGroupExportResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _export_template_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate'} # type: ignore + + async def export_template( + self, + resource_group_name: str, + resources: Optional[List[str]] = None, + options: Optional[str] = None, + **kwargs + ) -> "models.ResourceGroupExportResult": + """Captures the specified resource group as a template. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param 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', + 'SkipResourceNameParameterization', 'SkipAllParameterization'. + :type options: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: ResourceGroupExportResult + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.ResourceGroupExportResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceGroupExportResult"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._export_template_initial( + resource_group_name=resource_group_name, + resources=resources, + options=options, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ResourceGroupExportResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + 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 + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate'} # type: ignore + + def list( + self, + filter: Optional[str] = None, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.ResourceGroupListResult"]: + """Gets all the resource groups for a subscription. + + :param filter: The filter to apply on the operation.:code:`
`:code:`
`You can filter by + tag names and values. For example, to filter for a tag name and value, use $filter=tagName eq + 'tag1' and tagValue eq 'Value1'. + :type filter: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ResourceGroupListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/operations_async/_resources_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/operations_async/_resources_operations_async.py new file mode 100644 index 000000000000..9b26b4488712 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/operations_async/_resources_operations_async.py @@ -0,0 +1,1342 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, List, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.polling import AsyncNoPolling, AsyncPollingMethod, async_poller +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ResourcesOperations: + """ResourcesOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2019_10_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list_by_resource_group( + self, + resource_group_name: str, + filter: Optional[str] = None, + expand: Optional[str] = None, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.ResourceListResult"]: + """Get all the resources for a resource group. + + :param resource_group_name: The resource group with the resources to get. + :type resource_group_name: str + :param filter: The filter to apply on the operation.:code:`
`:code:`
`The properties you + can use for eq (equals) or ne (not equals) are: location, resourceType, name, resourceGroup, + identity, identity/principalId, plan, plan/publisher, plan/product, plan/name, plan/version, + and plan/promotionCode.:code:`
`:code:`
`For example, to filter by a resource type, use: + $filter=resourceType eq 'Microsoft.Network/virtualNetworks':code:`
`:code:`
`You can use + substringof(value, property) in the filter. The properties you can use for substring are: name + and resourceGroup.:code:`
`:code:`
`For example, to get all resources with 'demo' + anywhere in the name, use: $filter=substringof('demo', name):code:`
`:code:`
`You can + link more than one substringof together by adding and/or operators.:code:`
`:code:`
`You + can filter by tag names and values. For example, to filter for a tag name and value, use + $filter=tagName eq 'tag1' and tagValue eq 'Value1'. When you filter by a tag name and value, + the tags for each resource are not returned in the results.:code:`
`:code:`
`You can use + some properties together when filtering. The combinations you can use are: substringof and/or + resourceType, plan and plan/publisher and plan/name, identity and identity/principalId. + :type filter: str + :param expand: Comma-separated list of additional properties to be included in the response. + Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, + ``$expand=createdTime,changedTime``. + :type expand: str + :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 ResourceListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ResourceListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources'} # type: ignore + + async def _move_resources_initial( + self, + source_resource_group_name: str, + resources: Optional[List[str]] = None, + target_resource_group: Optional[str] = None, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.ResourcesMoveInfo(resources=resources, target_resource_group=target_resource_group) + api_version = "2019-10-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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + + # Construct and send request + 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 + + if response.status_code not in [202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore + + async def move_resources( + self, + source_resource_group_name: str, + resources: Optional[List[str]] = None, + target_resource_group: Optional[str] = None, + **kwargs + ) -> None: + """The resources to move must be in the same source resource group. The target resource group may be in a different subscription. When moving resources, both the source group and the target group are locked for the duration of the operation. Write and delete operations are blocked on the groups until the move completes. + + Moves resources from one resource group to another resource group. + + :param source_resource_group_name: The name of the resource group containing the resources to + move. + :type source_resource_group_name: str + :param resources: The IDs of the resources. + :type resources: list[str] + :param target_resource_group: The target resource group. + :type target_resource_group: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._move_resources_initial( + source_resource_group_name=source_resource_group_name, + resources=resources, + target_resource_group=target_resource_group, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore + + async def _validate_move_resources_initial( + self, + source_resource_group_name: str, + resources: Optional[List[str]] = None, + target_resource_group: Optional[str] = None, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.ResourcesMoveInfo(resources=resources, target_resource_group=target_resource_group) + api_version = "2019-10-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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + + # Construct and send request + 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 + + if response.status_code not in [202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _validate_move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} # type: ignore + + async def validate_move_resources( + self, + source_resource_group_name: str, + resources: Optional[List[str]] = None, + target_resource_group: Optional[str] = None, + **kwargs + ) -> None: + """This operation checks whether the specified resources can be moved to the target. The resources to move must be in the same source resource group. The target resource group may be in a different subscription. If validation succeeds, it returns HTTP response code 204 (no content). If validation fails, it returns HTTP response code 409 (Conflict) with an error message. Retrieve the URL in the Location header value to check the result of the long-running operation. + + Validates whether resources can be moved from one resource group to another resource group. + + :param source_resource_group_name: The name of the resource group containing the resources to + validate for move. + :type source_resource_group_name: str + :param resources: The IDs of the resources. + :type resources: list[str] + :param target_resource_group: The target resource group. + :type target_resource_group: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._validate_move_resources_initial( + source_resource_group_name=source_resource_group_name, + resources=resources, + target_resource_group=target_resource_group, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + validate_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} # type: ignore + + def list( + self, + filter: Optional[str] = None, + expand: Optional[str] = None, + top: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.ResourceListResult"]: + """Get all the resources in a subscription. + + :param filter: The filter to apply on the operation.:code:`
`:code:`
`The properties you + can use for eq (equals) or ne (not equals) are: location, resourceType, name, resourceGroup, + identity, identity/principalId, plan, plan/publisher, plan/product, plan/name, plan/version, + and plan/promotionCode.:code:`
`:code:`
`For example, to filter by a resource type, use: + $filter=resourceType eq 'Microsoft.Network/virtualNetworks':code:`
`:code:`
`You can use + substringof(value, property) in the filter. The properties you can use for substring are: name + and resourceGroup.:code:`
`:code:`
`For example, to get all resources with 'demo' + anywhere in the name, use: $filter=substringof('demo', name):code:`
`:code:`
`You can + link more than one substringof together by adding and/or operators.:code:`
`:code:`
`You + can filter by tag names and values. For example, to filter for a tag name and value, use + $filter=tagName eq 'tag1' and tagValue eq 'Value1'. When you filter by a tag name and value, + the tags for each resource are not returned in the results.:code:`
`:code:`
`You can use + some properties together when filtering. The combinations you can use are: substringof and/or + resourceType, plan and plan/publisher and plan/name, identity and identity/principalId. + :type filter: str + :param expand: Comma-separated list of additional properties to be included in the response. + Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, + ``$expand=createdTime,changedTime``. + :type expand: str + :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 ResourceListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ResourceListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resources'} # type: ignore + + async def check_existence( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + **kwargs + ) -> None: + """Checks whether a resource exists. + + :param resource_group_name: The name of the resource group containing the resource to check. + The name is case insensitive. + :type resource_group_name: str + :param resource_provider_namespace: The resource provider of the resource to check. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. + :type parent_resource_path: str + :param resource_type: The resource type. + :type resource_type: str + :param resource_name: The name of the resource to check whether it exists. + :type resource_name: str + :param api_version: The API version to use for the operation. + :type api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + 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] + + # Construct and send request + 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 + + if response.status_code not in [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + 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, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + 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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + async def delete( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + **kwargs + ) -> None: + """Deletes a resource. + + :param resource_group_name: The name of the resource group that contains the resource to + delete. The name is case insensitive. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. + :type parent_resource_path: str + :param resource_type: The resource type. + :type resource_type: str + :param resource_name: The name of the resource to delete. + :type resource_name: str + :param api_version: The API version to use for the operation. + :type api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._delete_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, + api_version=api_version, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: "models.GenericResource", + **kwargs + ) -> "models.GenericResource": + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + content_type = kwargs.pop("content_type", "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'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 201, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('GenericResource', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + async def create_or_update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: "models.GenericResource", + **kwargs + ) -> "models.GenericResource": + """Creates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to create. + :type resource_type: str + :param resource_name: The name of the resource to create. + :type resource_name: str + :param api_version: The API version to use for the operation. + :type api_version: str + :param parameters: Parameters for creating or updating the resource. + :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 polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: GenericResource + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._create_or_update_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, + api_version=api_version, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + 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, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: "models.GenericResource", + **kwargs + ) -> "models.GenericResource": + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + content_type = kwargs.pop("content_type", "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'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + async def update( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + parameters: "models.GenericResource", + **kwargs + ) -> "models.GenericResource": + """Updates a resource. + + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. + :type parent_resource_path: str + :param resource_type: The resource type of the resource to update. + :type resource_type: str + :param resource_name: The name of the resource to update. + :type resource_name: str + :param api_version: The API version to use for the operation. + :type api_version: str + :param parameters: Parameters for updating the resource. + :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 polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: GenericResource + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._update_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, + api_version=api_version, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + async def get( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + api_version: str, + **kwargs + ) -> "models.GenericResource": + """Gets a resource. + + :param resource_group_name: The name of the resource group containing the resource to get. The + name is case insensitive. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. + :type resource_provider_namespace: str + :param parent_resource_path: The parent resource identity. + :type parent_resource_path: str + :param resource_type: The resource type of the resource. + :type resource_type: str + :param resource_name: The name of the resource to get. + :type resource_name: str + :param api_version: The API version to use for the operation. + :type api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GenericResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + # Construct URL + url = self.get.metadata['url'] # type: 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + async def check_existence_by_id( + self, + resource_id: str, + api_version: str, + **kwargs + ) -> None: + """Checks by ID whether a resource exists. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + :type resource_id: str + :param api_version: The API version to use for the operation. + :type api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + 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] + + # Construct and send request + 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 + + if response.status_code not in [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + 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, + api_version: str, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + 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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + async def delete_by_id( + self, + resource_id: str, + api_version: str, + **kwargs + ) -> None: + """Deletes a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + :type resource_id: str + :param api_version: The API version to use for the operation. + :type api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._delete_by_id_initial( + resource_id=resource_id, + api_version=api_version, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + delete_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + + async def _create_or_update_by_id_initial( + self, + resource_id: str, + api_version: str, + parameters: "models.GenericResource", + **kwargs + ) -> "models.GenericResource": + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + content_type = kwargs.pop("content_type", "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) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 201, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('GenericResource', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + async def create_or_update_by_id( + self, + resource_id: str, + api_version: str, + parameters: "models.GenericResource", + **kwargs + ) -> "models.GenericResource": + """Create a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + :type resource_id: str + :param api_version: The API version to use for the operation. + :type api_version: str + :param parameters: Create or update resource parameters. + :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 polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: GenericResource + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._create_or_update_by_id_initial( + resource_id=resource_id, + api_version=api_version, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + create_or_update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + + async def _update_by_id_initial( + self, + resource_id: str, + api_version: str, + parameters: "models.GenericResource", + **kwargs + ) -> "models.GenericResource": + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + content_type = kwargs.pop("content_type", "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) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + async def update_by_id( + self, + resource_id: str, + api_version: str, + parameters: "models.GenericResource", + **kwargs + ) -> "models.GenericResource": + """Updates a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + :type resource_id: str + :param api_version: The API version to use for the operation. + :type api_version: str + :param parameters: Update resource parameters. + :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 polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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: GenericResource + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._update_by_id_initial( + resource_id=resource_id, + api_version=api_version, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore + + async def get_by_id( + self, + resource_id: str, + api_version: str, + **kwargs + ) -> "models.GenericResource": + """Gets a resource by ID. + + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. + :type resource_id: str + :param api_version: The API version to use for the operation. + :type api_version: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GenericResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('GenericResource', pipeline_response) + + if cls: + 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_async/_tags_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/operations_async/_tags_operations_async.py new file mode 100644 index 000000000000..5ba799719c7a --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/aio/operations_async/_tags_operations_async.py @@ -0,0 +1,566 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import 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 ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class TagsOperations: + """TagsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2019_10_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def delete_value( + self, + tag_name: str, + tag_value: str, + **kwargs + ) -> None: + """This operation allows deleting a value from the list of predefined values for an existing predefined tag name. The value being deleted must not be in use as a tag value for the given tag name for any resource. + + Deletes a predefined tag value for a predefined tag name. + + :param tag_name: The name of the tag. + :type tag_name: str + :param tag_value: The value of the tag to delete. + :type tag_value: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore + + async def create_or_update_value( + self, + tag_name: str, + tag_value: str, + **kwargs + ) -> "models.TagValue": + """This operation allows adding a value to the list of predefined values for an existing predefined tag name. A tag value can have a maximum of 256 characters. + + Creates a predefined value for a predefined tag name. + + :param tag_name: The name of the tag. + :type tag_name: str + :param tag_value: The value of the tag to create. + :type tag_value: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagValue or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.TagValue + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TagValue"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + + # 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'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('TagValue', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('TagValue', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore + + async def create_or_update( + self, + tag_name: str, + **kwargs + ) -> "models.TagDetails": + """This operation allows adding a name to the list of predefined tag names for the given subscription. A tag name can have a maximum of 512 characters and is case-insensitive. Tag names cannot have the following prefixes which are reserved for Azure use: 'microsoft', 'azure', 'windows'. + + Creates a predefined tag name. + + :param tag_name: The name of the tag to create. + :type tag_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagDetails or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.TagDetails + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TagDetails"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + + # 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'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('TagDetails', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('TagDetails', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore + + async def delete( + self, + tag_name: str, + **kwargs + ) -> None: + """This operation allows deleting a name from the list of predefined tag names for the given subscription. The name being deleted must not be in use as a tag name for any resource. All predefined values for the given name must have already been deleted. + + Deletes a predefined tag name. + + :param tag_name: The name of the tag. + :type tag_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-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] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore + + def list( + self, + **kwargs + ) -> AsyncIterable["models.TagsListResult"]: + """This operation performs a union of predefined tags, resource tags, resource group tags and subscription tags, and returns a summary of usage for each tag name and value under the given subscription. In case of a large number of tags, this operation may return a previously cached result. + + Gets a summary of tag usage under the subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of TagsListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('TagsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames'} # type: ignore + + async def create_or_update_at_scope( + self, + scope: str, + properties: "models.Tags", + **kwargs + ) -> "models.TagsResource": + """This operation allows adding or replacing the entire set of tags on the specified resource or subscription. The specified entity can have a maximum of 50 tags. + + Creates or updates the entire set of tags on a resource or subscription. + + :param scope: The resource scope. + :type scope: str + :param properties: The set of tags. + :type properties: ~azure.mgmt.resource.resources.v2019_10_01.models.Tags + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagsResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.TagsResource + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TagsResource"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.TagsResource(properties=properties) + api_version = "2019-10-01" + content_type = kwargs.pop("content_type", "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'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('TagsResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/tags/default'} # type: ignore + + async def update_at_scope( + self, + scope: str, + operation: Optional[Union[str, "models.TagsPatchResourceOperation"]] = None, + properties: Optional["models.Tags"] = None, + **kwargs + ) -> "models.TagsResource": + """This operation allows replacing, merging or selectively deleting tags on the specified resource or subscription. The specified entity can have a maximum of 50 tags at the end of the operation. The 'replace' option replaces the entire set of existing tags with a new set. The 'merge' option allows adding tags with new names and updating the values of tags with existing names. The 'delete' option allows selectively deleting tags based on given names or name/value pairs. + + Selectively updates the set of tags on a resource or subscription. + + :param scope: The resource scope. + :type scope: str + :param operation: The operation type for the patch API. + :type operation: str or ~azure.mgmt.resource.resources.v2019_10_01.models.TagsPatchResourceOperation + :param properties: The set of tags. + :type properties: ~azure.mgmt.resource.resources.v2019_10_01.models.Tags + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagsResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.TagsResource + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TagsResource"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.TagsPatchResource(operation=operation, properties=properties) + api_version = "2019-10-01" + content_type = kwargs.pop("content_type", "application/json") + + # Construct URL + url = self.update_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] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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 + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('TagsResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + update_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/tags/default'} # type: ignore + + async def get_at_scope( + self, + scope: str, + **kwargs + ) -> "models.TagsResource": + """Gets the entire set of tags on a resource or subscription. + + Gets the entire set of tags on a resource or subscription. + + :param scope: The resource scope. + :type scope: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagsResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.TagsResource + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TagsResource"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + + # Construct URL + url = self.get_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] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('TagsResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/tags/default'} # type: ignore + + async def delete_at_scope( + self, + scope: str, + **kwargs + ) -> None: + """Deletes the entire set of tags on a resource or subscription. + + Deletes the entire set of tags on a resource or subscription. + + :param scope: The resource scope. + :type scope: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + + # Construct URL + url = self.delete_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] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + 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/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/models/__init__.py index 5bf8e6b74192..641783abcddb 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/models/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/models/__init__.py @@ -1,27 +1,27 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- try: - from ._models_py3 import AliasPathType - from ._models_py3 import AliasPatternType1 - from ._models_py3 import AliasType1 + from ._models_py3 import Alias + from ._models_py3 import AliasPath + from ._models_py3 import AliasPattern from ._models_py3 import BasicDependency + from ._models_py3 import ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties from ._models_py3 import DebugSetting from ._models_py3 import Dependency from ._models_py3 import Deployment from ._models_py3 import DeploymentExportResult from ._models_py3 import DeploymentExtended from ._models_py3 import DeploymentExtendedFilter + from ._models_py3 import DeploymentListResult from ._models_py3 import DeploymentOperation from ._models_py3 import DeploymentOperationProperties + from ._models_py3 import DeploymentOperationsListResult from ._models_py3 import DeploymentProperties from ._models_py3 import DeploymentPropertiesExtended from ._models_py3 import DeploymentValidateResult @@ -36,21 +36,24 @@ from ._models_py3 import GenericResourceFilter from ._models_py3 import HttpMessage from ._models_py3 import Identity - from ._models_py3 import IdentityUserAssignedIdentitiesValue from ._models_py3 import OnErrorDeployment from ._models_py3 import OnErrorDeploymentExtended from ._models_py3 import Operation from ._models_py3 import OperationDisplay + from ._models_py3 import OperationListResult from ._models_py3 import ParametersLink from ._models_py3 import Plan from ._models_py3 import Provider + from ._models_py3 import ProviderListResult from ._models_py3 import ProviderResourceType from ._models_py3 import Resource from ._models_py3 import ResourceGroup from ._models_py3 import ResourceGroupExportResult from ._models_py3 import ResourceGroupFilter + from ._models_py3 import ResourceGroupListResult from ._models_py3 import ResourceGroupPatchable from ._models_py3 import ResourceGroupProperties + from ._models_py3 import ResourceListResult from ._models_py3 import ResourceProviderOperationDisplayProperties from ._models_py3 import ResourceReference from ._models_py3 import ResourcesMoveInfo @@ -61,6 +64,7 @@ from ._models_py3 import TagDetails from ._models_py3 import TagValue from ._models_py3 import Tags + from ._models_py3 import TagsListResult from ._models_py3 import TagsPatchResource from ._models_py3 import TagsResource from ._models_py3 import TargetResource @@ -70,96 +74,102 @@ from ._models_py3 import WhatIfOperationResult from ._models_py3 import WhatIfPropertyChange except (SyntaxError, ImportError): - from ._models import AliasPathType - from ._models import AliasPatternType1 - from ._models import AliasType1 - from ._models import BasicDependency - from ._models import DebugSetting - from ._models import Dependency - from ._models import Deployment - from ._models import DeploymentExportResult - from ._models import DeploymentExtended - from ._models import DeploymentExtendedFilter - from ._models import DeploymentOperation - from ._models import DeploymentOperationProperties - from ._models import DeploymentProperties - from ._models import DeploymentPropertiesExtended - from ._models import DeploymentValidateResult - from ._models import DeploymentWhatIf - from ._models import DeploymentWhatIfProperties - from ._models import DeploymentWhatIfSettings - from ._models import ErrorAdditionalInfo - from ._models import ErrorResponse - from ._models import ExportTemplateRequest - from ._models import GenericResource - from ._models import GenericResourceExpanded - from ._models import GenericResourceFilter - from ._models import HttpMessage - from ._models import Identity - from ._models import IdentityUserAssignedIdentitiesValue - from ._models import OnErrorDeployment - from ._models import OnErrorDeploymentExtended - from ._models import Operation - from ._models import OperationDisplay - from ._models import ParametersLink - from ._models import Plan - from ._models import Provider - from ._models import ProviderResourceType - from ._models import Resource - from ._models import ResourceGroup - from ._models import ResourceGroupExportResult - from ._models import ResourceGroupFilter - from ._models import ResourceGroupPatchable - from ._models import ResourceGroupProperties - from ._models import ResourceProviderOperationDisplayProperties - from ._models import ResourceReference - from ._models import ResourcesMoveInfo - from ._models import ScopedDeployment - from ._models import Sku - from ._models import SubResource - from ._models import TagCount - from ._models import TagDetails - from ._models import TagValue - from ._models import Tags - from ._models import TagsPatchResource - from ._models import TagsResource - from ._models import TargetResource - from ._models import TemplateHashResult - from ._models import TemplateLink - from ._models import WhatIfChange - from ._models import WhatIfOperationResult - from ._models import WhatIfPropertyChange -from ._paged_models import DeploymentExtendedPaged -from ._paged_models import DeploymentOperationPaged -from ._paged_models import GenericResourceExpandedPaged -from ._paged_models import OperationPaged -from ._paged_models import ProviderPaged -from ._paged_models import ResourceGroupPaged -from ._paged_models import TagDetailsPaged + from ._models import Alias # type: ignore + from ._models import AliasPath # type: ignore + from ._models import AliasPattern # type: ignore + from ._models import BasicDependency # type: ignore + from ._models import ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties # type: ignore + from ._models import DebugSetting # type: ignore + from ._models import Dependency # type: ignore + from ._models import Deployment # type: ignore + from ._models import DeploymentExportResult # type: ignore + from ._models import DeploymentExtended # type: ignore + from ._models import DeploymentExtendedFilter # type: ignore + from ._models import DeploymentListResult # type: ignore + from ._models import DeploymentOperation # type: ignore + from ._models import DeploymentOperationProperties # type: ignore + from ._models import DeploymentOperationsListResult # type: ignore + from ._models import DeploymentProperties # type: ignore + from ._models import DeploymentPropertiesExtended # type: ignore + from ._models import DeploymentValidateResult # type: ignore + from ._models import DeploymentWhatIf # type: ignore + from ._models import DeploymentWhatIfProperties # type: ignore + from ._models import DeploymentWhatIfSettings # type: ignore + from ._models import ErrorAdditionalInfo # type: ignore + from ._models import ErrorResponse # type: ignore + from ._models import ExportTemplateRequest # type: ignore + from ._models import GenericResource # type: ignore + from ._models import GenericResourceExpanded # type: ignore + from ._models import GenericResourceFilter # type: ignore + from ._models import HttpMessage # type: ignore + from ._models import Identity # type: ignore + from ._models import OnErrorDeployment # type: ignore + from ._models import OnErrorDeploymentExtended # type: ignore + from ._models import Operation # type: ignore + from ._models import OperationDisplay # type: ignore + from ._models import OperationListResult # type: ignore + from ._models import ParametersLink # type: ignore + from ._models import Plan # type: ignore + from ._models import Provider # type: ignore + from ._models import ProviderListResult # type: ignore + from ._models import ProviderResourceType # type: ignore + from ._models import Resource # type: ignore + from ._models import ResourceGroup # type: ignore + from ._models import ResourceGroupExportResult # type: ignore + from ._models import ResourceGroupFilter # type: ignore + from ._models import ResourceGroupListResult # type: ignore + from ._models import ResourceGroupPatchable # type: ignore + from ._models import ResourceGroupProperties # type: ignore + from ._models import ResourceListResult # type: ignore + from ._models import ResourceProviderOperationDisplayProperties # type: ignore + from ._models import ResourceReference # type: ignore + from ._models import ResourcesMoveInfo # type: ignore + from ._models import ScopedDeployment # type: ignore + from ._models import Sku # type: ignore + from ._models import SubResource # type: ignore + from ._models import TagCount # type: ignore + from ._models import TagDetails # type: ignore + from ._models import TagValue # type: ignore + from ._models import Tags # type: ignore + from ._models import TagsListResult # type: ignore + from ._models import TagsPatchResource # type: ignore + from ._models import TagsResource # type: ignore + from ._models import TargetResource # type: ignore + from ._models import TemplateHashResult # type: ignore + from ._models import TemplateLink # type: ignore + from ._models import WhatIfChange # type: ignore + from ._models import WhatIfOperationResult # type: ignore + from ._models import WhatIfPropertyChange # type: ignore + from ._resource_management_client_enums import ( - DeploymentMode, - OnErrorDeploymentType, - WhatIfResultFormat, AliasPatternType, AliasType, - ResourceIdentityType, - PropertyChangeType, ChangeType, + DeploymentMode, + OnErrorDeploymentType, + PropertyChangeType, + ProvisioningOperation, + ResourceIdentityType, + TagsPatchResourceOperation, + WhatIfResultFormat, ) __all__ = [ - 'AliasPathType', - 'AliasPatternType1', - 'AliasType1', + 'Alias', + 'AliasPath', + 'AliasPattern', 'BasicDependency', + 'ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties', 'DebugSetting', 'Dependency', 'Deployment', 'DeploymentExportResult', 'DeploymentExtended', 'DeploymentExtendedFilter', + 'DeploymentListResult', 'DeploymentOperation', 'DeploymentOperationProperties', + 'DeploymentOperationsListResult', 'DeploymentProperties', 'DeploymentPropertiesExtended', 'DeploymentValidateResult', @@ -174,21 +184,24 @@ 'GenericResourceFilter', 'HttpMessage', 'Identity', - 'IdentityUserAssignedIdentitiesValue', 'OnErrorDeployment', 'OnErrorDeploymentExtended', 'Operation', 'OperationDisplay', + 'OperationListResult', 'ParametersLink', 'Plan', 'Provider', + 'ProviderListResult', 'ProviderResourceType', 'Resource', 'ResourceGroup', 'ResourceGroupExportResult', 'ResourceGroupFilter', + 'ResourceGroupListResult', 'ResourceGroupPatchable', 'ResourceGroupProperties', + 'ResourceListResult', 'ResourceProviderOperationDisplayProperties', 'ResourceReference', 'ResourcesMoveInfo', @@ -199,6 +212,7 @@ 'TagDetails', 'TagValue', 'Tags', + 'TagsListResult', 'TagsPatchResource', 'TagsResource', 'TargetResource', @@ -207,19 +221,14 @@ 'WhatIfChange', 'WhatIfOperationResult', 'WhatIfPropertyChange', - 'OperationPaged', - 'DeploymentExtendedPaged', - 'ProviderPaged', - 'GenericResourceExpandedPaged', - 'ResourceGroupPaged', - 'TagDetailsPaged', - 'DeploymentOperationPaged', - 'DeploymentMode', - 'OnErrorDeploymentType', - 'WhatIfResultFormat', 'AliasPatternType', 'AliasType', - 'ResourceIdentityType', - 'PropertyChangeType', 'ChangeType', + 'DeploymentMode', + 'OnErrorDeploymentType', + 'PropertyChangeType', + 'ProvisioningOperation', + 'ResourceIdentityType', + 'TagsPatchResourceOperation', + 'WhatIfResultFormat', ] 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 3223274b3ca4..b13b83b6d242 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 @@ -1,19 +1,51 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.serialization import Model -from msrest.exceptions import HttpOperationError +import msrest.serialization -class AliasPathType(Model): +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", + "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 + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'paths': {'key': 'paths', 'type': '[AliasPath]'}, + 'type': {'key': 'type', 'type': 'str'}, + 'default_path': {'key': 'defaultPath', 'type': 'str'}, + 'default_pattern': {'key': 'defaultPattern', 'type': 'AliasPattern'}, + } + + def __init__( + self, + **kwargs + ): + super(Alias, self).__init__(**kwargs) + self.name = kwargs.get('name', None) + self.paths = kwargs.get('paths', None) + self.type = kwargs.get('type', None) + self.default_path = kwargs.get('default_path', None) + self.default_pattern = kwargs.get('default_pattern', None) + + +class AliasPath(msrest.serialization.Model): """The type of the paths for alias. :param path: The path of an alias. @@ -21,86 +53,53 @@ class AliasPathType(Model): :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.AliasPatternType1 + :type pattern: ~azure.mgmt.resource.resources.v2019_10_01.models.AliasPattern """ _attribute_map = { 'path': {'key': 'path', 'type': 'str'}, 'api_versions': {'key': 'apiVersions', 'type': '[str]'}, - 'pattern': {'key': 'pattern', 'type': 'AliasPatternType1'}, + 'pattern': {'key': 'pattern', 'type': 'AliasPattern'}, } - def __init__(self, **kwargs): - super(AliasPathType, self).__init__(**kwargs) + def __init__( + self, + **kwargs + ): + super(AliasPath, self).__init__(**kwargs) self.path = kwargs.get('path', None) self.api_versions = kwargs.get('api_versions', None) self.pattern = kwargs.get('pattern', None) -class AliasPatternType1(Model): +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 + :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 """ _attribute_map = { 'phrase': {'key': 'phrase', 'type': 'str'}, 'variable': {'key': 'variable', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'AliasPatternType'}, + 'type': {'key': 'type', 'type': 'str'}, } - def __init__(self, **kwargs): - super(AliasPatternType1, self).__init__(**kwargs) + def __init__( + self, + **kwargs + ): + super(AliasPattern, self).__init__(**kwargs) self.phrase = kwargs.get('phrase', None) self.variable = kwargs.get('variable', None) self.type = kwargs.get('type', None) -class AliasType1(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.AliasPathType] - :param 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.AliasPatternType1 - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'paths': {'key': 'paths', 'type': '[AliasPathType]'}, - 'type': {'key': 'type', 'type': 'AliasType'}, - 'default_path': {'key': 'defaultPath', 'type': 'str'}, - 'default_pattern': {'key': 'defaultPattern', 'type': 'AliasPatternType1'}, - } - - def __init__(self, **kwargs): - super(AliasType1, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.paths = kwargs.get('paths', None) - self.type = kwargs.get('type', None) - self.default_path = kwargs.get('default_path', None) - self.default_pattern = kwargs.get('default_pattern', None) - - -class BasicDependency(Model): +class BasicDependency(msrest.serialization.Model): """Deployment dependency information. :param id: The ID of the dependency. @@ -117,52 +116,55 @@ class BasicDependency(Model): 'resource_name': {'key': 'resourceName', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(BasicDependency, self).__init__(**kwargs) self.id = kwargs.get('id', None) self.resource_type = kwargs.get('resource_type', None) self.resource_name = kwargs.get('resource_name', None) -class CloudError(Model): - """An error response for a resource management request. +class ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties(msrest.serialization.Model): + """ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties. + + Variables are only populated by the server, and will be ignored when sending a request. - :param error: - :type error: - ~azure.mgmt.resource.resources.v2019_10_01.models.ErrorResponse + :ivar principal_id: The principal id of user assigned identity. + :vartype principal_id: str + :ivar client_id: The client id of user assigned identity. + :vartype client_id: str """ - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorResponse'}, + _validation = { + 'principal_id': {'readonly': True}, + 'client_id': {'readonly': True}, } - def __init__(self, **kwargs): - super(CloudError, self).__init__(**kwargs) - self.error = kwargs.get('error', None) - - -class CloudErrorException(HttpOperationError): - """Server responsed with exception of type: 'CloudError'. - - :param deserialize: A deserializer - :param response: Server response to be deserialized. - """ - - def __init__(self, deserialize, response, *args): + _attribute_map = { + 'principal_id': {'key': 'principalId', 'type': 'str'}, + 'client_id': {'key': 'clientId', 'type': 'str'}, + } - super(CloudErrorException, self).__init__(deserialize, response, 'CloudError', *args) + def __init__( + self, + **kwargs + ): + super(ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties, self).__init__(**kwargs) + self.principal_id = None + self.client_id = None -class DebugSetting(Model): +class DebugSetting(msrest.serialization.Model): """The debug setting. - :param 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. + :param 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 """ @@ -170,17 +172,19 @@ class DebugSetting(Model): 'detail_level': {'key': 'detailLevel', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DebugSetting, self).__init__(**kwargs) self.detail_level = kwargs.get('detail_level', None) -class Dependency(Model): +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] + :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. @@ -196,7 +200,10 @@ class Dependency(Model): 'resource_name': {'key': 'resourceName', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Dependency, self).__init__(**kwargs) self.depends_on = kwargs.get('depends_on', None) self.id = kwargs.get('id', None) @@ -204,7 +211,7 @@ def __init__(self, **kwargs): self.resource_name = kwargs.get('resource_name', None) -class Deployment(Model): +class Deployment(msrest.serialization.Model): """Deployment operation parameters. All required parameters must be populated in order to send to Azure. @@ -212,9 +219,8 @@ class Deployment(Model): :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: Deployment tags + :type properties: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentProperties + :param tags: A set of tags. Deployment tags. :type tags: dict[str, str] """ @@ -228,15 +234,18 @@ class Deployment(Model): 'tags': {'key': 'tags', 'type': '{str}'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Deployment, self).__init__(**kwargs) self.location = kwargs.get('location', None) - self.properties = kwargs.get('properties', None) + self.properties = kwargs['properties'] self.tags = kwargs.get('tags', None) -class DeploymentExportResult(Model): - """The deployment export result. . +class DeploymentExportResult(msrest.serialization.Model): + """The deployment export result. :param template: The template content. :type template: object @@ -246,16 +255,18 @@ class DeploymentExportResult(Model): 'template': {'key': 'template', 'type': 'object'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentExportResult, self).__init__(**kwargs) self.template = kwargs.get('template', None) -class DeploymentExtended(Model): +class DeploymentExtended(msrest.serialization.Model): """Deployment information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The ID of the deployment. :vartype id: str @@ -268,7 +279,7 @@ class DeploymentExtended(Model): :param properties: Deployment properties. :type properties: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentPropertiesExtended - :param tags: Deployment tags + :param tags: A set of tags. Deployment tags. :type tags: dict[str, str] """ @@ -287,7 +298,10 @@ class DeploymentExtended(Model): 'tags': {'key': 'tags', 'type': '{str}'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentExtended, self).__init__(**kwargs) self.id = None self.name = None @@ -297,7 +311,7 @@ def __init__(self, **kwargs): self.tags = kwargs.get('tags', None) -class DeploymentExtendedFilter(Model): +class DeploymentExtendedFilter(msrest.serialization.Model): """Deployment filter. :param provisioning_state: The provisioning state. @@ -308,16 +322,47 @@ class DeploymentExtendedFilter(Model): 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentExtendedFilter, self).__init__(**kwargs) self.provisioning_state = kwargs.get('provisioning_state', None) -class DeploymentOperation(Model): +class DeploymentListResult(msrest.serialization.Model): + """List of deployments. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[DeploymentExtended]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(DeploymentListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = None + + +class DeploymentOperation(msrest.serialization.Model): """Deployment operation information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Full deployment operation ID. :vartype id: str @@ -339,23 +384,30 @@ class DeploymentOperation(Model): 'properties': {'key': 'properties', 'type': 'DeploymentOperationProperties'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentOperation, self).__init__(**kwargs) self.id = None self.operation_id = None self.properties = kwargs.get('properties', None) -class DeploymentOperationProperties(Model): +class DeploymentOperationProperties(msrest.serialization.Model): """Deployment operation properties. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. + :ivar provisioning_operation: The name of the current provisioning operation. Possible values + include: "NotSpecified", "Create", "Delete", "Waiting", "AzureAsyncOperationWaiting", + "ResourceCacheWaiting", "Action", "Read", "EvaluateDeploymentOutput", "DeploymentCleanup". + :vartype provisioning_operation: str or + ~azure.mgmt.resource.resources.v2019_10_01.models.ProvisioningOperation :ivar provisioning_state: The state of the provisioning. :vartype provisioning_state: str :ivar timestamp: The date and time of the operation. - :vartype timestamp: datetime + :vartype timestamp: ~datetime.datetime :ivar duration: The duration of the operation. :vartype duration: str :ivar service_request_id: Deployment operation service request id. @@ -365,17 +417,15 @@ class DeploymentOperationProperties(Model): :ivar status_message: Operation status message. :vartype status_message: object :ivar target_resource: The target resource. - :vartype target_resource: - ~azure.mgmt.resource.resources.v2019_10_01.models.TargetResource + :vartype target_resource: ~azure.mgmt.resource.resources.v2019_10_01.models.TargetResource :ivar request: The HTTP request message. - :vartype request: - ~azure.mgmt.resource.resources.v2019_10_01.models.HttpMessage + :vartype request: ~azure.mgmt.resource.resources.v2019_10_01.models.HttpMessage :ivar response: The HTTP response message. - :vartype response: - ~azure.mgmt.resource.resources.v2019_10_01.models.HttpMessage + :vartype response: ~azure.mgmt.resource.resources.v2019_10_01.models.HttpMessage """ _validation = { + 'provisioning_operation': {'readonly': True}, 'provisioning_state': {'readonly': True}, 'timestamp': {'readonly': True}, 'duration': {'readonly': True}, @@ -388,6 +438,7 @@ class DeploymentOperationProperties(Model): } _attribute_map = { + 'provisioning_operation': {'key': 'provisioningOperation', 'type': 'str'}, 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, 'duration': {'key': 'duration', 'type': 'str'}, @@ -399,8 +450,12 @@ class DeploymentOperationProperties(Model): 'response': {'key': 'response', 'type': 'HttpMessage'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentOperationProperties, self).__init__(**kwargs) + self.provisioning_operation = None self.provisioning_state = None self.timestamp = None self.duration = None @@ -412,48 +467,68 @@ def __init__(self, **kwargs): self.response = None -class DeploymentProperties(Model): +class DeploymentOperationsListResult(msrest.serialization.Model): + """List of deployment operations. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[DeploymentOperation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(DeploymentOperationsListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = None + + +class DeploymentProperties(msrest.serialization.Model): """Deployment properties. 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 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. + :param 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: object - :param 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. 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. + :param 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. + 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: object - :param 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 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 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 + 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 + :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 + :type on_error_deployment: ~azure.mgmt.resource.resources.v2019_10_01.models.OnErrorDeployment """ _validation = { @@ -465,59 +540,55 @@ class DeploymentProperties(Model): 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, 'parameters': {'key': 'parameters', 'type': 'object'}, 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, - 'mode': {'key': 'mode', 'type': 'DeploymentMode'}, + 'mode': {'key': 'mode', 'type': 'str'}, 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, 'on_error_deployment': {'key': 'onErrorDeployment', 'type': 'OnErrorDeployment'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentProperties, self).__init__(**kwargs) self.template = kwargs.get('template', None) self.template_link = kwargs.get('template_link', None) self.parameters = kwargs.get('parameters', None) self.parameters_link = kwargs.get('parameters_link', None) - self.mode = kwargs.get('mode', None) + self.mode = kwargs['mode'] self.debug_setting = kwargs.get('debug_setting', None) self.on_error_deployment = kwargs.get('on_error_deployment', None) -class DeploymentPropertiesExtended(Model): +class DeploymentPropertiesExtended(msrest.serialization.Model): """Deployment properties with additional details. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :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 + :vartype timestamp: ~datetime.datetime :ivar duration: The duration of the template deployment. :vartype duration: str :ivar outputs: Key/value pairs that represent deployment output. :vartype outputs: object :ivar providers: The list of resource providers needed for the deployment. - :vartype providers: - list[~azure.mgmt.resource.resources.v2019_10_01.models.Provider] + :vartype providers: list[~azure.mgmt.resource.resources.v2019_10_01.models.Provider] :ivar dependencies: The list of deployment dependencies. - :vartype dependencies: - list[~azure.mgmt.resource.resources.v2019_10_01.models.Dependency] + :vartype dependencies: list[~azure.mgmt.resource.resources.v2019_10_01.models.Dependency] :ivar template_link: The URI referencing the template. - :vartype template_link: - ~azure.mgmt.resource.resources.v2019_10_01.models.TemplateLink + :vartype template_link: ~azure.mgmt.resource.resources.v2019_10_01.models.TemplateLink :ivar parameters: Deployment parameters. :vartype parameters: object :ivar parameters_link: The URI referencing the parameters. - :vartype parameters_link: - ~azure.mgmt.resource.resources.v2019_10_01.models.ParametersLink - :ivar mode: The deployment mode. Possible values are Incremental and - Complete. Possible values include: 'Incremental', 'Complete' - :vartype mode: str or - ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentMode + :vartype parameters_link: ~azure.mgmt.resource.resources.v2019_10_01.models.ParametersLink + :ivar mode: The deployment mode. Possible values are Incremental and Complete. Possible values + include: "Incremental", "Complete". + :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 + :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.OnErrorDeploymentExtended @@ -530,8 +601,7 @@ class DeploymentPropertiesExtended(Model): :vartype validated_resources: list[~azure.mgmt.resource.resources.v2019_10_01.models.ResourceReference] :ivar error: The deployment error. - :vartype error: - ~azure.mgmt.resource.resources.v2019_10_01.models.ErrorResponse + :vartype error: ~azure.mgmt.resource.resources.v2019_10_01.models.ErrorResponse """ _validation = { @@ -565,7 +635,7 @@ class DeploymentPropertiesExtended(Model): 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, 'parameters': {'key': 'parameters', 'type': 'object'}, 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, - 'mode': {'key': 'mode', 'type': 'DeploymentMode'}, + 'mode': {'key': 'mode', 'type': 'str'}, 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, 'on_error_deployment': {'key': 'onErrorDeployment', 'type': 'OnErrorDeploymentExtended'}, 'template_hash': {'key': 'templateHash', 'type': 'str'}, @@ -574,7 +644,10 @@ class DeploymentPropertiesExtended(Model): 'error': {'key': 'error', 'type': 'ErrorResponse'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentPropertiesExtended, self).__init__(**kwargs) self.provisioning_state = None self.correlation_id = None @@ -595,15 +668,13 @@ def __init__(self, **kwargs): self.error = None -class DeploymentValidateResult(Model): +class DeploymentValidateResult(msrest.serialization.Model): """Information from validate template deployment response. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar error: The deployment validation error. - :vartype error: - ~azure.mgmt.resource.resources.v2019_10_01.models.ErrorResponse + :vartype error: ~azure.mgmt.resource.resources.v2019_10_01.models.ErrorResponse :param properties: The template deployment properties. :type properties: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentPropertiesExtended @@ -618,13 +689,16 @@ class DeploymentValidateResult(Model): 'properties': {'key': 'properties', 'type': 'DeploymentPropertiesExtended'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentValidateResult, self).__init__(**kwargs) self.error = None self.properties = kwargs.get('properties', None) -class DeploymentWhatIf(Model): +class DeploymentWhatIf(msrest.serialization.Model): """Deployment What-if operation parameters. All required parameters must be populated in order to send to Azure. @@ -632,8 +706,7 @@ class DeploymentWhatIf(Model): :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 + :type properties: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentWhatIfProperties """ _validation = { @@ -645,10 +718,13 @@ class DeploymentWhatIf(Model): 'properties': {'key': 'properties', 'type': 'DeploymentWhatIfProperties'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentWhatIf, self).__init__(**kwargs) self.location = kwargs.get('location', None) - self.properties = kwargs.get('properties', None) + self.properties = kwargs['properties'] class DeploymentWhatIfProperties(DeploymentProperties): @@ -656,43 +732,34 @@ 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 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. + :param 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: object - :param 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. 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. + :param 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. + 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: object - :param 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 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 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 + 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 + :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 + :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: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentWhatIfSettings @@ -707,40 +774,45 @@ class DeploymentWhatIfProperties(DeploymentProperties): 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, 'parameters': {'key': 'parameters', 'type': 'object'}, 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, - 'mode': {'key': 'mode', 'type': 'DeploymentMode'}, + 'mode': {'key': 'mode', 'type': 'str'}, 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, 'on_error_deployment': {'key': 'onErrorDeployment', 'type': 'OnErrorDeployment'}, 'what_if_settings': {'key': 'whatIfSettings', 'type': 'DeploymentWhatIfSettings'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentWhatIfProperties, self).__init__(**kwargs) self.what_if_settings = kwargs.get('what_if_settings', None) -class DeploymentWhatIfSettings(Model): +class DeploymentWhatIfSettings(msrest.serialization.Model): """Deployment What-If operation settings. - :param result_format: The format of the What-If results. Possible values - include: 'ResourceIdOnly', 'FullResourcePayloads' + :param result_format: The format of the What-If results. Possible values include: + "ResourceIdOnly", "FullResourcePayloads". :type result_format: str or ~azure.mgmt.resource.resources.v2019_10_01.models.WhatIfResultFormat """ _attribute_map = { - 'result_format': {'key': 'resultFormat', 'type': 'WhatIfResultFormat'}, + 'result_format': {'key': 'resultFormat', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeploymentWhatIfSettings, self).__init__(**kwargs) self.result_format = kwargs.get('result_format', None) -class ErrorAdditionalInfo(Model): +class ErrorAdditionalInfo(msrest.serialization.Model): """The resource management error additional info. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar type: The additional info type. :vartype type: str @@ -758,17 +830,19 @@ class ErrorAdditionalInfo(Model): 'info': {'key': 'info', 'type': 'object'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None -class ErrorResponse(Model): +class ErrorResponse(msrest.serialization.Model): """The resource management error response. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar code: The error code. :vartype code: str @@ -777,8 +851,7 @@ class ErrorResponse(Model): :ivar target: The error target. :vartype target: str :ivar details: The error details. - :vartype details: - list[~azure.mgmt.resource.resources.v2019_10_01.models.ErrorResponse] + :vartype details: list[~azure.mgmt.resource.resources.v2019_10_01.models.ErrorResponse] :ivar additional_info: The error additional info. :vartype additional_info: list[~azure.mgmt.resource.resources.v2019_10_01.models.ErrorAdditionalInfo] @@ -800,7 +873,10 @@ class ErrorResponse(Model): 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ErrorResponse, self).__init__(**kwargs) self.code = None self.message = None @@ -809,16 +885,15 @@ def __init__(self, **kwargs): self.additional_info = None -class ExportTemplateRequest(Model): +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, supply an array with single entry '*'. + :param 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', 'SkipResourceNameParameterization', - 'SkipAllParameterization' + :param options: The export template options. A CSV-formatted list containing zero or more of + the following: 'IncludeParameterDefaultValue', 'IncludeComments', + 'SkipResourceNameParameterization', 'SkipAllParameterization'. :type options: str """ @@ -827,27 +902,29 @@ class ExportTemplateRequest(Model): 'options': {'key': 'options', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ExportTemplateRequest, self).__init__(**kwargs) self.resources = kwargs.get('resources', None) self.options = kwargs.get('options', None) -class Resource(Model): +class Resource(msrest.serialization.Model): """Specified resource. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID + :ivar id: Resource ID. :vartype id: str - :ivar name: Resource name + :ivar name: Resource name. :vartype name: str - :ivar type: Resource type + :ivar type: Resource type. :vartype type: str - :param location: Resource location + :param location: Resource location. :type location: str - :param tags: Resource tags + :param tags: A set of tags. Resource tags. :type tags: dict[str, str] """ @@ -865,7 +942,10 @@ class Resource(Model): 'tags': {'key': 'tags', 'type': '{str}'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -877,18 +957,17 @@ def __init__(self, **kwargs): class GenericResource(Resource): """Resource information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID + :ivar id: Resource ID. :vartype id: str - :ivar name: Resource name + :ivar name: Resource name. :vartype name: str - :ivar type: Resource type + :ivar type: Resource type. :vartype type: str - :param location: Resource location + :param location: Resource location. :type location: str - :param tags: Resource tags + :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 @@ -925,7 +1004,10 @@ class GenericResource(Resource): 'identity': {'key': 'identity', 'type': 'Identity'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(GenericResource, self).__init__(**kwargs) self.plan = kwargs.get('plan', None) self.properties = kwargs.get('properties', None) @@ -938,18 +1020,17 @@ def __init__(self, **kwargs): class GenericResourceExpanded(GenericResource): """Resource information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID + :ivar id: Resource ID. :vartype id: str - :ivar name: Resource name + :ivar name: Resource name. :vartype name: str - :ivar type: Resource type + :ivar type: Resource type. :vartype type: str - :param location: Resource location + :param location: Resource location. :type location: str - :param tags: Resource tags + :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 @@ -963,14 +1044,14 @@ class GenericResourceExpanded(GenericResource): :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 created_time: The created time of the resource. This is only present - if requested via the $expand query parameter. - :vartype created_time: datetime - :ivar changed_time: The changed time of the resource. This is only present - if requested via the $expand query parameter. - :vartype changed_time: datetime - :ivar provisioning_state: The provisioning state of the resource. This is - only present if requested via the $expand query parameter. + :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 + :ivar changed_time: The changed time of the resource. This is only present if requested via the + $expand query parameter. + :vartype changed_time: ~datetime.datetime + :ivar provisioning_state: The provisioning state of the resource. This is only present if + requested via the $expand query parameter. :vartype provisioning_state: str """ @@ -1001,14 +1082,17 @@ class GenericResourceExpanded(GenericResource): 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(GenericResourceExpanded, self).__init__(**kwargs) self.created_time = None self.changed_time = None self.provisioning_state = None -class GenericResourceFilter(Model): +class GenericResourceFilter(msrest.serialization.Model): """Resource filter. :param resource_type: The resource type. @@ -1025,14 +1109,17 @@ class GenericResourceFilter(Model): 'tagvalue': {'key': 'tagvalue', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(GenericResourceFilter, self).__init__(**kwargs) self.resource_type = kwargs.get('resource_type', None) self.tagname = kwargs.get('tagname', None) self.tagvalue = kwargs.get('tagvalue', None) -class HttpMessage(Model): +class HttpMessage(msrest.serialization.Model): """HTTP message. :param content: HTTP message content. @@ -1043,31 +1130,31 @@ class HttpMessage(Model): 'content': {'key': 'content', 'type': 'object'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(HttpMessage, self).__init__(**kwargs) self.content = kwargs.get('content', None) -class Identity(Model): +class Identity(msrest.serialization.Model): """Identity for the resource. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar principal_id: The principal ID of resource identity. :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :param 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 user identity dictionary key references will be ARM - resource ids in the form: + :param 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 + 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, - ~azure.mgmt.resource.resources.v2019_10_01.models.IdentityUserAssignedIdentitiesValue] + ~azure.mgmt.resource.resources.v2019_10_01.models.ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties] """ _validation = { @@ -1078,11 +1165,14 @@ class Identity(Model): _attribute_map = { 'principal_id': {'key': 'principalId', 'type': 'str'}, 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'ResourceIdentityType'}, - 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{IdentityUserAssignedIdentitiesValue}'}, + 'type': {'key': 'type', 'type': 'str'}, + 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties}'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Identity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None @@ -1090,71 +1180,40 @@ def __init__(self, **kwargs): self.user_assigned_identities = kwargs.get('user_assigned_identities', None) -class IdentityUserAssignedIdentitiesValue(Model): - """IdentityUserAssignedIdentitiesValue. - - Variables are only populated by the server, and will be ignored when - sending a request. - - :ivar principal_id: The principal id of user assigned identity. - :vartype principal_id: str - :ivar client_id: The client id of user assigned identity. - :vartype client_id: str - """ - - _validation = { - 'principal_id': {'readonly': True}, - 'client_id': {'readonly': True}, - } - - _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'client_id': {'key': 'clientId', 'type': 'str'}, - } - - def __init__(self, **kwargs): - super(IdentityUserAssignedIdentitiesValue, self).__init__(**kwargs) - self.principal_id = None - self.client_id = None - - -class OnErrorDeployment(Model): +class OnErrorDeployment(msrest.serialization.Model): """Deployment on error behavior. - :param 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 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 """ _attribute_map = { - 'type': {'key': 'type', 'type': 'OnErrorDeploymentType'}, + 'type': {'key': 'type', 'type': 'str'}, 'deployment_name': {'key': 'deploymentName', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(OnErrorDeployment, self).__init__(**kwargs) self.type = kwargs.get('type', None) self.deployment_name = kwargs.get('deployment_name', None) -class OnErrorDeploymentExtended(Model): +class OnErrorDeploymentExtended(msrest.serialization.Model): """Deployment on error behavior with additional details. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar provisioning_state: The state of the provisioning for the on error - deployment. + :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 SpecificDeployment. Possible values include: - 'LastSuccessful', 'SpecificDeployment' - :type type: str or - ~azure.mgmt.resource.resources.v2019_10_01.models.OnErrorDeploymentType + :param 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 """ @@ -1165,25 +1224,27 @@ class OnErrorDeploymentExtended(Model): _attribute_map = { 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'OnErrorDeploymentType'}, + 'type': {'key': 'type', 'type': 'str'}, 'deployment_name': {'key': 'deploymentName', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(OnErrorDeploymentExtended, self).__init__(**kwargs) self.provisioning_state = None self.type = kwargs.get('type', None) self.deployment_name = kwargs.get('deployment_name', None) -class Operation(Model): +class Operation(msrest.serialization.Model): """Microsoft.Resources operation. - :param name: Operation name: {provider}/{resource}/{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 + :type display: ~azure.mgmt.resource.resources.v2019_10_01.models.OperationDisplay """ _attribute_map = { @@ -1191,19 +1252,21 @@ class Operation(Model): 'display': {'key': 'display', 'type': 'OperationDisplay'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Operation, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.display = kwargs.get('display', None) -class OperationDisplay(Model): +class OperationDisplay(msrest.serialization.Model): """The object that represents the operation. - :param provider: Service provider: Microsoft.Resources + :param provider: Service provider: Microsoft.Resources. :type provider: str - :param resource: Resource on which the operation is performed: Profile, - endpoint, etc. + :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 @@ -1218,7 +1281,10 @@ class OperationDisplay(Model): 'description': {'key': 'description', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(OperationDisplay, self).__init__(**kwargs) self.provider = kwargs.get('provider', None) self.resource = kwargs.get('resource', None) @@ -1226,15 +1292,37 @@ def __init__(self, **kwargs): self.description = kwargs.get('description', None) -class ParametersLink(Model): +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 + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Operation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(OperationListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class ParametersLink(msrest.serialization.Model): """Entity representing the reference to the deployment parameters. 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. + :param content_version: If included, must match the ContentVersion in the template. :type content_version: str """ @@ -1247,13 +1335,16 @@ class ParametersLink(Model): 'content_version': {'key': 'contentVersion', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ParametersLink, self).__init__(**kwargs) - self.uri = kwargs.get('uri', None) + self.uri = kwargs['uri'] self.content_version = kwargs.get('content_version', None) -class Plan(Model): +class Plan(msrest.serialization.Model): """Plan for the resource. :param name: The plan ID. @@ -1276,7 +1367,10 @@ class Plan(Model): 'version': {'key': 'version', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Plan, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.publisher = kwargs.get('publisher', None) @@ -1285,11 +1379,10 @@ def __init__(self, **kwargs): self.version = kwargs.get('version', None) -class Provider(Model): +class Provider(msrest.serialization.Model): """Resource provider information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The provider ID. :vartype id: str @@ -1297,8 +1390,7 @@ class Provider(Model): :type 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. + :ivar registration_policy: The registration policy of the resource provider. :vartype registration_policy: str :ivar resource_types: The collection of provider resource types. :vartype resource_types: @@ -1320,7 +1412,10 @@ class Provider(Model): 'resource_types': {'key': 'resourceTypes', 'type': '[ProviderResourceType]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Provider, self).__init__(**kwargs) self.id = None self.namespace = kwargs.get('namespace', None) @@ -1329,21 +1424,47 @@ def __init__(self, **kwargs): self.resource_types = None -class ProviderResourceType(Model): +class ProviderListResult(msrest.serialization.Model): + """List of resource providers. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Provider]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ProviderListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = None + + +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. + :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.AliasType1] + :type aliases: list[~azure.mgmt.resource.resources.v2019_10_01.models.Alias] :param api_versions: The API version. :type api_versions: list[str] - :param capabilities: The additional capabilities offered by this resource - type. + :param capabilities: The additional capabilities offered by this resource type. :type capabilities: str :param properties: The properties. :type properties: dict[str, str] @@ -1352,13 +1473,16 @@ class ProviderResourceType(Model): _attribute_map = { 'resource_type': {'key': 'resourceType', 'type': 'str'}, 'locations': {'key': 'locations', 'type': '[str]'}, - 'aliases': {'key': 'aliases', 'type': '[AliasType1]'}, + 'aliases': {'key': 'aliases', 'type': '[Alias]'}, 'api_versions': {'key': 'apiVersions', 'type': '[str]'}, 'capabilities': {'key': 'capabilities', 'type': 'str'}, 'properties': {'key': 'properties', 'type': '{str}'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ProviderResourceType, self).__init__(**kwargs) self.resource_type = kwargs.get('resource_type', None) self.locations = kwargs.get('locations', None) @@ -1368,11 +1492,10 @@ def __init__(self, **kwargs): self.properties = kwargs.get('properties', None) -class ResourceGroup(Model): +class ResourceGroup(msrest.serialization.Model): """Resource group information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. @@ -1383,16 +1506,13 @@ class ResourceGroup(Model): :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 resource group has been created. It must be one of - the supported Azure locations. + :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 + 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. + :param managed_by: The ID of the resource that manages this resource group. :type managed_by: str - :param tags: The tags attached to the resource group. + :param tags: A set of tags. The tags attached to the resource group. :type tags: dict[str, str] """ @@ -1413,25 +1533,27 @@ class ResourceGroup(Model): 'tags': {'key': 'tags', 'type': '{str}'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ResourceGroup, self).__init__(**kwargs) self.id = None self.name = None self.type = None self.properties = kwargs.get('properties', None) - self.location = kwargs.get('location', None) + self.location = kwargs['location'] self.managed_by = kwargs.get('managed_by', None) self.tags = kwargs.get('tags', None) -class ResourceGroupExportResult(Model): +class ResourceGroupExportResult(msrest.serialization.Model): """Resource group export result. :param template: The template content. :type template: object :param error: The template export error. - :type error: - ~azure.mgmt.resource.resources.v2019_10_01.models.ErrorResponse + :type error: ~azure.mgmt.resource.resources.v2019_10_01.models.ErrorResponse """ _attribute_map = { @@ -1439,13 +1561,16 @@ class ResourceGroupExportResult(Model): 'error': {'key': 'error', 'type': 'ErrorResponse'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ResourceGroupExportResult, self).__init__(**kwargs) self.template = kwargs.get('template', None) self.error = kwargs.get('error', None) -class ResourceGroupFilter(Model): +class ResourceGroupFilter(msrest.serialization.Model): """Resource group filter. :param tag_name: The tag name. @@ -1459,24 +1584,54 @@ class ResourceGroupFilter(Model): 'tag_value': {'key': 'tagValue', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ResourceGroupFilter, self).__init__(**kwargs) self.tag_name = kwargs.get('tag_name', None) self.tag_value = kwargs.get('tag_value', None) -class ResourceGroupPatchable(Model): +class ResourceGroupListResult(msrest.serialization.Model): + """List of resource groups. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ResourceGroup]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ResourceGroupListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = None + + +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 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: The tags attached to the resource group. + :param tags: A set of tags. The tags attached to the resource group. :type tags: dict[str, str] """ @@ -1487,7 +1642,10 @@ class ResourceGroupPatchable(Model): 'tags': {'key': 'tags', 'type': '{str}'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ResourceGroupPatchable, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.properties = kwargs.get('properties', None) @@ -1495,11 +1653,10 @@ def __init__(self, **kwargs): self.tags = kwargs.get('tags', None) -class ResourceGroupProperties(Model): +class ResourceGroupProperties(msrest.serialization.Model): """The resource group properties. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar provisioning_state: The provisioning state. :vartype provisioning_state: str @@ -1513,12 +1670,44 @@ class ResourceGroupProperties(Model): 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ResourceGroupProperties, self).__init__(**kwargs) self.provisioning_state = None -class ResourceProviderOperationDisplayProperties(Model): +class ResourceListResult(msrest.serialization.Model): + """List of resource groups. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[GenericResourceExpanded]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ResourceListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = None + + +class ResourceProviderOperationDisplayProperties(msrest.serialization.Model): """Resource provider operation's display properties. :param publisher: Operation description. @@ -1541,7 +1730,10 @@ class ResourceProviderOperationDisplayProperties(Model): 'description': {'key': 'description', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ResourceProviderOperationDisplayProperties, self).__init__(**kwargs) self.publisher = kwargs.get('publisher', None) self.provider = kwargs.get('provider', None) @@ -1550,11 +1742,10 @@ def __init__(self, **kwargs): self.description = kwargs.get('description', None) -class ResourceReference(Model): +class ResourceReference(msrest.serialization.Model): """The resource Id model. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The fully qualified resource Id. :vartype id: str @@ -1568,12 +1759,15 @@ class ResourceReference(Model): 'id': {'key': 'id', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ResourceReference, self).__init__(**kwargs) self.id = None -class ResourcesMoveInfo(Model): +class ResourcesMoveInfo(msrest.serialization.Model): """Parameters of move resources. :param resources: The IDs of the resources. @@ -1587,13 +1781,16 @@ class ResourcesMoveInfo(Model): 'target_resource_group': {'key': 'targetResourceGroup', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ResourcesMoveInfo, self).__init__(**kwargs) self.resources = kwargs.get('resources', None) self.target_resource_group = kwargs.get('target_resource_group', None) -class ScopedDeployment(Model): +class ScopedDeployment(msrest.serialization.Model): """Deployment operation parameters. All required parameters must be populated in order to send to Azure. @@ -1601,9 +1798,8 @@ class ScopedDeployment(Model): :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: Deployment tags + :type properties: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentProperties + :param tags: A set of tags. Deployment tags. :type tags: dict[str, str] """ @@ -1618,14 +1814,17 @@ class ScopedDeployment(Model): 'tags': {'key': 'tags', 'type': '{str}'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ScopedDeployment, self).__init__(**kwargs) - self.location = kwargs.get('location', None) - self.properties = kwargs.get('properties', None) + self.location = kwargs['location'] + self.properties = kwargs['properties'] self.tags = kwargs.get('tags', None) -class Sku(Model): +class Sku(msrest.serialization.Model): """SKU for the resource. :param name: The SKU name. @@ -1651,7 +1850,10 @@ class Sku(Model): 'capacity': {'key': 'capacity', 'type': 'int'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Sku, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.tier = kwargs.get('tier', None) @@ -1661,10 +1863,10 @@ def __init__(self, **kwargs): self.capacity = kwargs.get('capacity', None) -class SubResource(Model): +class SubResource(msrest.serialization.Model): """Sub-resource. - :param id: Resource ID + :param id: Resource ID. :type id: str """ @@ -1672,12 +1874,15 @@ class SubResource(Model): 'id': {'key': 'id', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(SubResource, self).__init__(**kwargs) self.id = kwargs.get('id', None) -class TagCount(Model): +class TagCount(msrest.serialization.Model): """Tag count. :param type: Type of count. @@ -1691,29 +1896,29 @@ class TagCount(Model): 'value': {'key': 'value', 'type': 'int'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(TagCount, self).__init__(**kwargs) self.type = kwargs.get('type', None) self.value = kwargs.get('value', None) -class TagDetails(Model): +class TagDetails(msrest.serialization.Model): """Tag details. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :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 created and has no associated resources, the value - is 0. + :param 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] + :type values: list[~azure.mgmt.resource.resources.v2019_10_01.models.TagValue] """ _validation = { @@ -1727,7 +1932,10 @@ class TagDetails(Model): 'values': {'key': 'values', 'type': '[TagValue]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(TagDetails, self).__init__(**kwargs) self.id = None self.tag_name = kwargs.get('tag_name', None) @@ -1735,60 +1943,61 @@ def __init__(self, **kwargs): self.values = kwargs.get('values', None) -class TagValue(Model): - """Tag information. - - Variables are only populated by the server, and will be ignored when - sending a request. +class Tags(msrest.serialization.Model): + """A dictionary of name and value pairs. - :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 + :param tags: A set of tags. Dictionary of :code:``. + :type tags: dict[str, str] """ - _validation = { - 'id': {'readonly': True}, - } - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'tag_value': {'key': 'tagValue', 'type': 'str'}, - 'count': {'key': 'count', 'type': 'TagCount'}, + 'tags': {'key': 'tags', 'type': '{str}'}, } - def __init__(self, **kwargs): - super(TagValue, self).__init__(**kwargs) - self.id = None - self.tag_value = kwargs.get('tag_value', None) - self.count = kwargs.get('count', None) + def __init__( + self, + **kwargs + ): + super(Tags, self).__init__(**kwargs) + self.tags = kwargs.get('tags', None) -class Tags(Model): - """A dictionary of name and value pairs. +class TagsListResult(msrest.serialization.Model): + """List of subscription tags. - :param tags: - :type tags: dict[str, str] + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ + _validation = { + 'next_link': {'readonly': True}, + } + _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, + 'value': {'key': 'value', 'type': '[TagDetails]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, } - def __init__(self, **kwargs): - super(Tags, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) + def __init__( + self, + **kwargs + ): + super(TagsListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = None -class TagsPatchResource(Model): +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', 'Merge', 'Delete' + :param 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.enum + ~azure.mgmt.resource.resources.v2019_10_01.models.TagsPatchResourceOperation :param properties: The set of tags. :type properties: ~azure.mgmt.resource.resources.v2019_10_01.models.Tags """ @@ -1798,17 +2007,19 @@ class TagsPatchResource(Model): 'properties': {'key': 'properties', 'type': 'Tags'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(TagsPatchResource, self).__init__(**kwargs) self.operation = kwargs.get('operation', None) self.properties = kwargs.get('properties', None) -class TagsResource(Model): +class TagsResource(msrest.serialization.Model): """Wrapper resource for tags API requests and responses. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. @@ -1836,15 +2047,51 @@ class TagsResource(Model): 'properties': {'key': 'properties', 'type': 'Tags'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(TagsResource, self).__init__(**kwargs) self.id = None self.name = None self.type = None - self.properties = kwargs.get('properties', None) + self.properties = kwargs['properties'] -class TargetResource(Model): +class TagValue(msrest.serialization.Model): + """Tag information. + + Variables are only populated by the server, and will be ignored when sending a request. + + :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 + """ + + _validation = { + 'id': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'tag_value': {'key': 'tagValue', 'type': 'str'}, + 'count': {'key': 'count', 'type': 'TagCount'}, + } + + def __init__( + self, + **kwargs + ): + super(TagValue, self).__init__(**kwargs) + self.id = None + self.tag_value = kwargs.get('tag_value', None) + self.count = kwargs.get('count', None) + + +class TargetResource(msrest.serialization.Model): """Target resource. :param id: The ID of the resource. @@ -1861,16 +2108,18 @@ class TargetResource(Model): 'resource_type': {'key': 'resourceType', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(TargetResource, self).__init__(**kwargs) self.id = kwargs.get('id', None) self.resource_name = kwargs.get('resource_name', None) self.resource_type = kwargs.get('resource_type', None) -class TemplateHashResult(Model): - """Result of the request to calculate template hash. It contains a string of - minified template and its hash. +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 @@ -1883,21 +2132,23 @@ class TemplateHashResult(Model): 'template_hash': {'key': 'templateHash', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(TemplateHashResult, self).__init__(**kwargs) self.minified_template = kwargs.get('minified_template', None) self.template_hash = kwargs.get('template_hash', None) -class TemplateLink(Model): +class TemplateLink(msrest.serialization.Model): """Entity representing the reference to the template. 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. + :param content_version: If included, must match the ContentVersion in the template. :type content_version: str """ @@ -1910,33 +2161,32 @@ class TemplateLink(Model): 'content_version': {'key': 'contentVersion', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(TemplateLink, self).__init__(**kwargs) - self.uri = kwargs.get('uri', None) + self.uri = kwargs['uri'] self.content_version = kwargs.get('content_version', None) -class WhatIfChange(Model): +class WhatIfChange(msrest.serialization.Model): """Information about a single resource change predicted by What-If operation. All required parameters must be populated in order to send to Azure. - :param resource_id: Required. Resource ID + :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 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. + :param 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: object - :param after: The predicted snapshot of the resource after the deployment - is executed. + :param after: The predicted snapshot of the resource after the deployment is executed. :type after: object :param delta: The predicted changes to resource properties. - :type delta: - list[~azure.mgmt.resource.resources.v2019_10_01.models.WhatIfPropertyChange] + :type delta: list[~azure.mgmt.resource.resources.v2019_10_01.models.WhatIfPropertyChange] """ _validation = { @@ -1946,67 +2196,68 @@ class WhatIfChange(Model): _attribute_map = { 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'change_type': {'key': 'changeType', 'type': 'ChangeType'}, + 'change_type': {'key': 'changeType', 'type': 'str'}, 'before': {'key': 'before', 'type': 'object'}, 'after': {'key': 'after', 'type': 'object'}, 'delta': {'key': 'delta', 'type': '[WhatIfPropertyChange]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(WhatIfChange, self).__init__(**kwargs) - self.resource_id = kwargs.get('resource_id', None) - self.change_type = kwargs.get('change_type', None) + self.resource_id = kwargs['resource_id'] + self.change_type = kwargs['change_type'] self.before = kwargs.get('before', None) self.after = kwargs.get('after', None) self.delta = kwargs.get('delta', None) -class WhatIfOperationResult(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. +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 changes: List of resource changes predicted by What-If operation. - :type changes: - list[~azure.mgmt.resource.resources.v2019_10_01.models.WhatIfChange] :param error: Error when What-If operation fails. - :type error: - ~azure.mgmt.resource.resources.v2019_10_01.models.ErrorResponse + :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] """ _attribute_map = { 'status': {'key': 'status', 'type': 'str'}, - 'changes': {'key': 'properties.changes', 'type': '[WhatIfChange]'}, 'error': {'key': 'error', 'type': 'ErrorResponse'}, + 'changes': {'key': 'properties.changes', 'type': '[WhatIfChange]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(WhatIfOperationResult, self).__init__(**kwargs) self.status = kwargs.get('status', None) - self.changes = kwargs.get('changes', None) self.error = kwargs.get('error', None) + self.changes = kwargs.get('changes', None) -class WhatIfPropertyChange(Model): +class WhatIfPropertyChange(msrest.serialization.Model): """The predicted change to the resource property. 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: 'Create', 'Delete', 'Modify', 'Array' + :param property_change_type: Required. The type of property change. Possible values include: + "Create", "Delete", "Modify", "Array". :type 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. + :param before: The value of the property before the deployment is executed. :type before: object :param after: The value of the property after the deployment is executed. :type after: object :param children: Nested property changes. - :type children: - list[~azure.mgmt.resource.resources.v2019_10_01.models.WhatIfPropertyChange] + :type children: list[~azure.mgmt.resource.resources.v2019_10_01.models.WhatIfPropertyChange] """ _validation = { @@ -2016,16 +2267,19 @@ class WhatIfPropertyChange(Model): _attribute_map = { 'path': {'key': 'path', 'type': 'str'}, - 'property_change_type': {'key': 'propertyChangeType', 'type': 'PropertyChangeType'}, + 'property_change_type': {'key': 'propertyChangeType', 'type': 'str'}, 'before': {'key': 'before', 'type': 'object'}, 'after': {'key': 'after', 'type': 'object'}, 'children': {'key': 'children', 'type': '[WhatIfPropertyChange]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(WhatIfPropertyChange, self).__init__(**kwargs) - self.path = kwargs.get('path', None) - self.property_change_type = kwargs.get('property_change_type', None) + 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) 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 f04f07b773bd..394749da4b7c 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 @@ -1,19 +1,61 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.serialization import Model -from msrest.exceptions import HttpOperationError +from typing import Dict, List, Optional, Union +import msrest.serialization -class AliasPathType(Model): +from ._resource_management_client_enums import * + + +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", + "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 + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'paths': {'key': 'paths', 'type': '[AliasPath]'}, + 'type': {'key': 'type', 'type': 'str'}, + 'default_path': {'key': 'defaultPath', 'type': 'str'}, + 'default_pattern': {'key': 'defaultPattern', 'type': 'AliasPattern'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + paths: Optional[List["AliasPath"]] = None, + type: Optional[Union[str, "AliasType"]] = None, + default_path: Optional[str] = None, + default_pattern: Optional["AliasPattern"] = None, + **kwargs + ): + super(Alias, self).__init__(**kwargs) + self.name = name + self.paths = paths + self.type = type + self.default_path = default_path + self.default_pattern = default_pattern + + +class AliasPath(msrest.serialization.Model): """The type of the paths for alias. :param path: The path of an alias. @@ -21,86 +63,61 @@ class AliasPathType(Model): :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.AliasPatternType1 + :type pattern: ~azure.mgmt.resource.resources.v2019_10_01.models.AliasPattern """ _attribute_map = { 'path': {'key': 'path', 'type': 'str'}, 'api_versions': {'key': 'apiVersions', 'type': '[str]'}, - 'pattern': {'key': 'pattern', 'type': 'AliasPatternType1'}, - } - - def __init__(self, *, path: str=None, api_versions=None, pattern=None, **kwargs) -> None: - super(AliasPathType, self).__init__(**kwargs) + 'pattern': {'key': 'pattern', 'type': 'AliasPattern'}, + } + + def __init__( + self, + *, + path: Optional[str] = None, + api_versions: Optional[List[str]] = None, + pattern: Optional["AliasPattern"] = None, + **kwargs + ): + super(AliasPath, self).__init__(**kwargs) self.path = path self.api_versions = api_versions self.pattern = pattern -class AliasPatternType1(Model): +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 + :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 """ _attribute_map = { 'phrase': {'key': 'phrase', 'type': 'str'}, 'variable': {'key': 'variable', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'AliasPatternType'}, + 'type': {'key': 'type', 'type': 'str'}, } - def __init__(self, *, phrase: str=None, variable: str=None, type=None, **kwargs) -> None: - super(AliasPatternType1, self).__init__(**kwargs) + def __init__( + self, + *, + phrase: Optional[str] = None, + variable: Optional[str] = None, + type: Optional[Union[str, "AliasPatternType"]] = None, + **kwargs + ): + super(AliasPattern, self).__init__(**kwargs) self.phrase = phrase self.variable = variable self.type = type -class AliasType1(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.AliasPathType] - :param 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.AliasPatternType1 - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'paths': {'key': 'paths', 'type': '[AliasPathType]'}, - 'type': {'key': 'type', 'type': 'AliasType'}, - 'default_path': {'key': 'defaultPath', 'type': 'str'}, - 'default_pattern': {'key': 'defaultPattern', 'type': 'AliasPatternType1'}, - } - - def __init__(self, *, name: str=None, paths=None, type=None, default_path: str=None, default_pattern=None, **kwargs) -> None: - super(AliasType1, self).__init__(**kwargs) - self.name = name - self.paths = paths - self.type = type - self.default_path = default_path - self.default_pattern = default_pattern - - -class BasicDependency(Model): +class BasicDependency(msrest.serialization.Model): """Deployment dependency information. :param id: The ID of the dependency. @@ -117,52 +134,59 @@ class BasicDependency(Model): 'resource_name': {'key': 'resourceName', 'type': 'str'}, } - def __init__(self, *, id: str=None, resource_type: str=None, resource_name: str=None, **kwargs) -> None: + def __init__( + self, + *, + id: Optional[str] = None, + resource_type: Optional[str] = None, + resource_name: Optional[str] = None, + **kwargs + ): super(BasicDependency, self).__init__(**kwargs) self.id = id self.resource_type = resource_type self.resource_name = resource_name -class CloudError(Model): - """An error response for a resource management request. +class ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties(msrest.serialization.Model): + """ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties. + + Variables are only populated by the server, and will be ignored when sending a request. - :param error: - :type error: - ~azure.mgmt.resource.resources.v2019_10_01.models.ErrorResponse + :ivar principal_id: The principal id of user assigned identity. + :vartype principal_id: str + :ivar client_id: The client id of user assigned identity. + :vartype client_id: str """ - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorResponse'}, + _validation = { + 'principal_id': {'readonly': True}, + 'client_id': {'readonly': True}, } - def __init__(self, *, error=None, **kwargs) -> None: - super(CloudError, self).__init__(**kwargs) - self.error = error - - -class CloudErrorException(HttpOperationError): - """Server responsed with exception of type: 'CloudError'. - - :param deserialize: A deserializer - :param response: Server response to be deserialized. - """ - - def __init__(self, deserialize, response, *args): + _attribute_map = { + 'principal_id': {'key': 'principalId', 'type': 'str'}, + 'client_id': {'key': 'clientId', 'type': 'str'}, + } - super(CloudErrorException, self).__init__(deserialize, response, 'CloudError', *args) + def __init__( + self, + **kwargs + ): + super(ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties, self).__init__(**kwargs) + self.principal_id = None + self.client_id = None -class DebugSetting(Model): +class DebugSetting(msrest.serialization.Model): """The debug setting. - :param 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. + :param 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 """ @@ -170,17 +194,21 @@ class DebugSetting(Model): 'detail_level': {'key': 'detailLevel', 'type': 'str'}, } - def __init__(self, *, detail_level: str=None, **kwargs) -> None: + def __init__( + self, + *, + detail_level: Optional[str] = None, + **kwargs + ): super(DebugSetting, self).__init__(**kwargs) self.detail_level = detail_level -class Dependency(Model): +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] + :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. @@ -196,7 +224,15 @@ class Dependency(Model): 'resource_name': {'key': 'resourceName', 'type': 'str'}, } - def __init__(self, *, depends_on=None, id: str=None, resource_type: str=None, resource_name: str=None, **kwargs) -> None: + def __init__( + self, + *, + depends_on: Optional[List["BasicDependency"]] = None, + id: Optional[str] = None, + resource_type: Optional[str] = None, + resource_name: Optional[str] = None, + **kwargs + ): super(Dependency, self).__init__(**kwargs) self.depends_on = depends_on self.id = id @@ -204,7 +240,7 @@ def __init__(self, *, depends_on=None, id: str=None, resource_type: str=None, re self.resource_name = resource_name -class Deployment(Model): +class Deployment(msrest.serialization.Model): """Deployment operation parameters. All required parameters must be populated in order to send to Azure. @@ -212,9 +248,8 @@ class Deployment(Model): :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: Deployment tags + :type properties: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentProperties + :param tags: A set of tags. Deployment tags. :type tags: dict[str, str] """ @@ -228,15 +263,22 @@ class Deployment(Model): 'tags': {'key': 'tags', 'type': '{str}'}, } - def __init__(self, *, properties, location: str=None, tags=None, **kwargs) -> None: + def __init__( + self, + *, + properties: "DeploymentProperties", + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): super(Deployment, self).__init__(**kwargs) self.location = location self.properties = properties self.tags = tags -class DeploymentExportResult(Model): - """The deployment export result. . +class DeploymentExportResult(msrest.serialization.Model): + """The deployment export result. :param template: The template content. :type template: object @@ -246,16 +288,20 @@ class DeploymentExportResult(Model): 'template': {'key': 'template', 'type': 'object'}, } - def __init__(self, *, template=None, **kwargs) -> None: + def __init__( + self, + *, + template: Optional[object] = None, + **kwargs + ): super(DeploymentExportResult, self).__init__(**kwargs) self.template = template -class DeploymentExtended(Model): +class DeploymentExtended(msrest.serialization.Model): """Deployment information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The ID of the deployment. :vartype id: str @@ -268,7 +314,7 @@ class DeploymentExtended(Model): :param properties: Deployment properties. :type properties: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentPropertiesExtended - :param tags: Deployment tags + :param tags: A set of tags. Deployment tags. :type tags: dict[str, str] """ @@ -287,7 +333,14 @@ class DeploymentExtended(Model): 'tags': {'key': 'tags', 'type': '{str}'}, } - def __init__(self, *, location: str=None, properties=None, tags=None, **kwargs) -> None: + def __init__( + self, + *, + location: Optional[str] = None, + properties: Optional["DeploymentPropertiesExtended"] = None, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): super(DeploymentExtended, self).__init__(**kwargs) self.id = None self.name = None @@ -297,7 +350,7 @@ def __init__(self, *, location: str=None, properties=None, tags=None, **kwargs) self.tags = tags -class DeploymentExtendedFilter(Model): +class DeploymentExtendedFilter(msrest.serialization.Model): """Deployment filter. :param provisioning_state: The provisioning state. @@ -308,16 +361,51 @@ class DeploymentExtendedFilter(Model): 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, } - def __init__(self, *, provisioning_state: str=None, **kwargs) -> None: + def __init__( + self, + *, + provisioning_state: Optional[str] = None, + **kwargs + ): super(DeploymentExtendedFilter, self).__init__(**kwargs) self.provisioning_state = provisioning_state -class DeploymentOperation(Model): +class DeploymentListResult(msrest.serialization.Model): + """List of deployments. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[DeploymentExtended]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["DeploymentExtended"]] = None, + **kwargs + ): + super(DeploymentListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class DeploymentOperation(msrest.serialization.Model): """Deployment operation information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Full deployment operation ID. :vartype id: str @@ -339,23 +427,32 @@ class DeploymentOperation(Model): 'properties': {'key': 'properties', 'type': 'DeploymentOperationProperties'}, } - def __init__(self, *, properties=None, **kwargs) -> None: + def __init__( + self, + *, + properties: Optional["DeploymentOperationProperties"] = None, + **kwargs + ): super(DeploymentOperation, self).__init__(**kwargs) self.id = None self.operation_id = None self.properties = properties -class DeploymentOperationProperties(Model): +class DeploymentOperationProperties(msrest.serialization.Model): """Deployment operation properties. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. + :ivar provisioning_operation: The name of the current provisioning operation. Possible values + include: "NotSpecified", "Create", "Delete", "Waiting", "AzureAsyncOperationWaiting", + "ResourceCacheWaiting", "Action", "Read", "EvaluateDeploymentOutput", "DeploymentCleanup". + :vartype provisioning_operation: str or + ~azure.mgmt.resource.resources.v2019_10_01.models.ProvisioningOperation :ivar provisioning_state: The state of the provisioning. :vartype provisioning_state: str :ivar timestamp: The date and time of the operation. - :vartype timestamp: datetime + :vartype timestamp: ~datetime.datetime :ivar duration: The duration of the operation. :vartype duration: str :ivar service_request_id: Deployment operation service request id. @@ -365,17 +462,15 @@ class DeploymentOperationProperties(Model): :ivar status_message: Operation status message. :vartype status_message: object :ivar target_resource: The target resource. - :vartype target_resource: - ~azure.mgmt.resource.resources.v2019_10_01.models.TargetResource + :vartype target_resource: ~azure.mgmt.resource.resources.v2019_10_01.models.TargetResource :ivar request: The HTTP request message. - :vartype request: - ~azure.mgmt.resource.resources.v2019_10_01.models.HttpMessage + :vartype request: ~azure.mgmt.resource.resources.v2019_10_01.models.HttpMessage :ivar response: The HTTP response message. - :vartype response: - ~azure.mgmt.resource.resources.v2019_10_01.models.HttpMessage + :vartype response: ~azure.mgmt.resource.resources.v2019_10_01.models.HttpMessage """ _validation = { + 'provisioning_operation': {'readonly': True}, 'provisioning_state': {'readonly': True}, 'timestamp': {'readonly': True}, 'duration': {'readonly': True}, @@ -388,6 +483,7 @@ class DeploymentOperationProperties(Model): } _attribute_map = { + 'provisioning_operation': {'key': 'provisioningOperation', 'type': 'str'}, 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, 'duration': {'key': 'duration', 'type': 'str'}, @@ -399,8 +495,12 @@ class DeploymentOperationProperties(Model): 'response': {'key': 'response', 'type': 'HttpMessage'}, } - def __init__(self, **kwargs) -> None: + def __init__( + self, + **kwargs + ): super(DeploymentOperationProperties, self).__init__(**kwargs) + self.provisioning_operation = None self.provisioning_state = None self.timestamp = None self.duration = None @@ -412,48 +512,70 @@ def __init__(self, **kwargs) -> None: self.response = None -class DeploymentProperties(Model): +class DeploymentOperationsListResult(msrest.serialization.Model): + """List of deployment operations. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[DeploymentOperation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["DeploymentOperation"]] = None, + **kwargs + ): + super(DeploymentOperationsListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class DeploymentProperties(msrest.serialization.Model): """Deployment properties. 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 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. + :param 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: object - :param 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. 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. + :param 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. + 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: object - :param 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 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 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 + 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 + :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 + :type on_error_deployment: ~azure.mgmt.resource.resources.v2019_10_01.models.OnErrorDeployment """ _validation = { @@ -465,12 +587,23 @@ class DeploymentProperties(Model): 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, 'parameters': {'key': 'parameters', 'type': 'object'}, 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, - 'mode': {'key': 'mode', 'type': 'DeploymentMode'}, + 'mode': {'key': 'mode', 'type': 'str'}, 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, 'on_error_deployment': {'key': 'onErrorDeployment', 'type': 'OnErrorDeployment'}, } - def __init__(self, *, mode, template=None, template_link=None, parameters=None, parameters_link=None, debug_setting=None, on_error_deployment=None, **kwargs) -> None: + def __init__( + self, + *, + mode: Union[str, "DeploymentMode"], + template: Optional[object] = None, + template_link: Optional["TemplateLink"] = None, + parameters: Optional[object] = None, + parameters_link: Optional["ParametersLink"] = None, + debug_setting: Optional["DebugSetting"] = None, + on_error_deployment: Optional["OnErrorDeployment"] = None, + **kwargs + ): super(DeploymentProperties, self).__init__(**kwargs) self.template = template self.template_link = template_link @@ -481,43 +614,36 @@ def __init__(self, *, mode, template=None, template_link=None, parameters=None, self.on_error_deployment = on_error_deployment -class DeploymentPropertiesExtended(Model): +class DeploymentPropertiesExtended(msrest.serialization.Model): """Deployment properties with additional details. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :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 + :vartype timestamp: ~datetime.datetime :ivar duration: The duration of the template deployment. :vartype duration: str :ivar outputs: Key/value pairs that represent deployment output. :vartype outputs: object :ivar providers: The list of resource providers needed for the deployment. - :vartype providers: - list[~azure.mgmt.resource.resources.v2019_10_01.models.Provider] + :vartype providers: list[~azure.mgmt.resource.resources.v2019_10_01.models.Provider] :ivar dependencies: The list of deployment dependencies. - :vartype dependencies: - list[~azure.mgmt.resource.resources.v2019_10_01.models.Dependency] + :vartype dependencies: list[~azure.mgmt.resource.resources.v2019_10_01.models.Dependency] :ivar template_link: The URI referencing the template. - :vartype template_link: - ~azure.mgmt.resource.resources.v2019_10_01.models.TemplateLink + :vartype template_link: ~azure.mgmt.resource.resources.v2019_10_01.models.TemplateLink :ivar parameters: Deployment parameters. :vartype parameters: object :ivar parameters_link: The URI referencing the parameters. - :vartype parameters_link: - ~azure.mgmt.resource.resources.v2019_10_01.models.ParametersLink - :ivar mode: The deployment mode. Possible values are Incremental and - Complete. Possible values include: 'Incremental', 'Complete' - :vartype mode: str or - ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentMode + :vartype parameters_link: ~azure.mgmt.resource.resources.v2019_10_01.models.ParametersLink + :ivar mode: The deployment mode. Possible values are Incremental and Complete. Possible values + include: "Incremental", "Complete". + :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 + :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.OnErrorDeploymentExtended @@ -530,8 +656,7 @@ class DeploymentPropertiesExtended(Model): :vartype validated_resources: list[~azure.mgmt.resource.resources.v2019_10_01.models.ResourceReference] :ivar error: The deployment error. - :vartype error: - ~azure.mgmt.resource.resources.v2019_10_01.models.ErrorResponse + :vartype error: ~azure.mgmt.resource.resources.v2019_10_01.models.ErrorResponse """ _validation = { @@ -565,7 +690,7 @@ class DeploymentPropertiesExtended(Model): 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, 'parameters': {'key': 'parameters', 'type': 'object'}, 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, - 'mode': {'key': 'mode', 'type': 'DeploymentMode'}, + 'mode': {'key': 'mode', 'type': 'str'}, 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, 'on_error_deployment': {'key': 'onErrorDeployment', 'type': 'OnErrorDeploymentExtended'}, 'template_hash': {'key': 'templateHash', 'type': 'str'}, @@ -574,7 +699,10 @@ class DeploymentPropertiesExtended(Model): 'error': {'key': 'error', 'type': 'ErrorResponse'}, } - def __init__(self, **kwargs) -> None: + def __init__( + self, + **kwargs + ): super(DeploymentPropertiesExtended, self).__init__(**kwargs) self.provisioning_state = None self.correlation_id = None @@ -595,15 +723,13 @@ def __init__(self, **kwargs) -> None: self.error = None -class DeploymentValidateResult(Model): +class DeploymentValidateResult(msrest.serialization.Model): """Information from validate template deployment response. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar error: The deployment validation error. - :vartype error: - ~azure.mgmt.resource.resources.v2019_10_01.models.ErrorResponse + :vartype error: ~azure.mgmt.resource.resources.v2019_10_01.models.ErrorResponse :param properties: The template deployment properties. :type properties: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentPropertiesExtended @@ -618,13 +744,18 @@ class DeploymentValidateResult(Model): 'properties': {'key': 'properties', 'type': 'DeploymentPropertiesExtended'}, } - def __init__(self, *, properties=None, **kwargs) -> None: + def __init__( + self, + *, + properties: Optional["DeploymentPropertiesExtended"] = None, + **kwargs + ): super(DeploymentValidateResult, self).__init__(**kwargs) self.error = None self.properties = properties -class DeploymentWhatIf(Model): +class DeploymentWhatIf(msrest.serialization.Model): """Deployment What-if operation parameters. All required parameters must be populated in order to send to Azure. @@ -632,8 +763,7 @@ class DeploymentWhatIf(Model): :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 + :type properties: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentWhatIfProperties """ _validation = { @@ -645,7 +775,13 @@ class DeploymentWhatIf(Model): 'properties': {'key': 'properties', 'type': 'DeploymentWhatIfProperties'}, } - def __init__(self, *, properties, location: str=None, **kwargs) -> None: + def __init__( + self, + *, + properties: "DeploymentWhatIfProperties", + location: Optional[str] = None, + **kwargs + ): super(DeploymentWhatIf, self).__init__(**kwargs) self.location = location self.properties = properties @@ -656,43 +792,34 @@ 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 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. + :param 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: object - :param 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. 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. + :param 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. + 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: object - :param 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 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 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 + 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 + :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 + :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: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentWhatIfSettings @@ -707,40 +834,56 @@ class DeploymentWhatIfProperties(DeploymentProperties): 'template_link': {'key': 'templateLink', 'type': 'TemplateLink'}, 'parameters': {'key': 'parameters', 'type': 'object'}, 'parameters_link': {'key': 'parametersLink', 'type': 'ParametersLink'}, - 'mode': {'key': 'mode', 'type': 'DeploymentMode'}, + 'mode': {'key': 'mode', 'type': 'str'}, 'debug_setting': {'key': 'debugSetting', 'type': 'DebugSetting'}, 'on_error_deployment': {'key': 'onErrorDeployment', 'type': 'OnErrorDeployment'}, 'what_if_settings': {'key': 'whatIfSettings', 'type': 'DeploymentWhatIfSettings'}, } - def __init__(self, *, mode, template=None, template_link=None, parameters=None, parameters_link=None, debug_setting=None, on_error_deployment=None, what_if_settings=None, **kwargs) -> None: + def __init__( + self, + *, + mode: Union[str, "DeploymentMode"], + template: Optional[object] = None, + template_link: Optional["TemplateLink"] = None, + parameters: Optional[object] = None, + parameters_link: Optional["ParametersLink"] = None, + debug_setting: Optional["DebugSetting"] = None, + on_error_deployment: Optional["OnErrorDeployment"] = None, + what_if_settings: Optional["DeploymentWhatIfSettings"] = None, + **kwargs + ): 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 -class DeploymentWhatIfSettings(Model): +class DeploymentWhatIfSettings(msrest.serialization.Model): """Deployment What-If operation settings. - :param result_format: The format of the What-If results. Possible values - include: 'ResourceIdOnly', 'FullResourcePayloads' + :param result_format: The format of the What-If results. Possible values include: + "ResourceIdOnly", "FullResourcePayloads". :type result_format: str or ~azure.mgmt.resource.resources.v2019_10_01.models.WhatIfResultFormat """ _attribute_map = { - 'result_format': {'key': 'resultFormat', 'type': 'WhatIfResultFormat'}, + 'result_format': {'key': 'resultFormat', 'type': 'str'}, } - def __init__(self, *, result_format=None, **kwargs) -> None: + def __init__( + self, + *, + result_format: Optional[Union[str, "WhatIfResultFormat"]] = None, + **kwargs + ): super(DeploymentWhatIfSettings, self).__init__(**kwargs) self.result_format = result_format -class ErrorAdditionalInfo(Model): +class ErrorAdditionalInfo(msrest.serialization.Model): """The resource management error additional info. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar type: The additional info type. :vartype type: str @@ -758,17 +901,19 @@ class ErrorAdditionalInfo(Model): 'info': {'key': 'info', 'type': 'object'}, } - def __init__(self, **kwargs) -> None: + def __init__( + self, + **kwargs + ): super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None -class ErrorResponse(Model): +class ErrorResponse(msrest.serialization.Model): """The resource management error response. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar code: The error code. :vartype code: str @@ -777,8 +922,7 @@ class ErrorResponse(Model): :ivar target: The error target. :vartype target: str :ivar details: The error details. - :vartype details: - list[~azure.mgmt.resource.resources.v2019_10_01.models.ErrorResponse] + :vartype details: list[~azure.mgmt.resource.resources.v2019_10_01.models.ErrorResponse] :ivar additional_info: The error additional info. :vartype additional_info: list[~azure.mgmt.resource.resources.v2019_10_01.models.ErrorAdditionalInfo] @@ -800,7 +944,10 @@ class ErrorResponse(Model): 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, } - def __init__(self, **kwargs) -> None: + def __init__( + self, + **kwargs + ): super(ErrorResponse, self).__init__(**kwargs) self.code = None self.message = None @@ -809,16 +956,15 @@ def __init__(self, **kwargs) -> None: self.additional_info = None -class ExportTemplateRequest(Model): +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, supply an array with single entry '*'. + :param 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', 'SkipResourceNameParameterization', - 'SkipAllParameterization' + :param options: The export template options. A CSV-formatted list containing zero or more of + the following: 'IncludeParameterDefaultValue', 'IncludeComments', + 'SkipResourceNameParameterization', 'SkipAllParameterization'. :type options: str """ @@ -827,27 +973,32 @@ class ExportTemplateRequest(Model): 'options': {'key': 'options', 'type': 'str'}, } - def __init__(self, *, resources=None, options: str=None, **kwargs) -> None: + def __init__( + self, + *, + resources: Optional[List[str]] = None, + options: Optional[str] = None, + **kwargs + ): super(ExportTemplateRequest, self).__init__(**kwargs) self.resources = resources self.options = options -class Resource(Model): +class Resource(msrest.serialization.Model): """Specified resource. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID + :ivar id: Resource ID. :vartype id: str - :ivar name: Resource name + :ivar name: Resource name. :vartype name: str - :ivar type: Resource type + :ivar type: Resource type. :vartype type: str - :param location: Resource location + :param location: Resource location. :type location: str - :param tags: Resource tags + :param tags: A set of tags. Resource tags. :type tags: dict[str, str] """ @@ -865,7 +1016,13 @@ class Resource(Model): 'tags': {'key': 'tags', 'type': '{str}'}, } - def __init__(self, *, location: str=None, tags=None, **kwargs) -> None: + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -877,18 +1034,17 @@ def __init__(self, *, location: str=None, tags=None, **kwargs) -> None: class GenericResource(Resource): """Resource information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID + :ivar id: Resource ID. :vartype id: str - :ivar name: Resource name + :ivar name: Resource name. :vartype name: str - :ivar type: Resource type + :ivar type: Resource type. :vartype type: str - :param location: Resource location + :param location: Resource location. :type location: str - :param tags: Resource tags + :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 @@ -925,7 +1081,19 @@ class GenericResource(Resource): 'identity': {'key': 'identity', 'type': 'Identity'}, } - def __init__(self, *, location: str=None, tags=None, plan=None, properties=None, kind: str=None, managed_by: str=None, sku=None, identity=None, **kwargs) -> None: + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + plan: Optional["Plan"] = None, + properties: Optional[object] = None, + kind: Optional[str] = None, + managed_by: Optional[str] = None, + sku: Optional["Sku"] = None, + identity: Optional["Identity"] = None, + **kwargs + ): super(GenericResource, self).__init__(location=location, tags=tags, **kwargs) self.plan = plan self.properties = properties @@ -938,18 +1106,17 @@ def __init__(self, *, location: str=None, tags=None, plan=None, properties=None, class GenericResourceExpanded(GenericResource): """Resource information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID + :ivar id: Resource ID. :vartype id: str - :ivar name: Resource name + :ivar name: Resource name. :vartype name: str - :ivar type: Resource type + :ivar type: Resource type. :vartype type: str - :param location: Resource location + :param location: Resource location. :type location: str - :param tags: Resource tags + :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 @@ -963,14 +1130,14 @@ class GenericResourceExpanded(GenericResource): :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 created_time: The created time of the resource. This is only present - if requested via the $expand query parameter. - :vartype created_time: datetime - :ivar changed_time: The changed time of the resource. This is only present - if requested via the $expand query parameter. - :vartype changed_time: datetime - :ivar provisioning_state: The provisioning state of the resource. This is - only present if requested via the $expand query parameter. + :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 + :ivar changed_time: The changed time of the resource. This is only present if requested via the + $expand query parameter. + :vartype changed_time: ~datetime.datetime + :ivar provisioning_state: The provisioning state of the resource. This is only present if + requested via the $expand query parameter. :vartype provisioning_state: str """ @@ -1001,14 +1168,26 @@ class GenericResourceExpanded(GenericResource): 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, } - def __init__(self, *, location: str=None, tags=None, plan=None, properties=None, kind: str=None, managed_by: str=None, sku=None, identity=None, **kwargs) -> None: + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + plan: Optional["Plan"] = None, + properties: Optional[object] = None, + kind: Optional[str] = None, + managed_by: Optional[str] = None, + sku: Optional["Sku"] = None, + identity: Optional["Identity"] = None, + **kwargs + ): 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 self.provisioning_state = None -class GenericResourceFilter(Model): +class GenericResourceFilter(msrest.serialization.Model): """Resource filter. :param resource_type: The resource type. @@ -1025,14 +1204,21 @@ class GenericResourceFilter(Model): 'tagvalue': {'key': 'tagvalue', 'type': 'str'}, } - def __init__(self, *, resource_type: str=None, tagname: str=None, tagvalue: str=None, **kwargs) -> None: + def __init__( + self, + *, + resource_type: Optional[str] = None, + tagname: Optional[str] = None, + tagvalue: Optional[str] = None, + **kwargs + ): super(GenericResourceFilter, self).__init__(**kwargs) self.resource_type = resource_type self.tagname = tagname self.tagvalue = tagvalue -class HttpMessage(Model): +class HttpMessage(msrest.serialization.Model): """HTTP message. :param content: HTTP message content. @@ -1043,31 +1229,33 @@ class HttpMessage(Model): 'content': {'key': 'content', 'type': 'object'}, } - def __init__(self, *, content=None, **kwargs) -> None: + def __init__( + self, + *, + content: Optional[object] = None, + **kwargs + ): super(HttpMessage, self).__init__(**kwargs) self.content = content -class Identity(Model): +class Identity(msrest.serialization.Model): """Identity for the resource. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar principal_id: The principal ID of resource identity. :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :param 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 user identity dictionary key references will be ARM - resource ids in the form: + :param 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 + 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, - ~azure.mgmt.resource.resources.v2019_10_01.models.IdentityUserAssignedIdentitiesValue] + ~azure.mgmt.resource.resources.v2019_10_01.models.ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties] """ _validation = { @@ -1078,11 +1266,17 @@ class Identity(Model): _attribute_map = { 'principal_id': {'key': 'principalId', 'type': 'str'}, 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'ResourceIdentityType'}, - 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{IdentityUserAssignedIdentitiesValue}'}, + 'type': {'key': 'type', 'type': 'str'}, + 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties}'}, } - def __init__(self, *, type=None, user_assigned_identities=None, **kwargs) -> None: + def __init__( + self, + *, + type: Optional[Union[str, "ResourceIdentityType"]] = None, + user_assigned_identities: Optional[Dict[str, "ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties"]] = None, + **kwargs + ): super(Identity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None @@ -1090,71 +1284,43 @@ def __init__(self, *, type=None, user_assigned_identities=None, **kwargs) -> Non self.user_assigned_identities = user_assigned_identities -class IdentityUserAssignedIdentitiesValue(Model): - """IdentityUserAssignedIdentitiesValue. - - Variables are only populated by the server, and will be ignored when - sending a request. - - :ivar principal_id: The principal id of user assigned identity. - :vartype principal_id: str - :ivar client_id: The client id of user assigned identity. - :vartype client_id: str - """ - - _validation = { - 'principal_id': {'readonly': True}, - 'client_id': {'readonly': True}, - } - - _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'client_id': {'key': 'clientId', 'type': 'str'}, - } - - def __init__(self, **kwargs) -> None: - super(IdentityUserAssignedIdentitiesValue, self).__init__(**kwargs) - self.principal_id = None - self.client_id = None - - -class OnErrorDeployment(Model): +class OnErrorDeployment(msrest.serialization.Model): """Deployment on error behavior. - :param 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 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 """ _attribute_map = { - 'type': {'key': 'type', 'type': 'OnErrorDeploymentType'}, + 'type': {'key': 'type', 'type': 'str'}, 'deployment_name': {'key': 'deploymentName', 'type': 'str'}, } - def __init__(self, *, type=None, deployment_name: str=None, **kwargs) -> None: + def __init__( + self, + *, + type: Optional[Union[str, "OnErrorDeploymentType"]] = None, + deployment_name: Optional[str] = None, + **kwargs + ): super(OnErrorDeployment, self).__init__(**kwargs) self.type = type self.deployment_name = deployment_name -class OnErrorDeploymentExtended(Model): +class OnErrorDeploymentExtended(msrest.serialization.Model): """Deployment on error behavior with additional details. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar provisioning_state: The state of the provisioning for the on error - deployment. + :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 SpecificDeployment. Possible values include: - 'LastSuccessful', 'SpecificDeployment' - :type type: str or - ~azure.mgmt.resource.resources.v2019_10_01.models.OnErrorDeploymentType + :param 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 """ @@ -1165,25 +1331,30 @@ class OnErrorDeploymentExtended(Model): _attribute_map = { 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'OnErrorDeploymentType'}, + 'type': {'key': 'type', 'type': 'str'}, 'deployment_name': {'key': 'deploymentName', 'type': 'str'}, } - def __init__(self, *, type=None, deployment_name: str=None, **kwargs) -> None: + def __init__( + self, + *, + type: Optional[Union[str, "OnErrorDeploymentType"]] = None, + deployment_name: Optional[str] = None, + **kwargs + ): super(OnErrorDeploymentExtended, self).__init__(**kwargs) self.provisioning_state = None self.type = type self.deployment_name = deployment_name -class Operation(Model): +class Operation(msrest.serialization.Model): """Microsoft.Resources operation. - :param name: Operation name: {provider}/{resource}/{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 + :type display: ~azure.mgmt.resource.resources.v2019_10_01.models.OperationDisplay """ _attribute_map = { @@ -1191,19 +1362,24 @@ class Operation(Model): 'display': {'key': 'display', 'type': 'OperationDisplay'}, } - def __init__(self, *, name: str=None, display=None, **kwargs) -> None: + def __init__( + self, + *, + name: Optional[str] = None, + display: Optional["OperationDisplay"] = None, + **kwargs + ): super(Operation, self).__init__(**kwargs) self.name = name self.display = display -class OperationDisplay(Model): +class OperationDisplay(msrest.serialization.Model): """The object that represents the operation. - :param provider: Service provider: Microsoft.Resources + :param provider: Service provider: Microsoft.Resources. :type provider: str - :param resource: Resource on which the operation is performed: Profile, - endpoint, etc. + :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 @@ -1218,7 +1394,15 @@ class OperationDisplay(Model): 'description': {'key': 'description', 'type': 'str'}, } - def __init__(self, *, provider: str=None, resource: str=None, operation: str=None, description: str=None, **kwargs) -> None: + def __init__( + self, + *, + provider: Optional[str] = None, + resource: Optional[str] = None, + operation: Optional[str] = None, + description: Optional[str] = None, + **kwargs + ): super(OperationDisplay, self).__init__(**kwargs) self.provider = provider self.resource = resource @@ -1226,15 +1410,40 @@ def __init__(self, *, provider: str=None, resource: str=None, operation: str=Non self.description = description -class ParametersLink(Model): +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 + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Operation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["Operation"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(OperationListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ParametersLink(msrest.serialization.Model): """Entity representing the reference to the deployment parameters. 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. + :param content_version: If included, must match the ContentVersion in the template. :type content_version: str """ @@ -1247,13 +1456,19 @@ class ParametersLink(Model): 'content_version': {'key': 'contentVersion', 'type': 'str'}, } - def __init__(self, *, uri: str, content_version: str=None, **kwargs) -> None: + def __init__( + self, + *, + uri: str, + content_version: Optional[str] = None, + **kwargs + ): super(ParametersLink, self).__init__(**kwargs) self.uri = uri self.content_version = content_version -class Plan(Model): +class Plan(msrest.serialization.Model): """Plan for the resource. :param name: The plan ID. @@ -1276,7 +1491,16 @@ class Plan(Model): 'version': {'key': 'version', 'type': 'str'}, } - def __init__(self, *, name: str=None, publisher: str=None, product: str=None, promotion_code: str=None, version: str=None, **kwargs) -> None: + def __init__( + self, + *, + name: Optional[str] = None, + publisher: Optional[str] = None, + product: Optional[str] = None, + promotion_code: Optional[str] = None, + version: Optional[str] = None, + **kwargs + ): super(Plan, self).__init__(**kwargs) self.name = name self.publisher = publisher @@ -1285,11 +1509,10 @@ def __init__(self, *, name: str=None, publisher: str=None, product: str=None, pr self.version = version -class Provider(Model): +class Provider(msrest.serialization.Model): """Resource provider information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The provider ID. :vartype id: str @@ -1297,8 +1520,7 @@ class Provider(Model): :type 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. + :ivar registration_policy: The registration policy of the resource provider. :vartype registration_policy: str :ivar resource_types: The collection of provider resource types. :vartype resource_types: @@ -1320,7 +1542,12 @@ class Provider(Model): 'resource_types': {'key': 'resourceTypes', 'type': '[ProviderResourceType]'}, } - def __init__(self, *, namespace: str=None, **kwargs) -> None: + def __init__( + self, + *, + namespace: Optional[str] = None, + **kwargs + ): super(Provider, self).__init__(**kwargs) self.id = None self.namespace = namespace @@ -1329,21 +1556,49 @@ def __init__(self, *, namespace: str=None, **kwargs) -> None: self.resource_types = None -class ProviderResourceType(Model): +class ProviderListResult(msrest.serialization.Model): + """List of resource providers. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Provider]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["Provider"]] = None, + **kwargs + ): + super(ProviderListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +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. + :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.AliasType1] + :type aliases: list[~azure.mgmt.resource.resources.v2019_10_01.models.Alias] :param api_versions: The API version. :type api_versions: list[str] - :param capabilities: The additional capabilities offered by this resource - type. + :param capabilities: The additional capabilities offered by this resource type. :type capabilities: str :param properties: The properties. :type properties: dict[str, str] @@ -1352,13 +1607,23 @@ class ProviderResourceType(Model): _attribute_map = { 'resource_type': {'key': 'resourceType', 'type': 'str'}, 'locations': {'key': 'locations', 'type': '[str]'}, - 'aliases': {'key': 'aliases', 'type': '[AliasType1]'}, + 'aliases': {'key': 'aliases', 'type': '[Alias]'}, 'api_versions': {'key': 'apiVersions', 'type': '[str]'}, 'capabilities': {'key': 'capabilities', 'type': 'str'}, 'properties': {'key': 'properties', 'type': '{str}'}, } - def __init__(self, *, resource_type: str=None, locations=None, aliases=None, api_versions=None, capabilities: str=None, properties=None, **kwargs) -> None: + def __init__( + self, + *, + resource_type: Optional[str] = None, + locations: Optional[List[str]] = None, + aliases: Optional[List["Alias"]] = None, + api_versions: Optional[List[str]] = None, + capabilities: Optional[str] = None, + properties: Optional[Dict[str, str]] = None, + **kwargs + ): super(ProviderResourceType, self).__init__(**kwargs) self.resource_type = resource_type self.locations = locations @@ -1368,11 +1633,10 @@ def __init__(self, *, resource_type: str=None, locations=None, aliases=None, api self.properties = properties -class ResourceGroup(Model): +class ResourceGroup(msrest.serialization.Model): """Resource group information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. @@ -1383,16 +1647,13 @@ class ResourceGroup(Model): :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 resource group has been created. It must be one of - the supported Azure locations. + :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 + 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. + :param managed_by: The ID of the resource that manages this resource group. :type managed_by: str - :param tags: The tags attached to the resource group. + :param tags: A set of tags. The tags attached to the resource group. :type tags: dict[str, str] """ @@ -1413,7 +1674,15 @@ class ResourceGroup(Model): 'tags': {'key': 'tags', 'type': '{str}'}, } - def __init__(self, *, location: str, properties=None, managed_by: str=None, tags=None, **kwargs) -> None: + def __init__( + self, + *, + location: str, + properties: Optional["ResourceGroupProperties"] = None, + managed_by: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): super(ResourceGroup, self).__init__(**kwargs) self.id = None self.name = None @@ -1424,14 +1693,13 @@ def __init__(self, *, location: str, properties=None, managed_by: str=None, tags self.tags = tags -class ResourceGroupExportResult(Model): +class ResourceGroupExportResult(msrest.serialization.Model): """Resource group export result. :param template: The template content. :type template: object :param error: The template export error. - :type error: - ~azure.mgmt.resource.resources.v2019_10_01.models.ErrorResponse + :type error: ~azure.mgmt.resource.resources.v2019_10_01.models.ErrorResponse """ _attribute_map = { @@ -1439,13 +1707,19 @@ class ResourceGroupExportResult(Model): 'error': {'key': 'error', 'type': 'ErrorResponse'}, } - def __init__(self, *, template=None, error=None, **kwargs) -> None: + def __init__( + self, + *, + template: Optional[object] = None, + error: Optional["ErrorResponse"] = None, + **kwargs + ): super(ResourceGroupExportResult, self).__init__(**kwargs) self.template = template self.error = error -class ResourceGroupFilter(Model): +class ResourceGroupFilter(msrest.serialization.Model): """Resource group filter. :param tag_name: The tag name. @@ -1459,24 +1733,59 @@ class ResourceGroupFilter(Model): 'tag_value': {'key': 'tagValue', 'type': 'str'}, } - def __init__(self, *, tag_name: str=None, tag_value: str=None, **kwargs) -> None: + def __init__( + self, + *, + tag_name: Optional[str] = None, + tag_value: Optional[str] = None, + **kwargs + ): super(ResourceGroupFilter, self).__init__(**kwargs) self.tag_name = tag_name self.tag_value = tag_value -class ResourceGroupPatchable(Model): +class ResourceGroupListResult(msrest.serialization.Model): + """List of resource groups. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ResourceGroup]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["ResourceGroup"]] = None, + **kwargs + ): + super(ResourceGroupListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +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 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: The tags attached to the resource group. + :param tags: A set of tags. The tags attached to the resource group. :type tags: dict[str, str] """ @@ -1487,7 +1796,15 @@ class ResourceGroupPatchable(Model): 'tags': {'key': 'tags', 'type': '{str}'}, } - def __init__(self, *, name: str=None, properties=None, managed_by: str=None, tags=None, **kwargs) -> None: + def __init__( + self, + *, + name: Optional[str] = None, + properties: Optional["ResourceGroupProperties"] = None, + managed_by: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): super(ResourceGroupPatchable, self).__init__(**kwargs) self.name = name self.properties = properties @@ -1495,11 +1812,10 @@ def __init__(self, *, name: str=None, properties=None, managed_by: str=None, tag self.tags = tags -class ResourceGroupProperties(Model): +class ResourceGroupProperties(msrest.serialization.Model): """The resource group properties. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar provisioning_state: The provisioning state. :vartype provisioning_state: str @@ -1513,12 +1829,46 @@ class ResourceGroupProperties(Model): 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, } - def __init__(self, **kwargs) -> None: + def __init__( + self, + **kwargs + ): super(ResourceGroupProperties, self).__init__(**kwargs) self.provisioning_state = None -class ResourceProviderOperationDisplayProperties(Model): +class ResourceListResult(msrest.serialization.Model): + """List of resource groups. + + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[GenericResourceExpanded]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["GenericResourceExpanded"]] = None, + **kwargs + ): + super(ResourceListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class ResourceProviderOperationDisplayProperties(msrest.serialization.Model): """Resource provider operation's display properties. :param publisher: Operation description. @@ -1541,7 +1891,16 @@ class ResourceProviderOperationDisplayProperties(Model): 'description': {'key': 'description', 'type': 'str'}, } - def __init__(self, *, publisher: str=None, provider: str=None, resource: str=None, operation: str=None, description: str=None, **kwargs) -> None: + def __init__( + self, + *, + publisher: Optional[str] = None, + provider: Optional[str] = None, + resource: Optional[str] = None, + operation: Optional[str] = None, + description: Optional[str] = None, + **kwargs + ): super(ResourceProviderOperationDisplayProperties, self).__init__(**kwargs) self.publisher = publisher self.provider = provider @@ -1550,11 +1909,10 @@ def __init__(self, *, publisher: str=None, provider: str=None, resource: str=Non self.description = description -class ResourceReference(Model): +class ResourceReference(msrest.serialization.Model): """The resource Id model. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The fully qualified resource Id. :vartype id: str @@ -1568,12 +1926,15 @@ class ResourceReference(Model): 'id': {'key': 'id', 'type': 'str'}, } - def __init__(self, **kwargs) -> None: + def __init__( + self, + **kwargs + ): super(ResourceReference, self).__init__(**kwargs) self.id = None -class ResourcesMoveInfo(Model): +class ResourcesMoveInfo(msrest.serialization.Model): """Parameters of move resources. :param resources: The IDs of the resources. @@ -1587,13 +1948,19 @@ class ResourcesMoveInfo(Model): 'target_resource_group': {'key': 'targetResourceGroup', 'type': 'str'}, } - def __init__(self, *, resources=None, target_resource_group: str=None, **kwargs) -> None: + def __init__( + self, + *, + resources: Optional[List[str]] = None, + target_resource_group: Optional[str] = None, + **kwargs + ): super(ResourcesMoveInfo, self).__init__(**kwargs) self.resources = resources self.target_resource_group = target_resource_group -class ScopedDeployment(Model): +class ScopedDeployment(msrest.serialization.Model): """Deployment operation parameters. All required parameters must be populated in order to send to Azure. @@ -1601,9 +1968,8 @@ class ScopedDeployment(Model): :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: Deployment tags + :type properties: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentProperties + :param tags: A set of tags. Deployment tags. :type tags: dict[str, str] """ @@ -1618,14 +1984,21 @@ class ScopedDeployment(Model): 'tags': {'key': 'tags', 'type': '{str}'}, } - def __init__(self, *, location: str, properties, tags=None, **kwargs) -> None: + def __init__( + self, + *, + location: str, + properties: "DeploymentProperties", + tags: Optional[Dict[str, str]] = None, + **kwargs + ): super(ScopedDeployment, self).__init__(**kwargs) self.location = location self.properties = properties self.tags = tags -class Sku(Model): +class Sku(msrest.serialization.Model): """SKU for the resource. :param name: The SKU name. @@ -1651,7 +2024,17 @@ class Sku(Model): 'capacity': {'key': 'capacity', 'type': 'int'}, } - def __init__(self, *, name: str=None, tier: str=None, size: str=None, family: str=None, model: str=None, capacity: int=None, **kwargs) -> None: + def __init__( + self, + *, + name: Optional[str] = None, + tier: Optional[str] = None, + size: Optional[str] = None, + family: Optional[str] = None, + model: Optional[str] = None, + capacity: Optional[int] = None, + **kwargs + ): super(Sku, self).__init__(**kwargs) self.name = name self.tier = tier @@ -1661,10 +2044,10 @@ def __init__(self, *, name: str=None, tier: str=None, size: str=None, family: st self.capacity = capacity -class SubResource(Model): +class SubResource(msrest.serialization.Model): """Sub-resource. - :param id: Resource ID + :param id: Resource ID. :type id: str """ @@ -1672,12 +2055,17 @@ class SubResource(Model): 'id': {'key': 'id', 'type': 'str'}, } - def __init__(self, *, id: str=None, **kwargs) -> None: + def __init__( + self, + *, + id: Optional[str] = None, + **kwargs + ): super(SubResource, self).__init__(**kwargs) self.id = id -class TagCount(Model): +class TagCount(msrest.serialization.Model): """Tag count. :param type: Type of count. @@ -1691,29 +2079,32 @@ class TagCount(Model): 'value': {'key': 'value', 'type': 'int'}, } - def __init__(self, *, type: str=None, value: int=None, **kwargs) -> None: + def __init__( + self, + *, + type: Optional[str] = None, + value: Optional[int] = None, + **kwargs + ): super(TagCount, self).__init__(**kwargs) self.type = type self.value = value -class TagDetails(Model): +class TagDetails(msrest.serialization.Model): """Tag details. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :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 created and has no associated resources, the value - is 0. + :param 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] + :type values: list[~azure.mgmt.resource.resources.v2019_10_01.models.TagValue] """ _validation = { @@ -1727,7 +2118,14 @@ class TagDetails(Model): 'values': {'key': 'values', 'type': '[TagValue]'}, } - def __init__(self, *, tag_name: str=None, count=None, values=None, **kwargs) -> None: + def __init__( + self, + *, + tag_name: Optional[str] = None, + count: Optional["TagCount"] = None, + values: Optional[List["TagValue"]] = None, + **kwargs + ): super(TagDetails, self).__init__(**kwargs) self.id = None self.tag_name = tag_name @@ -1735,60 +2133,65 @@ def __init__(self, *, tag_name: str=None, count=None, values=None, **kwargs) -> self.values = values -class TagValue(Model): - """Tag information. - - Variables are only populated by the server, and will be ignored when - sending a request. +class Tags(msrest.serialization.Model): + """A dictionary of name and value pairs. - :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 + :param tags: A set of tags. Dictionary of :code:``. + :type tags: dict[str, str] """ - _validation = { - 'id': {'readonly': True}, - } - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'tag_value': {'key': 'tagValue', 'type': 'str'}, - 'count': {'key': 'count', 'type': 'TagCount'}, + 'tags': {'key': 'tags', 'type': '{str}'}, } - def __init__(self, *, tag_value: str=None, count=None, **kwargs) -> None: - super(TagValue, self).__init__(**kwargs) - self.id = None - self.tag_value = tag_value - self.count = count + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + super(Tags, self).__init__(**kwargs) + self.tags = tags -class Tags(Model): - """A dictionary of name and value pairs. +class TagsListResult(msrest.serialization.Model): + """List of subscription tags. - :param tags: - :type tags: dict[str, str] + 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 next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ + _validation = { + 'next_link': {'readonly': True}, + } + _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, + 'value': {'key': 'value', 'type': '[TagDetails]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, } - def __init__(self, *, tags=None, **kwargs) -> None: - super(Tags, self).__init__(**kwargs) - self.tags = tags + def __init__( + self, + *, + value: Optional[List["TagDetails"]] = None, + **kwargs + ): + super(TagsListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None -class TagsPatchResource(Model): +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', 'Merge', 'Delete' + :param 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.enum + ~azure.mgmt.resource.resources.v2019_10_01.models.TagsPatchResourceOperation :param properties: The set of tags. :type properties: ~azure.mgmt.resource.resources.v2019_10_01.models.Tags """ @@ -1798,17 +2201,22 @@ class TagsPatchResource(Model): 'properties': {'key': 'properties', 'type': 'Tags'}, } - def __init__(self, *, operation=None, properties=None, **kwargs) -> None: + def __init__( + self, + *, + operation: Optional[Union[str, "TagsPatchResourceOperation"]] = None, + properties: Optional["Tags"] = None, + **kwargs + ): super(TagsPatchResource, self).__init__(**kwargs) self.operation = operation self.properties = properties -class TagsResource(Model): +class TagsResource(msrest.serialization.Model): """Wrapper resource for tags API requests and responses. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. @@ -1836,7 +2244,12 @@ class TagsResource(Model): 'properties': {'key': 'properties', 'type': 'Tags'}, } - def __init__(self, *, properties, **kwargs) -> None: + def __init__( + self, + *, + properties: "Tags", + **kwargs + ): super(TagsResource, self).__init__(**kwargs) self.id = None self.name = None @@ -1844,7 +2257,43 @@ def __init__(self, *, properties, **kwargs) -> None: self.properties = properties -class TargetResource(Model): +class TagValue(msrest.serialization.Model): + """Tag information. + + Variables are only populated by the server, and will be ignored when sending a request. + + :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 + """ + + _validation = { + 'id': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'tag_value': {'key': 'tagValue', 'type': 'str'}, + 'count': {'key': 'count', 'type': 'TagCount'}, + } + + def __init__( + self, + *, + tag_value: Optional[str] = None, + count: Optional["TagCount"] = None, + **kwargs + ): + super(TagValue, self).__init__(**kwargs) + self.id = None + self.tag_value = tag_value + self.count = count + + +class TargetResource(msrest.serialization.Model): """Target resource. :param id: The ID of the resource. @@ -1861,16 +2310,22 @@ class TargetResource(Model): 'resource_type': {'key': 'resourceType', 'type': 'str'}, } - def __init__(self, *, id: str=None, resource_name: str=None, resource_type: str=None, **kwargs) -> None: + def __init__( + self, + *, + id: Optional[str] = None, + resource_name: Optional[str] = None, + resource_type: Optional[str] = None, + **kwargs + ): super(TargetResource, self).__init__(**kwargs) self.id = id self.resource_name = resource_name self.resource_type = resource_type -class TemplateHashResult(Model): - """Result of the request to calculate template hash. It contains a string of - minified template and its hash. +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 @@ -1883,21 +2338,26 @@ class TemplateHashResult(Model): 'template_hash': {'key': 'templateHash', 'type': 'str'}, } - def __init__(self, *, minified_template: str=None, template_hash: str=None, **kwargs) -> None: + def __init__( + self, + *, + minified_template: Optional[str] = None, + template_hash: Optional[str] = None, + **kwargs + ): super(TemplateHashResult, self).__init__(**kwargs) self.minified_template = minified_template self.template_hash = template_hash -class TemplateLink(Model): +class TemplateLink(msrest.serialization.Model): """Entity representing the reference to the template. 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. + :param content_version: If included, must match the ContentVersion in the template. :type content_version: str """ @@ -1910,33 +2370,35 @@ class TemplateLink(Model): 'content_version': {'key': 'contentVersion', 'type': 'str'}, } - def __init__(self, *, uri: str, content_version: str=None, **kwargs) -> None: + def __init__( + self, + *, + uri: str, + content_version: Optional[str] = None, + **kwargs + ): super(TemplateLink, self).__init__(**kwargs) self.uri = uri self.content_version = content_version -class WhatIfChange(Model): +class WhatIfChange(msrest.serialization.Model): """Information about a single resource change predicted by What-If operation. All required parameters must be populated in order to send to Azure. - :param resource_id: Required. Resource ID + :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 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. + :param 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: object - :param after: The predicted snapshot of the resource after the deployment - is executed. + :param after: The predicted snapshot of the resource after the deployment is executed. :type after: object :param delta: The predicted changes to resource properties. - :type delta: - list[~azure.mgmt.resource.resources.v2019_10_01.models.WhatIfPropertyChange] + :type delta: list[~azure.mgmt.resource.resources.v2019_10_01.models.WhatIfPropertyChange] """ _validation = { @@ -1946,13 +2408,22 @@ class WhatIfChange(Model): _attribute_map = { 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'change_type': {'key': 'changeType', 'type': 'ChangeType'}, + 'change_type': {'key': 'changeType', 'type': 'str'}, 'before': {'key': 'before', 'type': 'object'}, 'after': {'key': 'after', 'type': 'object'}, 'delta': {'key': 'delta', 'type': '[WhatIfPropertyChange]'}, } - def __init__(self, *, resource_id: str, change_type, before=None, after=None, delta=None, **kwargs) -> None: + def __init__( + self, + *, + resource_id: str, + change_type: Union[str, "ChangeType"], + before: Optional[object] = None, + after: Optional[object] = None, + delta: Optional[List["WhatIfPropertyChange"]] = None, + **kwargs + ): super(WhatIfChange, self).__init__(**kwargs) self.resource_id = resource_id self.change_type = change_type @@ -1961,52 +2432,54 @@ def __init__(self, *, resource_id: str, change_type, before=None, after=None, de self.delta = delta -class WhatIfOperationResult(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. +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 changes: List of resource changes predicted by What-If operation. - :type changes: - list[~azure.mgmt.resource.resources.v2019_10_01.models.WhatIfChange] :param error: Error when What-If operation fails. - :type error: - ~azure.mgmt.resource.resources.v2019_10_01.models.ErrorResponse + :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] """ _attribute_map = { 'status': {'key': 'status', 'type': 'str'}, - 'changes': {'key': 'properties.changes', 'type': '[WhatIfChange]'}, 'error': {'key': 'error', 'type': 'ErrorResponse'}, + 'changes': {'key': 'properties.changes', 'type': '[WhatIfChange]'}, } - def __init__(self, *, status: str=None, changes=None, error=None, **kwargs) -> None: + def __init__( + self, + *, + status: Optional[str] = None, + error: Optional["ErrorResponse"] = None, + changes: Optional[List["WhatIfChange"]] = None, + **kwargs + ): super(WhatIfOperationResult, self).__init__(**kwargs) self.status = status - self.changes = changes self.error = error + self.changes = changes -class WhatIfPropertyChange(Model): +class WhatIfPropertyChange(msrest.serialization.Model): """The predicted change to the resource property. 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: 'Create', 'Delete', 'Modify', 'Array' + :param property_change_type: Required. The type of property change. Possible values include: + "Create", "Delete", "Modify", "Array". :type 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. + :param before: The value of the property before the deployment is executed. :type before: object :param after: The value of the property after the deployment is executed. :type after: object :param children: Nested property changes. - :type children: - list[~azure.mgmt.resource.resources.v2019_10_01.models.WhatIfPropertyChange] + :type children: list[~azure.mgmt.resource.resources.v2019_10_01.models.WhatIfPropertyChange] """ _validation = { @@ -2016,13 +2489,22 @@ class WhatIfPropertyChange(Model): _attribute_map = { 'path': {'key': 'path', 'type': 'str'}, - 'property_change_type': {'key': 'propertyChangeType', 'type': 'PropertyChangeType'}, + 'property_change_type': {'key': 'propertyChangeType', 'type': 'str'}, 'before': {'key': 'before', 'type': 'object'}, 'after': {'key': 'after', 'type': 'object'}, 'children': {'key': 'children', 'type': '[WhatIfPropertyChange]'}, } - def __init__(self, *, path: str, property_change_type, before=None, after=None, children=None, **kwargs) -> None: + def __init__( + self, + *, + path: str, + property_change_type: Union[str, "PropertyChangeType"], + before: Optional[object] = None, + after: Optional[object] = None, + children: Optional[List["WhatIfPropertyChange"]] = None, + **kwargs + ): super(WhatIfPropertyChange, self).__init__(**kwargs) self.path = path self.property_change_type = property_change_type diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/models/_paged_models.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/models/_paged_models.py deleted file mode 100644 index 8df0d703591e..000000000000 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/models/_paged_models.py +++ /dev/null @@ -1,105 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.paging import Paged - - -class OperationPaged(Paged): - """ - A paging container for iterating over a list of :class:`Operation ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[Operation]'} - } - - def __init__(self, *args, **kwargs): - - super(OperationPaged, self).__init__(*args, **kwargs) -class DeploymentExtendedPaged(Paged): - """ - A paging container for iterating over a list of :class:`DeploymentExtended ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[DeploymentExtended]'} - } - - def __init__(self, *args, **kwargs): - - super(DeploymentExtendedPaged, self).__init__(*args, **kwargs) -class ProviderPaged(Paged): - """ - A paging container for iterating over a list of :class:`Provider ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[Provider]'} - } - - def __init__(self, *args, **kwargs): - - super(ProviderPaged, self).__init__(*args, **kwargs) -class GenericResourceExpandedPaged(Paged): - """ - A paging container for iterating over a list of :class:`GenericResourceExpanded ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[GenericResourceExpanded]'} - } - - def __init__(self, *args, **kwargs): - - super(GenericResourceExpandedPaged, self).__init__(*args, **kwargs) -class ResourceGroupPaged(Paged): - """ - A paging container for iterating over a list of :class:`ResourceGroup ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[ResourceGroup]'} - } - - def __init__(self, *args, **kwargs): - - super(ResourceGroupPaged, self).__init__(*args, **kwargs) -class TagDetailsPaged(Paged): - """ - A paging container for iterating over a list of :class:`TagDetails ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[TagDetails]'} - } - - def __init__(self, *args, **kwargs): - - super(TagDetailsPaged, self).__init__(*args, **kwargs) -class DeploymentOperationPaged(Paged): - """ - A paging container for iterating over a list of :class:`DeploymentOperation ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[DeploymentOperation]'} - } - - def __init__(self, *args, **kwargs): - - super(DeploymentOperationPaged, self).__init__(*args, **kwargs) 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 cf0a4ee2d873..5b6d6606abbe 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 @@ -1,69 +1,102 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from enum import Enum - -class DeploymentMode(str, Enum): - - incremental = "Incremental" - complete = "Complete" - - -class OnErrorDeploymentType(str, Enum): - - last_successful = "LastSuccessful" - specific_deployment = "SpecificDeployment" - - -class WhatIfResultFormat(str, Enum): - - resource_id_only = "ResourceIdOnly" - full_resource_payloads = "FullResourcePayloads" - - class AliasPatternType(str, Enum): + """The type of alias pattern + """ not_specified = "NotSpecified" #: NotSpecified is not allowed. extract = "Extract" #: Extract is the only allowed value. - class AliasType(str, Enum): + """The type of the alias. + """ not_specified = "NotSpecified" #: Alias type is unknown (same as not providing alias type). plain_text = "PlainText" #: Alias value is not secret. mask = "Mask" #: Alias value is secret. +class ChangeType(str, Enum): + """Type of change that will be made to the resource when the deployment is executed. + """ -class ResourceIdentityType(str, Enum): + create = "Create" #: The resource does not exist in the current state but is present in the desired state. The resource will be created when the deployment is executed. + delete = "Delete" #: The resource exists in the current state and is missing from the desired state. The resource will be deleted when the deployment is executed. + ignore = "Ignore" #: The resource exists in the current state and is missing from the desired state. The resource will not be deployed or modified when the deployment is executed. + deploy = "Deploy" #: The resource exists in the current state and the desired state and will be redeployed when the deployment is executed. The properties of the resource may or may not change. + no_change = "NoChange" #: The resource exists in the current state and the desired state and will be redeployed when the deployment is executed. The properties of the resource will not change. + modify = "Modify" #: The resource exists in the current state and the desired state and will be redeployed when the deployment is executed. The properties of the resource will change. - system_assigned = "SystemAssigned" - user_assigned = "UserAssigned" - system_assigned_user_assigned = "SystemAssigned, UserAssigned" - none = "None" +class DeploymentMode(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 + the resource group that are not included in the template are deleted. Be careful when using + Complete mode as you may unintentionally delete resources. + """ + + incremental = "Incremental" + complete = "Complete" +class OnErrorDeploymentType(str, Enum): + """The deployment on error behavior type. Possible values are LastSuccessful and + SpecificDeployment. + """ + + last_successful = "LastSuccessful" + specific_deployment = "SpecificDeployment" class PropertyChangeType(str, Enum): + """The type of property change. + """ create = "Create" #: The property does not exist in the current state but is present in the desired state. The property will be created when the deployment is executed. delete = "Delete" #: The property exists in the current state and is missing from the desired state. It will be deleted when the deployment is executed. modify = "Modify" #: The property exists in both current and desired state and is different. The value of the property will change when the deployment is executed. array = "Array" #: The property is an array and contains nested changes. +class ProvisioningOperation(str, Enum): + """The name of the current provisioning operation. + """ + + not_specified = "NotSpecified" #: The provisioning operation is not specified. + create = "Create" #: The provisioning operation is create. + delete = "Delete" #: The provisioning operation is delete. + waiting = "Waiting" #: The provisioning operation is waiting. + azure_async_operation_waiting = "AzureAsyncOperationWaiting" #: The provisioning operation is waiting Azure async operation. + resource_cache_waiting = "ResourceCacheWaiting" #: The provisioning operation is waiting for resource cache. + action = "Action" #: The provisioning operation is action. + read = "Read" #: The provisioning operation is read. + evaluate_deployment_output = "EvaluateDeploymentOutput" #: The provisioning operation is evaluate output. + deployment_cleanup = "DeploymentCleanup" #: The provisioning operation is cleanup. This operation is part of the 'complete' mode deployment. -class ChangeType(str, Enum): +class ResourceIdentityType(str, Enum): + """The identity type. + """ - create = "Create" #: The resource does not exist in the current state but is present in the desired state. The resource will be created when the deployment is executed. - delete = "Delete" #: The resource exists in the current state and is missing from the desired state. The resource will be deleted when the deployment is executed. - ignore = "Ignore" #: The resource exists in the current state and is missing from the desired state. The resource will not be deployed or modified when the deployment is executed. - deploy = "Deploy" #: The resource exists in the current state and the desired state and will be redeployed when the deployment is executed. The properties of the resource may or may not change. - no_change = "NoChange" #: The resource exists in the current state and the desired state and will be redeployed when the deployment is executed. The properties of the resource will not change. - modify = "Modify" #: The resource exists in the current state and the desired state and will be redeployed when the deployment is executed. The properties of the resource will change. + system_assigned = "SystemAssigned" + user_assigned = "UserAssigned" + system_assigned_user_assigned = "SystemAssigned, UserAssigned" + none = "None" + +class TagsPatchResourceOperation(str, Enum): + """The operation type for the patch API. + """ + + replace = "Replace" + merge = "Merge" + delete = "Delete" + +class WhatIfResultFormat(str, Enum): + """The format of the What-If results + """ + + resource_id_only = "ResourceIdOnly" + full_resource_payloads = "FullResourcePayloads" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/operations/__init__.py index 41027cf11028..a6f5fa20e792 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/operations/__init__.py @@ -1,12 +1,9 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from ._operations import Operations @@ -15,7 +12,7 @@ from ._resources_operations import ResourcesOperations from ._resource_groups_operations import ResourceGroupsOperations from ._tags_operations import TagsOperations -from ._deployment_operations import DeploymentOperations +from ._deployment_operations_operations import DeploymentOperationsOperations __all__ = [ 'Operations', @@ -24,5 +21,5 @@ 'ResourcesOperations', 'ResourceGroupsOperations', 'TagsOperations', - 'DeploymentOperations', + 'DeploymentOperationsOperations', ] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/operations/_deployment_operations.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/operations/_deployment_operations.py deleted file mode 100644 index 1b37b39c2d44..000000000000 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/operations/_deployment_operations.py +++ /dev/null @@ -1,729 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError - -from .. import models - - -class DeploymentOperations(object): - """DeploymentOperations operations. - - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. - - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for this operation. Constant value: "2019-10-01". - """ - - models = models - - def __init__(self, client, config, serializer, deserializer): - - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self.api_version = "2019-10-01" - - self.config = config - - def get_at_scope( - self, scope, deployment_name, operation_id, custom_headers=None, raw=False, **operation_config): - """Gets a deployments operation. - - :param scope: The resource scope. - :type scope: str - :param deployment_name: The name of the deployment. - :type deployment_name: str - :param operation_id: The ID of the operation to get. - :type operation_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentOperation or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentOperation - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` - """ - # Construct URL - url = self.get_at_scope.metadata['url'] - 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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) - - if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentOperation', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - - return deserialized - get_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} - - def list_at_scope( - self, scope, deployment_name, top=None, custom_headers=None, raw=False, **operation_config): - """Gets all deployments operations for a deployment. - - :param scope: The resource scope. - :type scope: str - :param deployment_name: The name of the deployment. - :type deployment_name: str - :param top: The number of results to return. - :type top: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of DeploymentOperation - :rtype: - ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentOperationPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentOperation] - :raises: :class:`CloudError` - """ - def prepare_request(next_link=None): - if not next_link: - # Construct URL - url = self.list_at_scope.metadata['url'] - 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 = {} - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - else: - url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) - return request - - def internal_paging(next_link=None): - request = prepare_request(next_link) - - response = self._client.send(request, stream=False, **operation_config) - - if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response - - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.DeploymentOperationPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} - - def get_at_tenant_scope( - self, deployment_name, operation_id, custom_headers=None, raw=False, **operation_config): - """Gets a deployments operation. - - :param deployment_name: The name of the deployment. - :type deployment_name: str - :param operation_id: The ID of the operation to get. - :type operation_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentOperation or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentOperation - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` - """ - # Construct URL - url = self.get_at_tenant_scope.metadata['url'] - 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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) - - if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentOperation', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - - return deserialized - get_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} - - def list_at_tenant_scope( - self, deployment_name, top=None, custom_headers=None, raw=False, **operation_config): - """Gets all deployments operations for a deployment. - - :param deployment_name: The name of the deployment. - :type deployment_name: str - :param top: The number of results to return. - :type top: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of DeploymentOperation - :rtype: - ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentOperationPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentOperation] - :raises: :class:`CloudError` - """ - def prepare_request(next_link=None): - if not next_link: - # Construct URL - url = self.list_at_tenant_scope.metadata['url'] - 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 = {} - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - else: - url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) - return request - - def internal_paging(next_link=None): - request = prepare_request(next_link) - - response = self._client.send(request, stream=False, **operation_config) - - if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response - - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.DeploymentOperationPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} - - def get_at_management_group_scope( - self, group_id, deployment_name, operation_id, custom_headers=None, raw=False, **operation_config): - """Gets a deployments operation. - - :param group_id: The management group ID. - :type group_id: str - :param deployment_name: The name of the deployment. - :type deployment_name: str - :param operation_id: The ID of the operation to get. - :type operation_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentOperation or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentOperation - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` - """ - # Construct URL - url = self.get_at_management_group_scope.metadata['url'] - 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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) - - if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentOperation', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - - return deserialized - get_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} - - def list_at_management_group_scope( - self, group_id, deployment_name, top=None, custom_headers=None, raw=False, **operation_config): - """Gets all deployments operations for a deployment. - - :param group_id: The management group ID. - :type group_id: str - :param deployment_name: The name of the deployment. - :type deployment_name: str - :param top: The number of results to return. - :type top: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of DeploymentOperation - :rtype: - ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentOperationPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentOperation] - :raises: :class:`CloudError` - """ - def prepare_request(next_link=None): - if not next_link: - # Construct URL - url = self.list_at_management_group_scope.metadata['url'] - 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 = {} - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - else: - url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) - return request - - def internal_paging(next_link=None): - request = prepare_request(next_link) - - response = self._client.send(request, stream=False, **operation_config) - - if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response - - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.DeploymentOperationPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} - - def get_at_subscription_scope( - self, deployment_name, operation_id, custom_headers=None, raw=False, **operation_config): - """Gets a deployments operation. - - :param deployment_name: The name of the deployment. - :type deployment_name: str - :param operation_id: The ID of the operation to get. - :type operation_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentOperation or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentOperation - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` - """ - # Construct URL - url = self.get_at_subscription_scope.metadata['url'] - 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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) - - if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentOperation', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - - return deserialized - get_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} - - def list_at_subscription_scope( - self, deployment_name, top=None, custom_headers=None, raw=False, **operation_config): - """Gets all deployments operations for a deployment. - - :param deployment_name: The name of the deployment. - :type deployment_name: str - :param top: The number of results to return. - :type top: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of DeploymentOperation - :rtype: - ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentOperationPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentOperation] - :raises: :class:`CloudError` - """ - def prepare_request(next_link=None): - if not next_link: - # Construct URL - url = self.list_at_subscription_scope.metadata['url'] - 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 = {} - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - else: - url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) - return request - - def internal_paging(next_link=None): - request = prepare_request(next_link) - - response = self._client.send(request, stream=False, **operation_config) - - if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response - - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.DeploymentOperationPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} - - def get( - self, resource_group_name, deployment_name, operation_id, custom_headers=None, raw=False, **operation_config): - """Gets a deployments operation. - - :param resource_group_name: The name of the resource group. The name - is case insensitive. - :type resource_group_name: str - :param deployment_name: The name of the deployment. - :type deployment_name: str - :param operation_id: The ID of the operation to get. - :type operation_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentOperation or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentOperation - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` - """ - # Construct URL - url = self.get.metadata['url'] - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, 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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) - - if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentOperation', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}'} - - def list( - self, resource_group_name, deployment_name, top=None, custom_headers=None, raw=False, **operation_config): - """Gets all deployments operations for a deployment. - - :param resource_group_name: The name of the resource group. The name - is case insensitive. - :type resource_group_name: str - :param deployment_name: The name of the deployment. - :type deployment_name: str - :param top: The number of results to return. - :type top: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of DeploymentOperation - :rtype: - ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentOperationPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentOperation] - :raises: :class:`CloudError` - """ - def prepare_request(next_link=None): - if not next_link: - # Construct URL - url = self.list.metadata['url'] - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - else: - url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) - return request - - def internal_paging(next_link=None): - request = prepare_request(next_link) - - response = self._client.send(request, stream=False, **operation_config) - - if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response - - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.DeploymentOperationPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations'} 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 new file mode 100644 index 000000000000..0d55728a4af1 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/operations/_deployment_operations_operations.py @@ -0,0 +1,714 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class DeploymentOperationsOperations(object): + """DeploymentOperationsOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2019_10_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def get_at_scope( + self, + scope, # type: str + deployment_name, # type: str + operation_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentOperation" + """Gets a deployments operation. + + :param scope: The resource scope. + :type scope: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param operation_id: The ID of the operation to get. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentOperation or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentOperation + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentOperation"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + + # 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'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentOperation', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + def list_at_scope( + self, + scope, # type: str + deployment_name, # type: str + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.DeploymentOperationsListResult"] + """Gets all deployments operations for a deployment. + + :param scope: The resource scope. + :type scope: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentOperationsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} # type: ignore + + def get_at_tenant_scope( + self, + deployment_name, # type: str + operation_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentOperation" + """Gets a deployments operation. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param operation_id: The ID of the operation to get. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentOperation or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentOperation + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentOperation"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + + # 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'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentOperation', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + def list_at_tenant_scope( + self, + deployment_name, # type: str + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.DeploymentOperationsListResult"] + """Gets all deployments operations for a deployment. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentOperationsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/operations'} # type: ignore + + def get_at_management_group_scope( + self, + group_id, # type: str + deployment_name, # type: str + operation_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentOperation" + """Gets a deployments operation. + + :param group_id: The management group ID. + :type group_id: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param operation_id: The ID of the operation to get. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentOperation or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentOperation + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentOperation"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + + # 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'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentOperation', pipeline_response) + + if cls: + 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 + + def list_at_management_group_scope( + self, + group_id, # type: str + deployment_name, # type: str + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.DeploymentOperationsListResult"] + """Gets all deployments operations for a deployment. + + :param group_id: The management group ID. + :type group_id: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentOperationsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + 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 + + def get_at_subscription_scope( + self, + deployment_name, # type: str + operation_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentOperation" + """Gets a deployments operation. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param operation_id: The ID of the operation to get. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentOperation or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentOperation + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentOperation"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + + # 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'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentOperation', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + def list_at_subscription_scope( + self, + deployment_name, # type: str + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.DeploymentOperationsListResult"] + """Gets all deployments operations for a deployment. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentOperationsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + 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 + + def get( + self, + resource_group_name, # type: str + deployment_name, # type: str + operation_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentOperation" + """Gets a deployments operation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param operation_id: The ID of the operation to get. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentOperation or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentOperation + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentOperation"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + + # Construct URL + url = self.get.metadata['url'] # type: 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'] = 'application/json' + + # Construct and send request + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeploymentOperation', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}'} # type: ignore + + def list( + self, + resource_group_name, # type: str + deployment_name, # type: str + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.DeploymentOperationsListResult"] + """Gets all deployments operations for a deployment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentOperationsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations'} # type: ignore 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 c7fcd071377a..aac005e8b310 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 @@ -1,3189 +1,3302 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError -from msrest.polling import LROPoller, NoPolling -from msrestazure.polling.arm_polling import ARMPolling +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class DeploymentsOperations(object): """DeploymentsOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2019_10_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for this operation. Constant value: "2019-10-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-10-01" - - self.config = config - + self._config = config def _delete_at_scope_initial( - self, scope, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + scope, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + # Construct URL - url = self.delete_at_scope.metadata['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\._\(\)]+$') + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [202, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - - def delete_at_scope( - self, scope, deployment_name, custom_headers=None, raw=False, polling=True, **operation_config): - """Deletes a deployment from the deployment history. - - A template deployment that is currently running cannot be deleted. - Deleting a template deployment removes the associated deployment - operations. This is an asynchronous operation that returns a status of - 202 until the template deployment is successfully deleted. The Location - response header contains the URI that is used to obtain the status of - the process. While the process is running, a call to the URI in the - Location header returns a status of 202. When the process finishes, the - URI in the Location header returns a status of 204 on success. If the - asynchronous request failed, the URI in the Location header returns an - error-level status code. + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_at_scope_initial.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + def begin_delete_at_scope( + self, + scope, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """A template deployment that is currently running cannot be deleted. Deleting a template deployment removes the associated deployment operations. This is an asynchronous operation that returns a status of 202 until the template deployment is successfully deleted. The Location response header contains the URI that is used to obtain the status of the process. While the process is running, a call to the URI in the Location header returns a status of 202. When the process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. + + Deletes a deployment from the deployment history. :param scope: The resource scope. :type scope: str :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns None or - ClientRawResponse if raw==True - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._delete_at_scope_initial( scope=scope, deployment_name=deployment_name, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - delete_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} + begin_delete_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore def check_existence_at_scope( - self, scope, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + scope, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Checks whether the deployment exists. :param scope: The resource scope. :type scope: str :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: bool or ClientRawResponse if raw=true - :rtype: bool or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + # Construct URL - url = self.check_existence_at_scope.metadata['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\._\(\)]+$') + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204, 404]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = (response.status_code == 204) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - return deserialized - check_existence_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + 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, deployment_name, parameters, custom_headers=None, raw=False, **operation_config): + self, + scope, # type: str + deployment_name, # type: str + parameters, # type: "models.Deployment" + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentExtended" + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + content_type = kwargs.pop("content_type", "application/json") + # Construct URL - url = self.create_or_update_at_scope.metadata['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\._\(\)]+$') + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'Deployment') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 201]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', response) + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', response) + deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_at_scope_initial.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore - def create_or_update_at_scope( - self, scope, deployment_name, parameters, custom_headers=None, raw=False, polling=True, **operation_config): - """Deploys resources at a given scope. + def begin_create_or_update_at_scope( + self, + scope, # type: str + deployment_name, # type: str + parameters, # type: "models.Deployment" + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """You can provide the template and parameters directly in the request or link to JSON files. - You can provide the template and parameters directly in the request or - link to JSON files. + Deploys resources at a given scope. :param scope: The resource scope. :type scope: str :param deployment_name: The name of the deployment. :type deployment_name: str :param parameters: Additional parameters supplied to the operation. - :type parameters: - ~azure.mgmt.resource.resources.v2019_10_01.models.Deployment - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :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 polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns DeploymentExtended or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 DeploymentExtended + :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] + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._create_or_update_at_scope_initial( scope=scope, deployment_name=deployment_name, parameters=parameters, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - deserialized = self._deserialize('DeploymentExtended', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - create_or_update_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} + begin_create_or_update_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore def get_at_scope( - self, scope, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + scope, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentExtended" """Gets a deployment. :param scope: The resource scope. :type scope: str :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentExtended or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExtended or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + # Construct URL - url = self.get_at_scope.metadata['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\._\(\)]+$') + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', response) + deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} + get_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore def cancel_at_scope( - self, scope, deployment_name, custom_headers=None, raw=False, **operation_config): - """Cancels a currently running template deployment. + self, + scope, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """You can cancel a deployment only if the provisioningState is Accepted or Running. After the deployment is canceled, the provisioningState is set to Canceled. Canceling a template deployment stops the currently running template deployment and leaves the resources partially deployed. - You can cancel a deployment only if the provisioningState is Accepted - or Running. After the deployment is canceled, the provisioningState is - set to Canceled. Canceling a template deployment stops the currently - running template deployment and leaves the resources partially - deployed. + Cancels a currently running template deployment. :param scope: The resource scope. :type scope: str :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + # Construct URL - url = self.cancel_at_scope.metadata['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\._\(\)]+$') + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - cancel_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} - - def validate_at_scope( - self, scope, deployment_name, parameters, custom_headers=None, raw=False, **operation_config): - """Validates whether the specified template is syntactically correct and - will be accepted by Azure Resource Manager.. + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + cancel_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + + def _validate_at_scope_initial( + self, + scope, # type: str + deployment_name, # type: str + parameters, # type: "models.Deployment" + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentValidateResult" + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentValidateResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + content_type = kwargs.pop("content_type", "application/json") - :param scope: The resource scope. - :type scope: str - :param deployment_name: The name of the deployment. - :type deployment_name: str - :param parameters: Parameters to validate. - :type parameters: - ~azure.mgmt.resource.resources.v2019_10_01.models.Deployment - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentValidateResult or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentValidateResult - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` - """ # Construct URL - url = self.validate_at_scope.metadata['url'] + url = self._validate_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\._\(\)]+$') + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'Deployment') # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 - if response.status_code not in [200, 400]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + if response.status_code not in [200, 202, 400]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', response) + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', response) + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - validate_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} + _validate_at_scope_initial.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + def begin_validate_at_scope( + self, + scope, # type: str + deployment_name, # type: str + parameters, # type: "models.Deployment" + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. + + :param scope: The resource scope. + :type scope: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param parameters: Parameters to 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 polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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 DeploymentValidateResult + :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] + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentValidateResult"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = self._validate_at_scope_initial( + scope=scope, + deployment_name=deployment_name, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + 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 def export_template_at_scope( - self, scope, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + scope, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentExportResult" """Exports the template used for specified deployment. :param scope: The resource scope. :type scope: str :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentExportResult or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExportResult - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExportResult + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExportResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + # Construct URL - url = self.export_template_at_scope.metadata['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\._\(\)]+$') + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentExportResult', response) + deserialized = self._deserialize('DeploymentExportResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - export_template_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} + export_template_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore def list_at_scope( - self, scope, filter=None, top=None, custom_headers=None, raw=False, **operation_config): + self, + scope, # type: str + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.DeploymentListResult"] """Get all the deployments at the given scope. :param scope: The resource scope. :type scope: str - :param filter: The filter to apply on the operation. For example, you - can use $filter=provisioningState eq '{state}'. + :param filter: The filter to apply on the operation. For example, you can use + $filter=provisioningState eq '{state}'. :type filter: str - :param top: The number of results to get. If null is passed, returns - all deployments. + :param top: The number of results to get. If null is passed, returns all deployments. :type top: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of DeploymentExtended - :rtype: - ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtendedPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_at_scope.metadata['url'] + url = self.list_at_scope.metadata['url'] # type: ignore path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str') + 'scope': self._serialize.url("scope", scope, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.DeploymentExtendedPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/'} + return pipeline_response + return ItemPaged( + get_next, extract_data + ) + list_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/'} # type: ignore def _delete_at_tenant_scope_initial( - self, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + # Construct URL - url = self.delete_at_tenant_scope.metadata['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\._\(\)]+$') + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [202, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - - def delete_at_tenant_scope( - self, deployment_name, custom_headers=None, raw=False, polling=True, **operation_config): - """Deletes a deployment from the deployment history. - - A template deployment that is currently running cannot be deleted. - Deleting a template deployment removes the associated deployment - operations. This is an asynchronous operation that returns a status of - 202 until the template deployment is successfully deleted. The Location - response header contains the URI that is used to obtain the status of - the process. While the process is running, a call to the URI in the - Location header returns a status of 202. When the process finishes, the - URI in the Location header returns a status of 204 on success. If the - asynchronous request failed, the URI in the Location header returns an - error-level status code. + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_at_tenant_scope_initial.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + def begin_delete_at_tenant_scope( + self, + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """A template deployment that is currently running cannot be deleted. Deleting a template deployment removes the associated deployment operations. This is an asynchronous operation that returns a status of 202 until the template deployment is successfully deleted. The Location response header contains the URI that is used to obtain the status of the process. While the process is running, a call to the URI in the Location header returns a status of 202. When the process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. + + Deletes a deployment from the deployment history. :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns None or - ClientRawResponse if raw==True - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._delete_at_tenant_scope_initial( deployment_name=deployment_name, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - delete_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} + begin_delete_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore def check_existence_at_tenant_scope( - self, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Checks whether the deployment exists. :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: bool or ClientRawResponse if raw=true - :rtype: bool or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + # Construct URL - url = self.check_existence_at_tenant_scope.metadata['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\._\(\)]+$') + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204, 404]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = (response.status_code == 204) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - return deserialized - check_existence_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + 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, parameters, custom_headers=None, raw=False, **operation_config): + self, + deployment_name, # type: str + parameters, # type: "models.ScopedDeployment" + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentExtended" + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + content_type = kwargs.pop("content_type", "application/json") + # Construct URL - url = self.create_or_update_at_tenant_scope.metadata['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\._\(\)]+$') + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'ScopedDeployment') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 201]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', response) + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', response) + deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_at_tenant_scope_initial.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore - def create_or_update_at_tenant_scope( - self, deployment_name, parameters, custom_headers=None, raw=False, polling=True, **operation_config): - """Deploys resources at tenant scope. + def begin_create_or_update_at_tenant_scope( + self, + deployment_name, # type: str + parameters, # type: "models.ScopedDeployment" + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """You can provide the template and parameters directly in the request or link to JSON files. - You can provide the template and parameters directly in the request or - link to JSON files. + Deploys resources at tenant scope. :param deployment_name: The name of the deployment. :type deployment_name: str :param parameters: Additional parameters supplied to the operation. - :type parameters: - ~azure.mgmt.resource.resources.v2019_10_01.models.ScopedDeployment - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :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 polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns DeploymentExtended or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 DeploymentExtended + :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] + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._create_or_update_at_tenant_scope_initial( deployment_name=deployment_name, parameters=parameters, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - deserialized = self._deserialize('DeploymentExtended', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - create_or_update_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} + begin_create_or_update_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore def get_at_tenant_scope( - self, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentExtended" """Gets a deployment. :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentExtended or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExtended or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + # Construct URL - url = self.get_at_tenant_scope.metadata['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\._\(\)]+$') + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', response) + deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} + get_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore def cancel_at_tenant_scope( - self, deployment_name, custom_headers=None, raw=False, **operation_config): - """Cancels a currently running template deployment. + self, + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """You can cancel a deployment only if the provisioningState is Accepted or Running. After the deployment is canceled, the provisioningState is set to Canceled. Canceling a template deployment stops the currently running template deployment and leaves the resources partially deployed. - You can cancel a deployment only if the provisioningState is Accepted - or Running. After the deployment is canceled, the provisioningState is - set to Canceled. Canceling a template deployment stops the currently - running template deployment and leaves the resources partially - deployed. + Cancels a currently running template deployment. :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + # Construct URL - url = self.cancel_at_tenant_scope.metadata['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\._\(\)]+$') + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + 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 + parameters, # type: "models.ScopedDeployment" + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentValidateResult" + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentValidateResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + content_type = kwargs.pop("content_type", "application/json") - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - cancel_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} - - def validate_at_tenant_scope( - self, deployment_name, parameters, custom_headers=None, raw=False, **operation_config): - """Validates whether the specified template is syntactically correct and - will be accepted by Azure Resource Manager.. - - :param deployment_name: The name of the deployment. - :type deployment_name: str - :param parameters: Parameters to validate. - :type parameters: - ~azure.mgmt.resource.resources.v2019_10_01.models.ScopedDeployment - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentValidateResult or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentValidateResult - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` - """ # Construct URL - url = self.validate_at_tenant_scope.metadata['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\._\(\)]+$') + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'ScopedDeployment') # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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) - if response.status_code not in [200, 400]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 400]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', response) + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', response) + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - validate_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} + _validate_at_tenant_scope_initial.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + def begin_validate_at_tenant_scope( + self, + deployment_name, # type: str + parameters, # type: "models.ScopedDeployment" + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. + + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param parameters: Parameters to validate. + :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 polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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 DeploymentValidateResult + :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] + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentValidateResult"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = self._validate_at_tenant_scope_initial( + deployment_name=deployment_name, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + 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 export_template_at_tenant_scope( - self, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentExportResult" """Exports the template used for specified deployment. :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentExportResult or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExportResult - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExportResult + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExportResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + # Construct URL - url = self.export_template_at_tenant_scope.metadata['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\._\(\)]+$') + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentExportResult', response) + deserialized = self._deserialize('DeploymentExportResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - export_template_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} + export_template_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore def list_at_tenant_scope( - self, filter=None, top=None, custom_headers=None, raw=False, **operation_config): + self, + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.DeploymentListResult"] """Get all the deployments at the tenant scope. - :param filter: The filter to apply on the operation. For example, you - can use $filter=provisioningState eq '{state}'. + :param filter: The filter to apply on the operation. For example, you can use + $filter=provisioningState eq '{state}'. :type filter: str - :param top: The number of results to get. If null is passed, returns - all deployments. + :param top: The number of results to get. If null is passed, returns all deployments. :type top: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of DeploymentExtended - :rtype: - ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtendedPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_at_tenant_scope.metadata['url'] - + url = self.list_at_tenant_scope.metadata['url'] # type: ignore # Construct parameters - query_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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.DeploymentExtendedPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/'} + return pipeline_response + return ItemPaged( + get_next, extract_data + ) + list_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/'} # type: ignore def _delete_at_management_group_scope_initial( - self, group_id, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + # Construct URL - url = self.delete_at_management_group_scope.metadata['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\._\(\)]+$') + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [202, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - - def delete_at_management_group_scope( - self, group_id, deployment_name, custom_headers=None, raw=False, polling=True, **operation_config): - """Deletes a deployment from the deployment history. - - A template deployment that is currently running cannot be deleted. - Deleting a template deployment removes the associated deployment - operations. This is an asynchronous operation that returns a status of - 202 until the template deployment is successfully deleted. The Location - response header contains the URI that is used to obtain the status of - the process. While the process is running, a call to the URI in the - Location header returns a status of 202. When the process finishes, the - URI in the Location header returns a status of 204 on success. If the - asynchronous request failed, the URI in the Location header returns an - error-level status code. + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_at_management_group_scope_initial.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + def begin_delete_at_management_group_scope( + self, + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """A template deployment that is currently running cannot be deleted. Deleting a template deployment removes the associated deployment operations. This is an asynchronous operation that returns a status of 202 until the template deployment is successfully deleted. The Location response header contains the URI that is used to obtain the status of the process. While the process is running, a call to the URI in the Location header returns a status of 202. When the process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. + + Deletes a deployment from the deployment history. :param group_id: The management group ID. :type group_id: str :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns None or - ClientRawResponse if raw==True - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._delete_at_management_group_scope_initial( group_id=group_id, deployment_name=deployment_name, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - delete_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} + begin_delete_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore def check_existence_at_management_group_scope( - self, group_id, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Checks whether the deployment exists. :param group_id: The management group ID. :type group_id: str :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: bool or ClientRawResponse if raw=true - :rtype: bool or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + # Construct URL - url = self.check_existence_at_management_group_scope.metadata['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\._\(\)]+$') + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204, 404]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = (response.status_code == 204) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - return deserialized - check_existence_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + 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, deployment_name, parameters, custom_headers=None, raw=False, **operation_config): + self, + group_id, # type: str + deployment_name, # type: str + parameters, # type: "models.ScopedDeployment" + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentExtended" + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + content_type = kwargs.pop("content_type", "application/json") + # Construct URL - url = self.create_or_update_at_management_group_scope.metadata['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\._\(\)]+$') + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'ScopedDeployment') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 201]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', response) + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', response) + deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + 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 - def create_or_update_at_management_group_scope( - self, group_id, deployment_name, parameters, custom_headers=None, raw=False, polling=True, **operation_config): - """Deploys resources at management group scope. + def begin_create_or_update_at_management_group_scope( + self, + group_id, # type: str + deployment_name, # type: str + parameters, # type: "models.ScopedDeployment" + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """You can provide the template and parameters directly in the request or link to JSON files. - You can provide the template and parameters directly in the request or - link to JSON files. + Deploys resources at management group scope. :param group_id: The management group ID. :type group_id: str :param deployment_name: The name of the deployment. :type deployment_name: str :param parameters: Additional parameters supplied to the operation. - :type parameters: - ~azure.mgmt.resource.resources.v2019_10_01.models.ScopedDeployment - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :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 polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns DeploymentExtended or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 DeploymentExtended + :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] + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._create_or_update_at_management_group_scope_initial( group_id=group_id, deployment_name=deployment_name, parameters=parameters, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - deserialized = self._deserialize('DeploymentExtended', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - create_or_update_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} + begin_create_or_update_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore def get_at_management_group_scope( - self, group_id, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentExtended" """Gets a deployment. :param group_id: The management group ID. :type group_id: str :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentExtended or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExtended or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + # Construct URL - url = self.get_at_management_group_scope.metadata['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\._\(\)]+$') + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', response) + deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} + get_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore def cancel_at_management_group_scope( - self, group_id, deployment_name, custom_headers=None, raw=False, **operation_config): - """Cancels a currently running template deployment. + self, + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """You can cancel a deployment only if the provisioningState is Accepted or Running. After the deployment is canceled, the provisioningState is set to Canceled. Canceling a template deployment stops the currently running template deployment and leaves the resources partially deployed. - You can cancel a deployment only if the provisioningState is Accepted - or Running. After the deployment is canceled, the provisioningState is - set to Canceled. Canceling a template deployment stops the currently - running template deployment and leaves the resources partially - deployed. + Cancels a currently running template deployment. :param group_id: The management group ID. :type group_id: str :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + # Construct URL - url = self.cancel_at_management_group_scope.metadata['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\._\(\)]+$') + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - cancel_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} - - def validate_at_management_group_scope( - self, group_id, deployment_name, parameters, custom_headers=None, raw=False, **operation_config): - """Validates whether the specified template is syntactically correct and - will be accepted by Azure Resource Manager.. + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + 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 + deployment_name, # type: str + parameters, # type: "models.ScopedDeployment" + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentValidateResult" + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentValidateResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + content_type = kwargs.pop("content_type", "application/json") - :param group_id: The management group ID. - :type group_id: str - :param deployment_name: The name of the deployment. - :type deployment_name: str - :param parameters: Parameters to validate. - :type parameters: - ~azure.mgmt.resource.resources.v2019_10_01.models.ScopedDeployment - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentValidateResult or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentValidateResult - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` - """ # Construct URL - url = self.validate_at_management_group_scope.metadata['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\._\(\)]+$') + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'ScopedDeployment') # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 - if response.status_code not in [200, 400]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + if response.status_code not in [200, 202, 400]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', response) + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', response) + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + 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'} + _validate_at_management_group_scope_initial.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + def begin_validate_at_management_group_scope( + self, + group_id, # type: str + deployment_name, # type: str + parameters, # type: "models.ScopedDeployment" + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. + + :param group_id: The management group ID. + :type group_id: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param parameters: Parameters to validate. + :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 polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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 DeploymentValidateResult + :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] + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentValidateResult"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = self._validate_at_management_group_scope_initial( + group_id=group_id, + deployment_name=deployment_name, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + 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 export_template_at_management_group_scope( - self, group_id, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + group_id, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentExportResult" """Exports the template used for specified deployment. :param group_id: The management group ID. :type group_id: str :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentExportResult or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExportResult - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExportResult + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExportResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + # Construct URL - url = self.export_template_at_management_group_scope.metadata['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\._\(\)]+$') + 'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern=r'^[-\w\._\(\)]+$'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentExportResult', response) + deserialized = self._deserialize('DeploymentExportResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + 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'} + export_template_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore def list_at_management_group_scope( - self, group_id, filter=None, top=None, custom_headers=None, raw=False, **operation_config): + self, + group_id, # type: str + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.DeploymentListResult"] """Get all the deployments for a management group. :param group_id: The management group ID. :type group_id: str - :param filter: The filter to apply on the operation. For example, you - can use $filter=provisioningState eq '{state}'. + :param filter: The filter to apply on the operation. For example, you can use + $filter=provisioningState eq '{state}'. :type filter: str - :param top: The number of results to get. If null is passed, returns - all deployments. + :param top: The number of results to get. If null is passed, returns all deployments. :type top: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of DeploymentExtended - :rtype: - ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtendedPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_at_management_group_scope.metadata['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) + '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 = {} + 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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.DeploymentExtendedPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/'} + 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/'} # type: ignore def _delete_at_subscription_scope_initial( - self, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + # Construct URL - url = self.delete_at_subscription_scope.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [202, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - - def delete_at_subscription_scope( - self, deployment_name, custom_headers=None, raw=False, polling=True, **operation_config): - """Deletes a deployment from the deployment history. - - A template deployment that is currently running cannot be deleted. - Deleting a template deployment removes the associated deployment - operations. This is an asynchronous operation that returns a status of - 202 until the template deployment is successfully deleted. The Location - response header contains the URI that is used to obtain the status of - the process. While the process is running, a call to the URI in the - Location header returns a status of 202. When the process finishes, the - URI in the Location header returns a status of 204 on success. If the - asynchronous request failed, the URI in the Location header returns an - error-level status code. + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + def begin_delete_at_subscription_scope( + self, + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """A template deployment that is currently running cannot be deleted. Deleting a template deployment removes the associated deployment operations. This is an asynchronous operation that returns a status of 202 until the template deployment is successfully deleted. The Location response header contains the URI that is used to obtain the status of the process. While the process is running, a call to the URI in the Location header returns a status of 202. When the process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. + + Deletes a deployment from the deployment history. :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns None or - ClientRawResponse if raw==True - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._delete_at_subscription_scope_initial( deployment_name=deployment_name, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - delete_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} + begin_delete_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore def check_existence_at_subscription_scope( - self, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Checks whether the deployment exists. :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: bool or ClientRawResponse if raw=true - :rtype: bool or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + # Construct URL - url = self.check_existence_at_subscription_scope.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204, 404]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = (response.status_code == 204) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - return deserialized - check_existence_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + if cls: + return cls(pipeline_response, None, {}) + + 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, parameters, custom_headers=None, raw=False, **operation_config): + self, + deployment_name, # type: str + parameters, # type: "models.Deployment" + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentExtended" + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + content_type = kwargs.pop("content_type", "application/json") + # Construct URL - url = self.create_or_update_at_subscription_scope.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'Deployment') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 201]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', response) + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', response) + deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + 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 - def create_or_update_at_subscription_scope( - self, deployment_name, parameters, custom_headers=None, raw=False, polling=True, **operation_config): - """Deploys resources at subscription scope. + def begin_create_or_update_at_subscription_scope( + self, + deployment_name, # type: str + parameters, # type: "models.Deployment" + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """You can provide the template and parameters directly in the request or link to JSON files. - You can provide the template and parameters directly in the request or - link to JSON files. + Deploys resources at subscription scope. :param deployment_name: The name of the deployment. :type deployment_name: str :param parameters: Additional parameters supplied to the operation. - :type parameters: - ~azure.mgmt.resource.resources.v2019_10_01.models.Deployment - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :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 polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns DeploymentExtended or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 DeploymentExtended + :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] + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._create_or_update_at_subscription_scope_initial( deployment_name=deployment_name, parameters=parameters, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - deserialized = self._deserialize('DeploymentExtended', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - create_or_update_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} + begin_create_or_update_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore def get_at_subscription_scope( - self, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentExtended" """Gets a deployment. :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentExtended or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExtended or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + # Construct URL - url = self.get_at_subscription_scope.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', response) + deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} + get_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore def cancel_at_subscription_scope( - self, deployment_name, custom_headers=None, raw=False, **operation_config): - """Cancels a currently running template deployment. + self, + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """You can cancel a deployment only if the provisioningState is Accepted or Running. After the deployment is canceled, the provisioningState is set to Canceled. Canceling a template deployment stops the currently running template deployment and leaves the resources partially deployed. - You can cancel a deployment only if the provisioningState is Accepted - or Running. After the deployment is canceled, the provisioningState is - set to Canceled. Canceling a template deployment stops the currently - running template deployment and leaves the resources partially - deployed. + Cancels a currently running template deployment. :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + # Construct URL - url = self.cancel_at_subscription_scope.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + 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 + parameters, # type: "models.Deployment" + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentValidateResult" + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentValidateResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + content_type = kwargs.pop("content_type", "application/json") - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - cancel_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} - - def validate_at_subscription_scope( - self, deployment_name, parameters, custom_headers=None, raw=False, **operation_config): - """Validates whether the specified template is syntactically correct and - will be accepted by Azure Resource Manager.. - - :param deployment_name: The name of the deployment. - :type deployment_name: str - :param parameters: Parameters to validate. - :type parameters: - ~azure.mgmt.resource.resources.v2019_10_01.models.Deployment - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentValidateResult or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentValidateResult - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` - """ # Construct URL - url = self.validate_at_subscription_scope.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'Deployment') # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 - if response.status_code not in [200, 400]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + if response.status_code not in [200, 202, 400]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', response) + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', response) + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - validate_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} + _validate_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + def begin_validate_at_subscription_scope( + self, + deployment_name, # type: str + parameters, # type: "models.Deployment" + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param parameters: Parameters to 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 polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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 DeploymentValidateResult + :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] + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentValidateResult"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = self._validate_at_subscription_scope_initial( + deployment_name=deployment_name, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + 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( - self, deployment_name, properties, location=None, custom_headers=None, raw=False, **operation_config): - parameters = models.DeploymentWhatIf(location=location, properties=properties) + self, + deployment_name, # type: str + properties, # type: "models.DeploymentWhatIfProperties" + location=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.WhatIfOperationResult" + cls = kwargs.pop('cls', None) # type: ClsType["models.WhatIfOperationResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.DeploymentWhatIf(location=location, properties=properties) + api_version = "2019-10-01" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.what_if_at_subscription_scope.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'DeploymentWhatIf') # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 202]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} deserialized = None - header_dict = {} - if response.status_code == 200: - deserialized = self._deserialize('WhatIfOperationResult', response) - header_dict = { - 'Location': 'str', - 'Retry-After': 'str', - } + deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_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')) - return deserialized + if cls: + return cls(pipeline_response, deserialized, response_headers) - def what_if_at_subscription_scope( - self, deployment_name, properties, location=None, custom_headers=None, raw=False, polling=True, **operation_config): - """Returns changes that will be made by the deployment if executed at the - scope of the subscription. + return deserialized + _what_if_at_subscription_scope_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + + def begin_what_if_at_subscription_scope( + self, + deployment_name, # type: str + properties, # type: "models.DeploymentWhatIfProperties" + location=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """Returns changes that will be made by the deployment if executed at the scope of the subscription. :param deployment_name: The name of the deployment. :type deployment_name: str :param properties: The deployment properties. - :type properties: - ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentWhatIfProperties + :type properties: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentWhatIfProperties :param location: The location to store the deployment data. :type location: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy + :paramtype polling: bool or ~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 WhatIfOperationResult - or ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.resource.resources.v2019_10_01.models.WhatIfOperationResult] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.resource.resources.v2019_10_01.models.WhatIfOperationResult]] - :raises: :class:`CloudError` + :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] + cls = kwargs.pop('cls', None) # type: ClsType["models.WhatIfOperationResult"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._what_if_at_subscription_scope_initial( deployment_name=deployment_name, properties=properties, location=location, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - header_dict = { - 'Location': 'str', - 'Retry-After': 'str', - } - deserialized = self._deserialize('WhatIfOperationResult', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **operation_config) + 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 return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - what_if_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} + begin_what_if_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore def export_template_at_subscription_scope( - self, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentExportResult" """Exports the template used for specified deployment. :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentExportResult or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExportResult - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExportResult + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExportResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + # Construct URL - url = self.export_template_at_subscription_scope.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentExportResult', response) + deserialized = self._deserialize('DeploymentExportResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - export_template_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} + export_template_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore def list_at_subscription_scope( - self, filter=None, top=None, custom_headers=None, raw=False, **operation_config): + self, + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.DeploymentListResult"] """Get all the deployments for a subscription. - :param filter: The filter to apply on the operation. For example, you - can use $filter=provisioningState eq '{state}'. + :param filter: The filter to apply on the operation. For example, you can use + $filter=provisioningState eq '{state}'. :type filter: str - :param top: The number of results to get. If null is passed, returns - all deployments. + :param top: The number of results to get. If null is passed, returns all deployments. :type top: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of DeploymentExtended - :rtype: - ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtendedPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_at_subscription_scope.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.DeploymentExtendedPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/'} + return pipeline_response + return ItemPaged( + get_next, extract_data + ) + list_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/'} # type: ignore def _delete_initial( - self, resource_group_name, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + # Construct URL - url = self.delete.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [202, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - - def delete( - self, resource_group_name, deployment_name, custom_headers=None, raw=False, polling=True, **operation_config): - """Deletes a deployment from the deployment history. - - A template deployment that is currently running cannot be deleted. - Deleting a template deployment removes the associated deployment - operations. Deleting a template deployment does not affect the state of - the resource group. This is an asynchronous operation that returns a - status of 202 until the template deployment is successfully deleted. - The Location response header contains the URI that is used to obtain - the status of the process. While the process is running, a call to the - URI in the Location header returns a status of 202. When the process - finishes, the URI in the Location header returns a status of 204 on - success. If the asynchronous request failed, the URI in the Location - header returns an error-level status code. - - :param resource_group_name: The name of the resource group with the - deployment to delete. The name is case insensitive. + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + def begin_delete( + self, + resource_group_name, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """A template deployment that is currently running cannot be deleted. Deleting a template deployment removes the associated deployment operations. Deleting a template deployment does not affect the state of the resource group. This is an asynchronous operation that returns a status of 202 until the template deployment is successfully deleted. The Location response header contains the URI that is used to obtain the status of the process. While the process is running, a call to the URI in the Location header returns a status of 202. When the process finishes, the URI in the Location header returns a status of 204 on success. If the asynchronous request failed, the URI in the Location header returns an error-level status code. + + Deletes a deployment from the deployment history. + + :param resource_group_name: The name of the resource group with the deployment to delete. The + name is case insensitive. :type resource_group_name: str :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns None or - ClientRawResponse if raw==True - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._delete_initial( resource_group_name=resource_group_name, deployment_name=deployment_name, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore def check_existence( - self, resource_group_name, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Checks whether the deployment exists. - :param resource_group_name: The name of the resource group with the - deployment to check. The name is case insensitive. + :param resource_group_name: The name of the resource group with the deployment to check. The + name is case insensitive. :type resource_group_name: str :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: bool or ClientRawResponse if raw=true - :rtype: bool or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + # Construct URL - url = self.check_existence.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204, 404]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = (response.status_code == 204) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - return deserialized - check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + 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, deployment_name, parameters, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + deployment_name, # type: str + parameters, # type: "models.Deployment" + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentExtended" + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + content_type = kwargs.pop("content_type", "application/json") + # Construct URL - url = self.create_or_update.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'Deployment') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 201]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', response) + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('DeploymentExtended', response) + deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - - def create_or_update( - self, resource_group_name, deployment_name, parameters, custom_headers=None, raw=False, polling=True, **operation_config): - """Deploys resources to a resource group. - - You can provide the template and parameters directly in the request or - link to JSON files. - - :param resource_group_name: The name of the resource group to deploy - the resources to. The name is case insensitive. The resource group - must already exist. + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore + + def begin_create_or_update( + self, + resource_group_name, # type: str + deployment_name, # type: str + parameters, # type: "models.Deployment" + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """You can provide the template and parameters directly in the request or link to JSON files. + + Deploys resources to a resource group. + + :param resource_group_name: The name of the resource group to deploy the resources to. The name + is case insensitive. The resource group must already exist. :type resource_group_name: str :param deployment_name: The name of the deployment. :type deployment_name: str :param parameters: Additional parameters supplied to the operation. - :type parameters: - ~azure.mgmt.resource.resources.v2019_10_01.models.Deployment - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :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 polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns DeploymentExtended or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 DeploymentExtended + :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] + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._create_or_update_initial( resource_group_name=resource_group_name, deployment_name=deployment_name, parameters=parameters, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - deserialized = self._deserialize('DeploymentExtended', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('DeploymentExtended', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore def get( - self, resource_group_name, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentExtended" """Gets a deployment. - :param resource_group_name: The name of the resource group. The name - is case insensitive. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentExtended or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExtended or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExtended"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + # Construct URL - url = self.get.metadata['url'] + url = self.get.metadata['url'] # type: 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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentExtended', response) + deserialized = self._deserialize('DeploymentExtended', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'} # type: ignore def cancel( - self, resource_group_name, deployment_name, custom_headers=None, raw=False, **operation_config): - """Cancels a currently running template deployment. + self, + resource_group_name, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """You can cancel a deployment only if the provisioningState is Accepted or Running. After the deployment is canceled, the provisioningState is set to Canceled. Canceling a template deployment stops the currently running template deployment and leaves the resource group partially deployed. - You can cancel a deployment only if the provisioningState is Accepted - or Running. After the deployment is canceled, the provisioningState is - set to Canceled. Canceling a template deployment stops the currently - running template deployment and leaves the resource group partially - deployed. + Cancels a currently running template deployment. - :param resource_group_name: The name of the resource group. The name - is case insensitive. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + # Construct URL - url = self.cancel.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - cancel.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} - - def validate( - self, resource_group_name, deployment_name, parameters, custom_headers=None, raw=False, **operation_config): - """Validates whether the specified template is syntactically correct and - will be accepted by Azure Resource Manager.. - - :param resource_group_name: The name of the resource group the - template will be deployed to. The name is case insensitive. - :type resource_group_name: str - :param deployment_name: The name of the deployment. - :type deployment_name: str - :param parameters: Parameters to validate. - :type parameters: - ~azure.mgmt.resource.resources.v2019_10_01.models.Deployment - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentValidateResult or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentValidateResult - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` - """ + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + cancel.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel'} # type: ignore + + def _validate_initial( + self, + resource_group_name, # type: str + deployment_name, # type: str + parameters, # type: "models.Deployment" + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentValidateResult" + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentValidateResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + content_type = kwargs.pop("content_type", "application/json") + # Construct URL - url = self.validate.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'Deployment') # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 - if response.status_code not in [200, 400]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + if response.status_code not in [200, 202, 400]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('DeploymentValidateResult', response) + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + if response.status_code == 400: - deserialized = self._deserialize('DeploymentValidateResult', response) + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - validate.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} + _validate_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate'} # type: ignore + + def begin_validate( + self, + resource_group_name, # type: str + deployment_name, # type: str + parameters, # type: "models.Deployment" + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. + :type resource_group_name: str + :param deployment_name: The name of the deployment. + :type deployment_name: str + :param parameters: Parameters to 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 polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~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 DeploymentValidateResult + :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] + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentValidateResult"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = self._validate_initial( + resource_group_name=resource_group_name, + deployment_name=deployment_name, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('DeploymentValidateResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + 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( - self, resource_group_name, deployment_name, properties, location=None, custom_headers=None, raw=False, **operation_config): - parameters = models.DeploymentWhatIf(location=location, properties=properties) + self, + resource_group_name, # type: str + deployment_name, # type: str + properties, # type: "models.DeploymentWhatIfProperties" + location=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.WhatIfOperationResult" + cls = kwargs.pop('cls', None) # type: ClsType["models.WhatIfOperationResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.DeploymentWhatIf(location=location, properties=properties) + api_version = "2019-10-01" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.what_if.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'DeploymentWhatIf') # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 202]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + response_headers = {} deserialized = None - header_dict = {} - if response.status_code == 200: - deserialized = self._deserialize('WhatIfOperationResult', response) - header_dict = { - 'Location': 'str', - 'Retry-After': 'str', - } - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) - return deserialized + 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')) - def what_if( - self, resource_group_name, deployment_name, properties, location=None, custom_headers=None, raw=False, polling=True, **operation_config): - """Returns changes that will be made by the deployment if executed at the - scope of the resource group. + if cls: + return cls(pipeline_response, deserialized, response_headers) - :param resource_group_name: The name of the resource group the - template will be deployed to. The name is case insensitive. + return deserialized + _what_if_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore + + def begin_what_if( + self, + resource_group_name, # type: str + deployment_name, # type: str + properties, # type: "models.DeploymentWhatIfProperties" + location=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """Returns changes that will be made by the deployment if executed at the scope of the resource group. + + :param resource_group_name: The name of the resource group the template will be deployed to. + The name is case insensitive. :type resource_group_name: str :param deployment_name: The name of the deployment. :type deployment_name: str :param properties: The deployment properties. - :type properties: - ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentWhatIfProperties + :type properties: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentWhatIfProperties :param location: The location to store the deployment data. :type location: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy + :paramtype polling: bool or ~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 WhatIfOperationResult - or ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.resource.resources.v2019_10_01.models.WhatIfOperationResult] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.resource.resources.v2019_10_01.models.WhatIfOperationResult]] - :raises: :class:`CloudError` + :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] + cls = kwargs.pop('cls', None) # type: ClsType["models.WhatIfOperationResult"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._what_if_initial( resource_group_name=resource_group_name, deployment_name=deployment_name, properties=properties, location=location, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - header_dict = { - 'Location': 'str', - 'Retry-After': 'str', - } - deserialized = self._deserialize('WhatIfOperationResult', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('WhatIfOperationResult', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **operation_config) + 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 return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - what_if.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} + begin_what_if.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/whatIf'} # type: ignore def export_template( - self, resource_group_name, deployment_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + deployment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DeploymentExportResult" """Exports the template used for specified deployment. - :param resource_group_name: The name of the resource group. The name - is case insensitive. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param deployment_name: The name of the deployment. :type deployment_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DeploymentExportResult or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExportResult - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeploymentExportResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExportResult + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeploymentExportResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + # Construct URL - url = self.export_template.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DeploymentExportResult', response) + deserialized = self._deserialize('DeploymentExportResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} + export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate'} # type: ignore def list_by_resource_group( - self, resource_group_name, filter=None, top=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.DeploymentListResult"] """Get all the deployments for a resource group. - :param resource_group_name: The name of the resource group with the - deployments to get. The name is case insensitive. + :param resource_group_name: The name of the resource group with the deployments to get. The + name is case insensitive. :type resource_group_name: str - :param filter: The filter to apply on the operation. For example, you - can use $filter=provisioningState eq '{state}'. + :param filter: The filter to apply on the operation. For example, you can use + $filter=provisioningState eq '{state}'. :type filter: str - :param top: The number of results to get. If null is passed, returns - all deployments. + :param top: The number of results to get. If null is passed, returns all deployments. :type top: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of DeploymentExtended - :rtype: - ~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtendedPaged[~azure.mgmt.resource.resources.v2019_10_01.models.DeploymentExtended] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_by_resource_group.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('DeploymentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.DeploymentExtendedPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/'} + return ItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/'} # type: ignore def calculate_template_hash( - self, template, custom_headers=None, raw=False, **operation_config): + self, + template, # type: object + **kwargs # type: Any + ): + # type: (...) -> "models.TemplateHashResult" """Calculate the hash of the given template. :param template: The template provided to calculate hash. :type template: object - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: TemplateHashResult or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_10_01.models.TemplateHashResult - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TemplateHashResult or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.TemplateHashResult + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TemplateHashResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + content_type = kwargs.pop("content_type", "application/json") + # Construct URL - url = self.calculate_template_hash.metadata['url'] + url = self.calculate_template_hash.metadata['url'] # type: ignore # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(template, 'object') # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('TemplateHashResult', response) + deserialized = self._deserialize('TemplateHashResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - calculate_template_hash.metadata = {'url': '/providers/Microsoft.Resources/calculateTemplateHash'} + 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 08402ad733ee..877fe243f842 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 @@ -1,102 +1,106 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class Operations(object): """Operations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2019_10_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for this operation. Constant value: "2019-10-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-10-01" - - self.config = config + self._config = config def list( - self, custom_headers=None, raw=False, **operation_config): + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.OperationListResult"] """Lists all of the available Microsoft.Resources REST API operations. - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of Operation - :rtype: - ~azure.mgmt.resource.resources.v2019_10_01.models.OperationPaged[~azure.mgmt.resource.resources.v2019_10_01.models.Operation] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of OperationListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['url'] - + url = self.list.metadata['url'] # type: ignore # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('OperationListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.OperationPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list.metadata = {'url': '/providers/Microsoft.Resources/operations'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.Resources/operations'} # type: ignore 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 c101a48bde0c..83c5aaa6d6cd 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 @@ -1,437 +1,417 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class ProvidersOperations(object): """ProvidersOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2019_10_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for this operation. Constant value: "2019-10-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-10-01" - - self.config = config + self._config = config def unregister( - self, resource_provider_namespace, custom_headers=None, raw=False, **operation_config): + self, + resource_provider_namespace, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.Provider" """Unregisters a subscription from a resource provider. - :param resource_provider_namespace: The namespace of the resource - provider to unregister. + :param resource_provider_namespace: The namespace of the resource provider to unregister. :type resource_provider_namespace: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: Provider or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.Provider or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Provider or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.Provider + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Provider"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + # Construct URL - url = self.unregister.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('Provider', response) + deserialized = self._deserialize('Provider', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - unregister.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister'} + unregister.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister'} # type: ignore def register( - self, resource_provider_namespace, custom_headers=None, raw=False, **operation_config): + self, + resource_provider_namespace, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.Provider" """Registers a subscription with a resource provider. - :param resource_provider_namespace: The namespace of the resource - provider to register. + :param resource_provider_namespace: The namespace of the resource provider to register. :type resource_provider_namespace: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: Provider or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.Provider or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Provider or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.Provider + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Provider"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + # Construct URL - url = self.register.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('Provider', response) + deserialized = self._deserialize('Provider', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - register.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register'} + register.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register'} # type: ignore def list( - self, top=None, expand=None, custom_headers=None, raw=False, **operation_config): + self, + top=None, # type: Optional[int] + expand=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.ProviderListResult"] """Gets all resource providers for a subscription. - :param top: The number of results to return. If null is passed returns - all deployments. + :param top: The number of results to return. If null is passed returns all deployments. :type top: int - :param expand: The properties to include in the results. For example, - use &$expand=metadata in the query string to retrieve resource - provider metadata. To include property aliases in response, use - $expand=resourceTypes/aliases. + :param expand: The properties to include in the results. For example, use &$expand=metadata in + the query string to retrieve resource provider metadata. To include property aliases in + response, use $expand=resourceTypes/aliases. :type expand: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of Provider - :rtype: - ~azure.mgmt.resource.resources.v2019_10_01.models.ProviderPaged[~azure.mgmt.resource.resources.v2019_10_01.models.Provider] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of ProviderListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['url'] + url = self.list.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_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 = {} + 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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('ProviderListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.ProviderPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers'} # type: ignore def list_at_tenant_scope( - self, top=None, expand=None, custom_headers=None, raw=False, **operation_config): + self, + top=None, # type: Optional[int] + expand=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.ProviderListResult"] """Gets all resource providers for the tenant. - :param top: The number of results to return. If null is passed returns - all providers. + :param top: The number of results to return. If null is passed returns all providers. :type top: int - :param expand: The properties to include in the results. For example, - use &$expand=metadata in the query string to retrieve resource - provider metadata. To include property aliases in response, use - $expand=resourceTypes/aliases. + :param expand: The properties to include in the results. For example, use &$expand=metadata in + the query string to retrieve resource provider metadata. To include property aliases in + response, use $expand=resourceTypes/aliases. :type expand: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of Provider - :rtype: - ~azure.mgmt.resource.resources.v2019_10_01.models.ProviderPaged[~azure.mgmt.resource.resources.v2019_10_01.models.Provider] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of ProviderListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_at_tenant_scope.metadata['url'] - + url = self.list_at_tenant_scope.metadata['url'] # type: ignore # Construct parameters - query_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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('ProviderListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.ProviderPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_at_tenant_scope.metadata = {'url': '/providers'} + return ItemPaged( + get_next, extract_data + ) + list_at_tenant_scope.metadata = {'url': '/providers'} # type: ignore def get( - self, resource_provider_namespace, expand=None, custom_headers=None, raw=False, **operation_config): + self, + resource_provider_namespace, # type: str + expand=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.Provider" """Gets the specified resource provider. - :param resource_provider_namespace: The namespace of the resource - provider. + :param resource_provider_namespace: The namespace of the resource provider. :type resource_provider_namespace: str - :param expand: The $expand query parameter. For example, to include - property aliases in response, use $expand=resourceTypes/aliases. + :param expand: The $expand query parameter. For example, to include property aliases in + response, use $expand=resourceTypes/aliases. :type expand: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: Provider or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.Provider or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Provider or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.Provider + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Provider"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + # Construct URL - url = self.get.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('Provider', response) + deserialized = self._deserialize('Provider', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}'} # type: ignore def get_at_tenant_scope( - self, resource_provider_namespace, expand=None, custom_headers=None, raw=False, **operation_config): + self, + resource_provider_namespace, # type: str + expand=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.Provider" """Gets the specified resource provider at the tenant level. - :param resource_provider_namespace: The namespace of the resource - provider. + :param resource_provider_namespace: The namespace of the resource provider. :type resource_provider_namespace: str - :param expand: The $expand query parameter. For example, to include - property aliases in response, use $expand=resourceTypes/aliases. + :param expand: The $expand query parameter. For example, to include property aliases in + response, use $expand=resourceTypes/aliases. :type expand: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: Provider or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.Provider or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Provider or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.Provider + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Provider"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + # Construct URL - url = self.get_at_tenant_scope.metadata['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') + 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('Provider', response) + deserialized = self._deserialize('Provider', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get_at_tenant_scope.metadata = {'url': '/providers/{resourceProviderNamespace}'} + 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 b61989570e8a..b8008c371d1d 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 @@ -1,563 +1,558 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError -from msrest.polling import LROPoller, NoPolling -from msrestazure.polling.arm_polling import ARMPolling +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, List, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class ResourceGroupsOperations(object): """ResourceGroupsOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2019_10_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for this operation. Constant value: "2019-10-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-10-01" - - self.config = config + self._config = config def check_existence( - self, resource_group_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Checks whether a resource group exists. - :param resource_group_name: The name of the resource group to check. - The name is case insensitive. + :param resource_group_name: The name of the resource group to check. The name is case + insensitive. :type resource_group_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: bool or ClientRawResponse if raw=true - :rtype: bool or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + # Construct URL - url = self.check_existence.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204, 404]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = (response.status_code == 204) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - return deserialized - check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + return 200 <= response.status_code <= 299 + check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore def create_or_update( - self, resource_group_name, parameters, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + parameters, # type: "models.ResourceGroup" + **kwargs # type: Any + ): + # type: (...) -> "models.ResourceGroup" """Creates or updates a resource group. - :param resource_group_name: The name of the resource group to create - or update. Can include alphanumeric, underscore, parentheses, hyphen, - period (except at end), and Unicode characters that match the allowed - characters. + :param resource_group_name: The name of the resource group to create or update. Can include + alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters + that match the allowed characters. :type resource_group_name: str - :param parameters: Parameters supplied to the create or update a - resource group. - :type parameters: - ~azure.mgmt.resource.resources.v2019_10_01.models.ResourceGroup - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: ResourceGroup or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_10_01.models.ResourceGroup or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :param parameters: Parameters supplied to the create or update a resource group. + :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.ResourceGroup + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.ResourceGroup + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceGroup"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + content_type = kwargs.pop("content_type", "application/json") + # Construct URL - url = self.create_or_update.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'ResourceGroup') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 201]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ResourceGroup', response) + deserialized = self._deserialize('ResourceGroup', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('ResourceGroup', response) + deserialized = self._deserialize('ResourceGroup', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} - + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore def _delete_initial( - self, resource_group_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + # Construct URL - url = self.delete.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 202]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + if cls: + return cls(pipeline_response, None, {}) - def delete( - self, resource_group_name, custom_headers=None, raw=False, polling=True, **operation_config): - """Deletes a resource group. + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore - When you delete a resource group, all of its resources are also - deleted. Deleting a resource group deletes all of its template - deployments and currently stored operations. + def begin_delete( + self, + resource_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """When you delete a resource group, all of its resources are also deleted. Deleting a resource group deletes all of its template deployments and currently stored operations. - :param resource_group_name: The name of the resource group to delete. - The name is case insensitive. + Deletes a resource group. + + :param resource_group_name: The name of the resource group to delete. The name is case + insensitive. :type resource_group_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns None or - ClientRawResponse if raw==True - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._delete_initial( resource_group_name=resource_group_name, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore def get( - self, resource_group_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.ResourceGroup" """Gets a resource group. - :param resource_group_name: The name of the resource group to get. The - name is case insensitive. + :param resource_group_name: The name of the resource group to get. The name is case + insensitive. :type resource_group_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: ResourceGroup or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_10_01.models.ResourceGroup or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.ResourceGroup + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceGroup"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + # Construct URL - url = self.get.metadata['url'] + url = self.get.metadata['url'] # type: 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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('ResourceGroup', response) + deserialized = self._deserialize('ResourceGroup', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore def update( - self, resource_group_name, parameters, custom_headers=None, raw=False, **operation_config): - """Updates a resource group. - - Resource groups can be updated through a simple PATCH operation to a - group address. The format of the request is the same as that for - creating a resource group. If a field is unspecified, the current value - is retained. - - :param resource_group_name: The name of the resource group to update. - The name is case insensitive. + self, + resource_group_name, # type: str + parameters, # type: "models.ResourceGroupPatchable" + **kwargs # type: Any + ): + # type: (...) -> "models.ResourceGroup" + """Resource groups can be updated through a simple PATCH operation to a group address. The format of the request is the same as that for creating a resource group. If a field is unspecified, the current value is retained. + + Updates a resource group. + + :param resource_group_name: The name of the resource group to update. The name is case + insensitive. :type resource_group_name: str :param parameters: Parameters supplied to update a resource group. - :type parameters: - ~azure.mgmt.resource.resources.v2019_10_01.models.ResourceGroupPatchable - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: ResourceGroup or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_10_01.models.ResourceGroup or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :type parameters: ~azure.mgmt.resource.resources.v2019_10_01.models.ResourceGroupPatchable + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceGroup or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.ResourceGroup + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceGroup"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + content_type = kwargs.pop("content_type", "application/json") + # Construct URL - url = self.update.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'ResourceGroupPatchable') # Construct and send request - request = self._client.patch(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('ResourceGroup', response) + deserialized = self._deserialize('ResourceGroup', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} - + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}'} # type: ignore def _export_template_initial( - self, resource_group_name, resources=None, options=None, custom_headers=None, raw=False, **operation_config): - parameters = models.ExportTemplateRequest(resources=resources, options=options) + self, + resource_group_name, # type: str + resources=None, # type: Optional[List[str]] + options=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.ResourceGroupExportResult" + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceGroupExportResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.ExportTemplateRequest(resources=resources, options=options) + api_version = "2019-10-01" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.export_template.metadata['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, pattern=r'^[-\w\._\(\)]+$') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'ExportTemplateRequest') # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 202]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('ResourceGroupExportResult', response) + deserialized = self._deserialize('ResourceGroupExportResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - - def export_template( - self, resource_group_name, resources=None, options=None, custom_headers=None, raw=False, polling=True, **operation_config): + _export_template_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate'} # type: ignore + + def begin_export_template( + self, + resource_group_name, # type: str + resources=None, # type: Optional[List[str]] + options=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> LROPoller """Captures the specified resource group as a template. - :param resource_group_name: The name of the resource group. The name - is case insensitive. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str - :param resources: The IDs of the resources to filter the export by. To - export all resources, supply an array with single entry '*'. + :param 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', - 'SkipResourceNameParameterization', 'SkipAllParameterization' + :param options: The export template options. A CSV-formatted list containing zero or more of + the following: 'IncludeParameterDefaultValue', 'IncludeComments', + 'SkipResourceNameParameterization', 'SkipAllParameterization'. :type options: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns - ResourceGroupExportResult or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.resource.resources.v2019_10_01.models.ResourceGroupExportResult] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.resource.resources.v2019_10_01.models.ResourceGroupExportResult]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 ResourceGroupExportResult + :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] + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceGroupExportResult"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._export_template_initial( resource_group_name=resource_group_name, resources=resources, options=options, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - deserialized = self._deserialize('ResourceGroupExportResult', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ResourceGroupExportResult', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **operation_config) + 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 return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate'} + begin_export_template.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate'} # type: ignore def list( - self, filter=None, top=None, custom_headers=None, raw=False, **operation_config): + self, + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.ResourceGroupListResult"] """Gets all the resource groups for a subscription. - :param filter: The filter to apply on the operation.

You can - filter by tag names and values. For example, to filter for a tag name - and value, use $filter=tagName eq 'tag1' and tagValue eq 'Value1' + :param filter: The filter to apply on the operation.:code:`
`:code:`
`You can filter by + tag names and values. For example, to filter for a tag name and value, use $filter=tagName eq + 'tag1' and tagValue eq 'Value1'. :type filter: str - :param top: The number of results to return. If null is passed, - returns all resource groups. + :param top: The number of results to return. If null is passed, returns all resource groups. :type top: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of ResourceGroup - :rtype: - ~azure.mgmt.resource.resources.v2019_10_01.models.ResourceGroupPaged[~azure.mgmt.resource.resources.v2019_10_01.models.ResourceGroup] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['url'] + url = self.list.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_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 = {} + 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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('ResourceGroupListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.ResourceGroupPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups'} # type: ignore 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 f763439d1ef9..7090fa6ee850 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 @@ -1,560 +1,582 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError -from msrest.polling import LROPoller, NoPolling -from msrestazure.polling.arm_polling import ARMPolling +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, List, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class ResourcesOperations(object): """ResourcesOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2019_10_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for this operation. Constant value: "2019-10-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-10-01" - - self.config = config + self._config = config def list_by_resource_group( - self, resource_group_name, filter=None, expand=None, top=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + filter=None, # type: Optional[str] + expand=None, # type: Optional[str] + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.ResourceListResult"] """Get all the resources for a resource group. - :param resource_group_name: The resource group with the resources to - get. + :param resource_group_name: The resource group with the resources to get. :type resource_group_name: str - :param filter: The filter to apply on the operation.

The - properties you can use for eq (equals) or ne (not equals) are: - location, resourceType, name, resourceGroup, identity, - identity/principalId, plan, plan/publisher, plan/product, plan/name, - plan/version, and plan/promotionCode.

For example, to filter by - a resource type, use: $filter=resourceType eq - 'Microsoft.Network/virtualNetworks'

You can use - substringof(value, property) in the filter. The properties you can use - for substring are: name and resourceGroup.

For example, to get - all resources with 'demo' anywhere in the name, use: - $filter=substringof('demo', name)

You can link more than one - substringof together by adding and/or operators.

You can filter - by tag names and values. For example, to filter for a tag name and - value, use $filter=tagName eq 'tag1' and tagValue eq 'Value1'. When - you filter by a tag name and value, the tags for each resource are not - returned in the results.

You can use some properties together - when filtering. The combinations you can use are: substringof and/or - resourceType, plan and plan/publisher and plan/name, identity and - identity/principalId. + :param filter: The filter to apply on the operation.:code:`
`:code:`
`The properties you + can use for eq (equals) or ne (not equals) are: location, resourceType, name, resourceGroup, + identity, identity/principalId, plan, plan/publisher, plan/product, plan/name, plan/version, + and plan/promotionCode.:code:`
`:code:`
`For example, to filter by a resource type, use: + $filter=resourceType eq 'Microsoft.Network/virtualNetworks':code:`
`:code:`
`You can use + substringof(value, property) in the filter. The properties you can use for substring are: name + and resourceGroup.:code:`
`:code:`
`For example, to get all resources with 'demo' + anywhere in the name, use: $filter=substringof('demo', name):code:`
`:code:`
`You can + link more than one substringof together by adding and/or operators.:code:`
`:code:`
`You + can filter by tag names and values. For example, to filter for a tag name and value, use + $filter=tagName eq 'tag1' and tagValue eq 'Value1'. When you filter by a tag name and value, + the tags for each resource are not returned in the results.:code:`
`:code:`
`You can use + some properties together when filtering. The combinations you can use are: substringof and/or + resourceType, plan and plan/publisher and plan/name, identity and identity/principalId. :type filter: str - :param expand: Comma-separated list of additional properties to be - included in the response. Valid values include `createdTime`, - `changedTime` and `provisioningState`. For example, - `$expand=createdTime,changedTime`. + :param expand: Comma-separated list of additional properties to be included in the response. + Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, + ``$expand=createdTime,changedTime``. :type expand: str - :param top: The 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 - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of GenericResourceExpanded - :rtype: - ~azure.mgmt.resource.resources.v2019_10_01.models.GenericResourceExpandedPaged[~azure.mgmt.resource.resources.v2019_10_01.models.GenericResourceExpanded] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of ResourceListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_by_resource_group.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('ResourceListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response - - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.GenericResourceExpandedPaged(internal_paging, self._deserialize.dependencies, header_dict) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return deserialized - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources'} + return pipeline_response + return ItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources'} # type: ignore def _move_resources_initial( - self, source_resource_group_name, resources=None, target_resource_group=None, custom_headers=None, raw=False, **operation_config): - parameters = models.ResourcesMoveInfo(resources=resources, target_resource_group=target_resource_group) + self, + source_resource_group_name, # type: str + resources=None, # type: Optional[List[str]] + target_resource_group=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.ResourcesMoveInfo(resources=resources, target_resource_group=target_resource_group) + api_version = "2019-10-01" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.move_resources.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'ResourcesMoveInfo') + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [202, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - - def move_resources( - self, source_resource_group_name, resources=None, target_resource_group=None, custom_headers=None, raw=False, polling=True, **operation_config): - """Moves resources from one resource group to another resource group. - - The resources to move must be in the same source resource group. The - target resource group may be in a different subscription. When moving - resources, both the source group and the target group are locked for - the duration of the operation. Write and delete operations are blocked - on the groups until the move completes. . - - :param source_resource_group_name: The name of the resource group - containing the resources to move. + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore + + def begin_move_resources( + self, + source_resource_group_name, # type: str + resources=None, # type: Optional[List[str]] + target_resource_group=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """The resources to move must be in the same source resource group. The target resource group may be in a different subscription. When moving resources, both the source group and the target group are locked for the duration of the operation. Write and delete operations are blocked on the groups until the move completes. + + Moves resources from one resource group to another resource group. + + :param source_resource_group_name: The name of the resource group containing the resources to + move. :type source_resource_group_name: str :param resources: The IDs of the resources. :type resources: list[str] :param target_resource_group: The target resource group. :type target_resource_group: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns None or - ClientRawResponse if raw==True - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._move_resources_initial( source_resource_group_name=source_resource_group_name, resources=resources, target_resource_group=target_resource_group, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} - + begin_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore def _validate_move_resources_initial( - self, source_resource_group_name, resources=None, target_resource_group=None, custom_headers=None, raw=False, **operation_config): - parameters = models.ResourcesMoveInfo(resources=resources, target_resource_group=target_resource_group) + self, + source_resource_group_name, # type: str + resources=None, # type: Optional[List[str]] + target_resource_group=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.ResourcesMoveInfo(resources=resources, target_resource_group=target_resource_group) + api_version = "2019-10-01" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.validate_move_resources.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'ResourcesMoveInfo') + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [202, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - - def validate_move_resources( - self, source_resource_group_name, resources=None, target_resource_group=None, custom_headers=None, raw=False, polling=True, **operation_config): - """Validates whether resources can be moved from one resource group to - another resource group. - - This operation checks whether the specified resources can be moved to - the target. The resources to move must be in the same source resource - group. The target resource group may be in a different subscription. If - validation succeeds, it returns HTTP response code 204 (no content). If - validation fails, it returns HTTP response code 409 (Conflict) with an - error message. Retrieve the URL in the Location header value to check - the result of the long-running operation. - - :param source_resource_group_name: The name of the resource group - containing the resources to validate for move. + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _validate_move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} # type: ignore + + def begin_validate_move_resources( + self, + source_resource_group_name, # type: str + resources=None, # type: Optional[List[str]] + target_resource_group=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """This operation checks whether the specified resources can be moved to the target. The resources to move must be in the same source resource group. The target resource group may be in a different subscription. If validation succeeds, it returns HTTP response code 204 (no content). If validation fails, it returns HTTP response code 409 (Conflict) with an error message. Retrieve the URL in the Location header value to check the result of the long-running operation. + + Validates whether resources can be moved from one resource group to another resource group. + + :param source_resource_group_name: The name of the resource group containing the resources to + validate for move. :type source_resource_group_name: str :param resources: The IDs of the resources. :type resources: list[str] :param target_resource_group: The target resource group. :type target_resource_group: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns None or - ClientRawResponse if raw==True - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._validate_move_resources_initial( source_resource_group_name=source_resource_group_name, resources=resources, target_resource_group=target_resource_group, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - validate_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} + begin_validate_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources'} # type: ignore def list( - self, filter=None, expand=None, top=None, custom_headers=None, raw=False, **operation_config): + self, + filter=None, # type: Optional[str] + expand=None, # type: Optional[str] + top=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.ResourceListResult"] """Get all the resources in a subscription. - :param filter: The filter to apply on the operation.

The - properties you can use for eq (equals) or ne (not equals) are: - location, resourceType, name, resourceGroup, identity, - identity/principalId, plan, plan/publisher, plan/product, plan/name, - plan/version, and plan/promotionCode.

For example, to filter by - a resource type, use: $filter=resourceType eq - 'Microsoft.Network/virtualNetworks'

You can use - substringof(value, property) in the filter. The properties you can use - for substring are: name and resourceGroup.

For example, to get - all resources with 'demo' anywhere in the name, use: - $filter=substringof('demo', name)

You can link more than one - substringof together by adding and/or operators.

You can filter - by tag names and values. For example, to filter for a tag name and - value, use $filter=tagName eq 'tag1' and tagValue eq 'Value1'. When - you filter by a tag name and value, the tags for each resource are not - returned in the results.

You can use some properties together - when filtering. The combinations you can use are: substringof and/or - resourceType, plan and plan/publisher and plan/name, identity and - identity/principalId. + :param filter: The filter to apply on the operation.:code:`
`:code:`
`The properties you + can use for eq (equals) or ne (not equals) are: location, resourceType, name, resourceGroup, + identity, identity/principalId, plan, plan/publisher, plan/product, plan/name, plan/version, + and plan/promotionCode.:code:`
`:code:`
`For example, to filter by a resource type, use: + $filter=resourceType eq 'Microsoft.Network/virtualNetworks':code:`
`:code:`
`You can use + substringof(value, property) in the filter. The properties you can use for substring are: name + and resourceGroup.:code:`
`:code:`
`For example, to get all resources with 'demo' + anywhere in the name, use: $filter=substringof('demo', name):code:`
`:code:`
`You can + link more than one substringof together by adding and/or operators.:code:`
`:code:`
`You + can filter by tag names and values. For example, to filter for a tag name and value, use + $filter=tagName eq 'tag1' and tagValue eq 'Value1'. When you filter by a tag name and value, + the tags for each resource are not returned in the results.:code:`
`:code:`
`You can use + some properties together when filtering. The combinations you can use are: substringof and/or + resourceType, plan and plan/publisher and plan/name, identity and identity/principalId. :type filter: str - :param expand: Comma-separated list of additional properties to be - included in the response. Valid values include `createdTime`, - `changedTime` and `provisioningState`. For example, - `$expand=createdTime,changedTime`. + :param expand: Comma-separated list of additional properties to be included in the response. + Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, + ``$expand=createdTime,changedTime``. :type expand: str - :param top: The number of results to return. If null is passed, - returns all resource groups. + :param top: The number of results to return. If null is passed, returns all resource groups. :type top: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of GenericResourceExpanded - :rtype: - ~azure.mgmt.resource.resources.v2019_10_01.models.GenericResourceExpandedPaged[~azure.mgmt.resource.resources.v2019_10_01.models.GenericResourceExpanded] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of ResourceListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['url'] + url = self.list.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_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 = {} + 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("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('ResourceListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.GenericResourceExpandedPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resources'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resources'} # type: ignore def check_existence( - self, resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, api_version, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + api_version, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Checks whether a resource exists. - :param resource_group_name: The name of the resource group containing - the resource to check. The name is case insensitive. + :param resource_group_name: The name of the resource group containing the resource to check. + The name is case insensitive. :type resource_group_name: str - :param resource_provider_namespace: The resource provider of the - resource to check. + :param resource_provider_namespace: The resource provider of the resource to check. :type resource_provider_namespace: str :param parent_resource_path: The parent resource identity. :type parent_resource_path: str :param resource_type: The resource type. :type resource_type: str - :param resource_name: The name of the resource to check whether it - exists. + :param resource_name: The name of the resource to check whether it exists. :type resource_name: str :param api_version: The API version to use for the operation. :type api_version: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: bool or ClientRawResponse if raw=true - :rtype: bool or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + # Construct URL - url = self.check_existence.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204, 404]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = (response.status_code == 204) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - return deserialized - check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + 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, resource_provider_namespace, parent_resource_path, resource_type, resource_name, api_version, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + api_version, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + # Construct URL - url = self.delete.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - - def delete( - self, resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, api_version, custom_headers=None, raw=False, polling=True, **operation_config): + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + def begin_delete( + self, + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + api_version, # type: str + **kwargs # type: Any + ): + # type: (...) -> LROPoller """Deletes a resource. - :param resource_group_name: The name of the resource group that - contains the resource to delete. The name is case insensitive. + :param resource_group_name: The name of the resource group that contains the resource to + delete. The name is case insensitive. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource - provider. + :param resource_provider_namespace: The namespace of the resource provider. :type resource_provider_namespace: str :param parent_resource_path: The parent resource identity. :type parent_resource_path: str @@ -564,17 +586,21 @@ def delete( :type resource_name: str :param api_version: The API version to use for the operation. :type api_version: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns None or - ClientRawResponse if raw==True - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._delete_initial( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -582,89 +608,102 @@ def delete( resource_type=resource_type, resource_name=resource_name, api_version=api_version, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} - + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore def _create_or_update_initial( - self, resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, api_version, parameters, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + api_version, # type: str + parameters, # type: "models.GenericResource" + **kwargs # type: Any + ): + # type: (...) -> "models.GenericResource" + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + content_type = kwargs.pop("content_type", "application/json") + # Construct URL - url = self.create_or_update.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'GenericResource') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 201, 202]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('GenericResource', response) + deserialized = self._deserialize('GenericResource', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('GenericResource', response) + deserialized = self._deserialize('GenericResource', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - - def create_or_update( - self, resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, api_version, parameters, custom_headers=None, raw=False, polling=True, **operation_config): + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + def begin_create_or_update( + self, + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + api_version, # type: str + parameters, # type: "models.GenericResource" + **kwargs # type: Any + ): + # type: (...) -> LROPoller """Creates a resource. - :param resource_group_name: The name of the resource group for the - resource. The name is case insensitive. + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource - provider. + :param resource_provider_namespace: The namespace of the resource provider. :type resource_provider_namespace: str :param parent_resource_path: The parent resource identity. :type parent_resource_path: str @@ -675,21 +714,22 @@ def create_or_update( :param api_version: The API version to use for the operation. :type api_version: str :param parameters: Parameters for creating or updating the resource. - :type parameters: - ~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :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 polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns GenericResource or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 GenericResource + :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] + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._create_or_update_initial( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -698,91 +738,102 @@ def create_or_update( resource_name=resource_name, api_version=api_version, parameters=parameters, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - deserialized = self._deserialize('GenericResource', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('GenericResource', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} - + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore def _update_initial( - self, resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, api_version, parameters, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + api_version, # type: str + parameters, # type: "models.GenericResource" + **kwargs # type: Any + ): + # type: (...) -> "models.GenericResource" + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + content_type = kwargs.pop("content_type", "application/json") + # Construct URL - url = self.update.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'GenericResource') # Construct and send request - request = self._client.patch(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 202]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('GenericResource', response) + deserialized = self._deserialize('GenericResource', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - - def update( - self, resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, api_version, parameters, custom_headers=None, raw=False, polling=True, **operation_config): + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore + + def begin_update( + self, + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + api_version, # type: str + parameters, # type: "models.GenericResource" + **kwargs # type: Any + ): + # type: (...) -> LROPoller """Updates a resource. - :param resource_group_name: The name of the resource group for the - resource. The name is case insensitive. + :param resource_group_name: The name of the resource group for the resource. The name is case + insensitive. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource - provider. + :param resource_provider_namespace: The namespace of the resource provider. :type resource_provider_namespace: str :param parent_resource_path: The parent resource identity. :type parent_resource_path: str @@ -793,21 +844,22 @@ def update( :param api_version: The API version to use for the operation. :type api_version: str :param parameters: Parameters for updating the resource. - :type parameters: - ~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :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 polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns GenericResource or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 GenericResource + :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] + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._update_initial( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, @@ -816,38 +868,40 @@ def update( resource_name=resource_name, api_version=api_version, parameters=parameters, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - deserialized = self._deserialize('GenericResource', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('GenericResource', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore def get( - self, resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, api_version, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_path, # type: str + resource_type, # type: str + resource_name, # type: str + api_version, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.GenericResource" """Gets a resource. - :param resource_group_name: The name of the resource group containing - the resource to get. The name is case insensitive. + :param resource_group_name: The name of the resource group containing the resource to get. The + name is case insensitive. :type resource_group_name: str - :param resource_provider_namespace: The namespace of the resource - provider. + :param resource_provider_namespace: The namespace of the resource provider. :type resource_provider_namespace: str :param parent_resource_path: The parent resource identity. :type parent_resource_path: str @@ -857,459 +911,458 @@ def get( :type resource_name: str :param api_version: The API version to use for the operation. :type api_version: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: GenericResource or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GenericResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + # Construct URL - url = self.get.metadata['url'] + url = self.get.metadata['url'] # type: 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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('GenericResource', response) + deserialized = self._deserialize('GenericResource', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore def check_existence_by_id( - self, resource_id, api_version, custom_headers=None, raw=False, **operation_config): + self, + resource_id, # type: str + api_version, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Checks by ID whether a resource exists. - :param resource_id: The fully qualified ID of the resource, including - the resource name and resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. :type resource_id: str :param api_version: The API version to use for the operation. :type api_version: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: bool or ClientRawResponse if raw=true - :rtype: bool or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + # Construct URL - url = self.check_existence_by_id.metadata['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) + '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 = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204, 404]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = (response.status_code == 204) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - return deserialized - check_existence_by_id.metadata = {'url': '/{resourceId}'} + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + return 200 <= response.status_code <= 299 + check_existence_by_id.metadata = {'url': '/{resourceId}'} # type: ignore def _delete_by_id_initial( - self, resource_id, api_version, custom_headers=None, raw=False, **operation_config): + self, + resource_id, # type: str + api_version, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + # Construct URL - url = self.delete_by_id.metadata['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) + '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 = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + _delete_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore - def delete_by_id( - self, resource_id, api_version, custom_headers=None, raw=False, polling=True, **operation_config): + def begin_delete_by_id( + self, + resource_id, # type: str + api_version, # type: str + **kwargs # type: Any + ): + # type: (...) -> LROPoller """Deletes a resource by ID. - :param resource_id: The fully qualified ID of the resource, including - the resource name and resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. :type resource_id: str :param api_version: The API version to use for the operation. :type api_version: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns None or - ClientRawResponse if raw==True - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._delete_by_id_initial( resource_id=resource_id, api_version=api_version, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - delete_by_id.metadata = {'url': '/{resourceId}'} - + begin_delete_by_id.metadata = {'url': '/{resourceId}'} # type: ignore def _create_or_update_by_id_initial( - self, resource_id, api_version, parameters, custom_headers=None, raw=False, **operation_config): + self, + resource_id, # type: str + api_version, # type: str + parameters, # type: "models.GenericResource" + **kwargs # type: Any + ): + # type: (...) -> "models.GenericResource" + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + content_type = kwargs.pop("content_type", "application/json") + # Construct URL - url = self.create_or_update_by_id.metadata['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) + '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 = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'GenericResource') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 201, 202]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('GenericResource', response) + deserialized = self._deserialize('GenericResource', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('GenericResource', response) + deserialized = self._deserialize('GenericResource', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - - def create_or_update_by_id( - self, resource_id, api_version, parameters, custom_headers=None, raw=False, polling=True, **operation_config): + _create_or_update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + def begin_create_or_update_by_id( + self, + resource_id, # type: str + api_version, # type: str + parameters, # type: "models.GenericResource" + **kwargs # type: Any + ): + # type: (...) -> LROPoller """Create a resource by ID. - :param resource_id: The fully qualified ID of the resource, including - the resource name and resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. :type resource_id: str :param api_version: The API version to use for the operation. :type api_version: str :param parameters: Create or update resource parameters. - :type parameters: - ~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :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 polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns GenericResource or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 GenericResource + :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] + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._create_or_update_by_id_initial( resource_id=resource_id, api_version=api_version, parameters=parameters, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - deserialized = self._deserialize('GenericResource', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('GenericResource', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - create_or_update_by_id.metadata = {'url': '/{resourceId}'} - + begin_create_or_update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore def _update_by_id_initial( - self, resource_id, api_version, parameters, custom_headers=None, raw=False, **operation_config): + self, + resource_id, # type: str + api_version, # type: str + parameters, # type: "models.GenericResource" + **kwargs # type: Any + ): + # type: (...) -> "models.GenericResource" + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + content_type = kwargs.pop("content_type", "application/json") + # Construct URL - url = self.update_by_id.metadata['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) + '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 = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'GenericResource') # Construct and send request - request = self._client.patch(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200, 202]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('GenericResource', response) + deserialized = self._deserialize('GenericResource', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - - def update_by_id( - self, resource_id, api_version, parameters, custom_headers=None, raw=False, polling=True, **operation_config): + _update_by_id_initial.metadata = {'url': '/{resourceId}'} # type: ignore + + def begin_update_by_id( + self, + resource_id, # type: str + api_version, # type: str + parameters, # type: "models.GenericResource" + **kwargs # type: Any + ): + # type: (...) -> LROPoller """Updates a resource by ID. - :param resource_id: The fully qualified ID of the resource, including - the resource name and resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. :type resource_id: str :param api_version: The API version to use for the operation. :type api_version: str :param parameters: Update resource parameters. - :type parameters: - ~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :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 polling: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns GenericResource or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource]] - :raises: :class:`CloudError` + :paramtype polling: bool or ~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 GenericResource + :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] + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) raw_result = self._update_by_id_initial( resource_id=resource_id, api_version=api_version, parameters=parameters, - custom_headers=custom_headers, - raw=True, - **operation_config + cls=lambda x,y,z: x, + **kwargs ) - def get_long_running_output(response): - deserialized = self._deserialize('GenericResource', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('GenericResource', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - update_by_id.metadata = {'url': '/{resourceId}'} + begin_update_by_id.metadata = {'url': '/{resourceId}'} # type: ignore def get_by_id( - self, resource_id, api_version, custom_headers=None, raw=False, **operation_config): + self, + resource_id, # type: str + api_version, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.GenericResource" """Gets a resource by ID. - :param resource_id: The fully qualified ID of the resource, including - the resource name and resource type. Use the format, - /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} + :param resource_id: The fully qualified ID of the resource, including the resource name and + resource type. Use the format, /subscriptions/{guid}/resourceGroups/{resource-group- + name}/{resource-provider-namespace}/{resource-type}/{resource-name}. :type resource_id: str :param api_version: The API version to use for the operation. :type api_version: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: GenericResource or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GenericResource or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.GenericResource + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.GenericResource"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + # Construct URL - url = self.get_by_id.metadata['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) + '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 = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('GenericResource', response) + deserialized = self._deserialize('GenericResource', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/{resourceId}'} + 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 e65913b7f528..c946373bd33d 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 @@ -1,613 +1,579 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class TagsOperations(object): """TagsOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.resources.v2019_10_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for this operation. Constant value: "2019-10-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-10-01" - - self.config = config + self._config = config def delete_value( - self, tag_name, tag_value, custom_headers=None, raw=False, **operation_config): - """Deletes a predefined tag value for a predefined tag name. + self, + tag_name, # type: str + tag_value, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """This operation allows deleting a value from the list of predefined values for an existing predefined tag name. The value being deleted must not be in use as a tag value for the given tag name for any resource. - This operation allows deleting a value from the list of predefined - values for an existing predefined tag name. The value being deleted - must not be in use as a tag value for the given tag name for any - resource. + Deletes a predefined tag value for a predefined tag name. :param tag_name: The name of the tag. :type tag_name: str :param tag_value: The value of the tag to delete. :type tag_value: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + # Construct URL - url = self.delete_value.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} + delete_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore def create_or_update_value( - self, tag_name, tag_value, custom_headers=None, raw=False, **operation_config): - """Creates a predefined value for a predefined tag name. + self, + tag_name, # type: str + tag_value, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.TagValue" + """This operation allows adding a value to the list of predefined values for an existing predefined tag name. A tag value can have a maximum of 256 characters. - This operation allows adding a value to the list of predefined values - for an existing predefined tag name. A tag value can have a maximum of - 256 characters. + Creates a predefined value for a predefined tag name. :param tag_name: The name of the tag. :type tag_name: str :param tag_value: The value of the tag to create. :type tag_value: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: TagValue or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.TagValue or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagValue or the result of cls(response) + :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.TagValue + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TagValue"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + # Construct URL - url = self.create_or_update_value.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.put(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 201]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('TagValue', response) + deserialized = self._deserialize('TagValue', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('TagValue', response) + deserialized = self._deserialize('TagValue', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} + create_or_update_value.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}'} # type: ignore def create_or_update( - self, tag_name, custom_headers=None, raw=False, **operation_config): - """Creates a predefined tag name. + self, + tag_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.TagDetails" + """This operation allows adding a name to the list of predefined tag names for the given subscription. A tag name can have a maximum of 512 characters and is case-insensitive. Tag names cannot have the following prefixes which are reserved for Azure use: 'microsoft', 'azure', 'windows'. - This operation allows adding a name to the list of predefined tag names - for the given subscription. A tag name can have a maximum of 512 - characters and is case-insensitive. Tag names cannot have the following - prefixes which are reserved for Azure use: 'microsoft', 'azure', - 'windows'. + Creates a predefined tag name. :param tag_name: The name of the tag to create. :type tag_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: TagDetails or ClientRawResponse if raw=true + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagDetails or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.TagDetails - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TagDetails"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + # Construct URL - url = self.create_or_update.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.put(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 201]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('TagDetails', response) + deserialized = self._deserialize('TagDetails', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('TagDetails', response) + deserialized = self._deserialize('TagDetails', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore def delete( - self, tag_name, custom_headers=None, raw=False, **operation_config): - """Deletes a predefined tag name. + self, + tag_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """This operation allows deleting a name from the list of predefined tag names for the given subscription. The name being deleted must not be in use as a tag name for any resource. All predefined values for the given name must have already been deleted. - This operation allows deleting a name from the list of predefined tag - names for the given subscription. The name being deleted must not be in - use as a tag name for any resource. All predefined values for the given - name must have already been deleted. + Deletes a predefined tag name. :param tag_name: The name of the tag. :type tag_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + # Construct URL - url = self.delete.metadata['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') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} + delete.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames/{tagName}'} # type: ignore def list( - self, custom_headers=None, raw=False, **operation_config): - """Gets a summary of tag usage under the subscription. - - This operation performs a union of predefined tags, resource tags, - resource group tags and subscription tags, and returns a summary of - usage for each tag name and value under the given subscription. In case - of a large number of tags, this operation may return a previously - cached result. - - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of TagDetails - :rtype: - ~azure.mgmt.resource.resources.v2019_10_01.models.TagDetailsPaged[~azure.mgmt.resource.resources.v2019_10_01.models.TagDetails] - :raises: :class:`CloudError` + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.TagsListResult"] + """This operation performs a union of predefined tags, resource tags, resource group tags and subscription tags, and returns a summary of usage for each tag name and value under the given subscription. In case of a large number of tags, this operation may return a previously cached result. + + Gets a summary of tag usage under the subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of TagsListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['url'] + url = self.list.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('TagsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.TagDetailsPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/tagNames'} # type: ignore def create_or_update_at_scope( - self, scope, properties, custom_headers=None, raw=False, **operation_config): - """Creates or updates the entire set of tags on a resource or - subscription. + self, + scope, # type: str + properties, # type: "models.Tags" + **kwargs # type: Any + ): + # type: (...) -> "models.TagsResource" + """This operation allows adding or replacing the entire set of tags on the specified resource or subscription. The specified entity can have a maximum of 50 tags. - This operation allows adding or replacing the entire set of tags on the - specified resource or subscription. The specified entity can have a - maximum of 50 tags. + Creates or updates the entire set of tags on a resource or subscription. :param scope: The resource scope. :type scope: str :param properties: The set of tags. - :type properties: - ~azure.mgmt.resource.resources.v2019_10_01.models.Tags - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: TagsResource or ClientRawResponse if raw=true + :type properties: ~azure.mgmt.resource.resources.v2019_10_01.models.Tags + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagsResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.TagsResource - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :raises: ~azure.core.exceptions.HttpResponseError """ - parameters = models.TagsResource(properties=properties) + cls = kwargs.pop('cls', None) # type: ClsType["models.TagsResource"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.TagsResource(properties=properties) + api_version = "2019-10-01" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.create_or_update_at_scope.metadata['url'] + url = self.create_or_update_at_scope.metadata['url'] # type: ignore path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str') + 'scope': self._serialize.url("scope", scope, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'TagsResource') # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('TagsResource', response) + deserialized = self._deserialize('TagsResource', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/tags/default'} + create_or_update_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/tags/default'} # type: ignore def update_at_scope( - self, scope, operation=None, properties=None, custom_headers=None, raw=False, **operation_config): - """Selectively updates the set of tags on a resource or subscription. + self, + scope, # type: str + operation=None, # type: Optional[Union[str, "models.TagsPatchResourceOperation"]] + properties=None, # type: Optional["models.Tags"] + **kwargs # type: Any + ): + # type: (...) -> "models.TagsResource" + """This operation allows replacing, merging or selectively deleting tags on the specified resource or subscription. The specified entity can have a maximum of 50 tags at the end of the operation. The 'replace' option replaces the entire set of existing tags with a new set. The 'merge' option allows adding tags with new names and updating the values of tags with existing names. The 'delete' option allows selectively deleting tags based on given names or name/value pairs. - This operation allows replacing, merging or selectively deleting tags - on the specified resource or subscription. The specified entity can - have a maximum of 50 tags at the end of the operation. The 'replace' - option replaces the entire set of existing tags with a new set. The - 'merge' option allows adding tags with new names and updating the - values of tags with existing names. The 'delete' option allows - selectively deleting tags based on given names or name/value pairs. + Selectively updates the set of tags on a resource or subscription. :param scope: The resource scope. :type scope: str - :param 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.enum + :param operation: The operation type for the patch API. + :type operation: str or ~azure.mgmt.resource.resources.v2019_10_01.models.TagsPatchResourceOperation :param properties: The set of tags. - :type properties: - ~azure.mgmt.resource.resources.v2019_10_01.models.Tags - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: TagsResource or ClientRawResponse if raw=true + :type properties: ~azure.mgmt.resource.resources.v2019_10_01.models.Tags + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagsResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.TagsResource - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :raises: ~azure.core.exceptions.HttpResponseError """ - parameters = models.TagsPatchResource(operation=operation, properties=properties) + cls = kwargs.pop('cls', None) # type: ClsType["models.TagsResource"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.TagsPatchResource(operation=operation, properties=properties) + api_version = "2019-10-01" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.update_at_scope.metadata['url'] + url = self.update_at_scope.metadata['url'] # type: ignore path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str') + 'scope': self._serialize.url("scope", scope, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'TagsPatchResource') # Construct and send request - request = self._client.patch(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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 if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('TagsResource', response) + deserialized = self._deserialize('TagsResource', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - update_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/tags/default'} + update_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/tags/default'} # type: ignore def get_at_scope( - self, scope, custom_headers=None, raw=False, **operation_config): + self, + scope, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.TagsResource" """Gets the entire set of tags on a resource or subscription. + Gets the entire set of tags on a resource or subscription. + :param scope: The resource scope. :type scope: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: TagsResource or ClientRawResponse if raw=true + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagsResource or the result of cls(response) :rtype: ~azure.mgmt.resource.resources.v2019_10_01.models.TagsResource - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TagsResource"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + # Construct URL - url = self.get_at_scope.metadata['url'] + url = self.get_at_scope.metadata['url'] # type: ignore path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str') + 'scope': self._serialize.url("scope", scope, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('TagsResource', response) + deserialized = self._deserialize('TagsResource', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/tags/default'} + get_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/tags/default'} # type: ignore def delete_at_scope( - self, scope, custom_headers=None, raw=False, **operation_config): + self, + scope, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Deletes the entire set of tags on a resource or subscription. + Deletes the entire set of tags on a resource or subscription. + :param scope: The resource scope. :type scope: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-10-01" + # Construct URL - url = self.delete_at_scope.metadata['url'] + url = self.delete_at_scope.metadata['url'] # type: ignore path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str') + 'scope': self._serialize.url("scope", scope, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters = {} # type: Dict[str, Any] # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/tags/default'} + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete_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/py.typed b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file 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 deleted file mode 100644 index f0880ef49517..000000000000 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/resources/v2019_10_01/version.py +++ /dev/null @@ -1,13 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -VERSION = "2019-10-01" - diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/__init__.py index b268f0af22b7..b07b0882922e 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/__init__.py @@ -1,19 +1,16 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._configuration import SubscriptionClientConfiguration from ._subscription_client import SubscriptionClient -__all__ = ['SubscriptionClient', 'SubscriptionClientConfiguration'] - -from ..version import VERSION - -__version__ = VERSION +__all__ = ['SubscriptionClient'] +try: + from ._patch import patch_sdk + patch_sdk() +except ImportError: + pass 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 2c43c852b1e5..a7be5d9af264 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 @@ -1,43 +1,63 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrestazure import AzureConfiguration -from ..version import VERSION +from typing import TYPE_CHECKING +from azure.core.configuration import Configuration +from azure.core.pipeline import policies -class SubscriptionClientConfiguration(AzureConfiguration): - """Configuration for SubscriptionClient - Note that all parameters used to create this instance are saved as instance - attributes. +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` - :param str base_url: Service URL - """ - - def __init__( - self, credentials, base_url=None): + from azure.core.credentials import TokenCredential - if credentials is None: - raise ValueError("Parameter 'credentials' must not be None.") - if not base_url: - base_url = 'https://management.azure.com' +VERSION = "unknown" - super(SubscriptionClientConfiguration, self).__init__(base_url) +class SubscriptionClientConfiguration(Configuration): + """Configuration for SubscriptionClient. - # Starting Autorest.Python 4.0.64, make connection pool activated by default - self.keep_alive = True + Note that all parameters used to create this instance are saved as instance + attributes. - self.add_user_agent('azure-mgmt-resource/{}'.format(VERSION)) - self.add_user_agent('Azure-SDK-For-Python') + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + """ - self.credentials = credentials + def __init__( + self, + credential, # type: "TokenCredential" + **kwargs # type: Any + ): + # type: (...) -> None + 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" + self.credential_scopes = ['https://management.azure.com/.default'] + self.credential_scopes.extend(kwargs.pop('credential_scopes', [])) + kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + 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) 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 399e93fb102f..b07b0882922e 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 @@ -1,19 +1,16 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._configuration import SubscriptionClientConfiguration from ._subscription_client import SubscriptionClient -__all__ = ['SubscriptionClient', 'SubscriptionClientConfiguration'] - -from .version import VERSION - -__version__ = VERSION +__all__ = ['SubscriptionClient'] +try: + from ._patch import patch_sdk + patch_sdk() +except ImportError: + pass 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 935bf662873f..398a58ebd768 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 @@ -1,43 +1,63 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrestazure import AzureConfiguration -from .version import VERSION +from typing import TYPE_CHECKING +from azure.core.configuration import Configuration +from azure.core.pipeline import policies -class SubscriptionClientConfiguration(AzureConfiguration): - """Configuration for SubscriptionClient - Note that all parameters used to create this instance are saved as instance - attributes. +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` - :param str base_url: Service URL - """ - - def __init__( - self, credentials, base_url=None): + from azure.core.credentials import TokenCredential - if credentials is None: - raise ValueError("Parameter 'credentials' must not be None.") - if not base_url: - base_url = 'https://management.azure.com' +VERSION = "unknown" - super(SubscriptionClientConfiguration, self).__init__(base_url) +class SubscriptionClientConfiguration(Configuration): + """Configuration for SubscriptionClient. - # Starting Autorest.Python 4.0.64, make connection pool activated by default - self.keep_alive = True + Note that all parameters used to create this instance are saved as instance + attributes. - self.add_user_agent('azure-mgmt-resource/{}'.format(VERSION)) - self.add_user_agent('Azure-SDK-For-Python') + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + """ - self.credentials = credentials + def __init__( + self, + credential, # type: "TokenCredential" + **kwargs # type: Any + ): + # type: (...) -> None + 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" + self.credential_scopes = ['https://management.azure.com/.default'] + self.credential_scopes.extend(kwargs.pop('credential_scopes', [])) + kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + 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) 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 new file mode 100644 index 000000000000..a7e8a9df7ec4 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/_metadata.json @@ -0,0 +1,43 @@ +{ + "chosen_version": "2016-06-01", + "total_api_version_list": ["2016-06-01"], + "client": { + "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." + }, + "global_parameters": { + "sync_method": { + "credential": { + "method_signature": "credential, # type: \"TokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials.TokenCredential", + "required": true + } + }, + "async_method": { + "credential": { + "method_signature": "credential, # type: \"AsyncTokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + } + }, + "constant": { + }, + "call": "credential" + }, + "config": { + "credential": true, + "credential_scopes": ["https://management.azure.com/.default"] + }, + "operation_groups": { + "operations": "Operations", + "subscriptions": "SubscriptionsOperations", + "tenants": "TenantsOperations" + }, + "operation_mixins": { + }, + "sync_imports": "None", + "async_imports": "None" +} \ 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 bd145dc5256e..5a4d7e095e5b 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 @@ -1,16 +1,19 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.service_client import SDKClient -from msrest import Serializer, Deserializer +from typing import TYPE_CHECKING + +from azure.mgmt.core import ARMPipelineClient +from msrest import Deserializer, Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional from ._configuration import SubscriptionClientConfiguration from .operations import Operations @@ -19,39 +22,53 @@ from . import models -class SubscriptionClient(SDKClient): +class SubscriptionClient(object): """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 config: Configuration for client. - :vartype config: SubscriptionClientConfiguration - :ivar operations: Operations operations :vartype operations: azure.mgmt.resource.subscriptions.v2016_06_01.operations.Operations - :ivar subscriptions: Subscriptions operations + :ivar subscriptions: SubscriptionsOperations operations :vartype subscriptions: azure.mgmt.resource.subscriptions.v2016_06_01.operations.SubscriptionsOperations - :ivar tenants: Tenants operations + :ivar tenants: TenantsOperations operations :vartype tenants: azure.mgmt.resource.subscriptions.v2016_06_01.operations.TenantsOperations - - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential :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. """ def __init__( - self, credentials, base_url=None): - - self.config = SubscriptionClientConfiguration(credentials, base_url) - super(SubscriptionClient, self).__init__(self.config.credentials, self.config) + self, + credential, # type: "TokenCredential" + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + 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) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - self.api_version = '2016-06-01' self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self.operations = Operations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.subscriptions = SubscriptionsOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.tenants = TenantsOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> SubscriptionClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) 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 new file mode 100644 index 000000000000..345034cd2938 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/aio/__init__.py @@ -0,0 +1,10 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._subscription_client_async import SubscriptionClient +__all__ = ['SubscriptionClient'] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/aio/_configuration_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/aio/_configuration_async.py new file mode 100644 index 000000000000..a02ea4dbbe99 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/aio/_configuration_async.py @@ -0,0 +1,59 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + +VERSION = "unknown" + +class SubscriptionClientConfiguration(Configuration): + """Configuration for SubscriptionClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + **kwargs: Any + ) -> None: + 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" + self.credential_scopes = ['https://management.azure.com/.default'] + self.credential_scopes.extend(kwargs.pop('credential_scopes', [])) + kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs: Any + ) -> None: + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + 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) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/aio/_subscription_client_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/aio/_subscription_client_async.py new file mode 100644 index 000000000000..b4564305b352 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/aio/_subscription_client_async.py @@ -0,0 +1,66 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, Optional + +from azure.mgmt.core import AsyncARMPipelineClient +from msrest import Deserializer, Serializer + +from ._configuration_async import SubscriptionClientConfiguration +from .operations_async import Operations +from .operations_async import SubscriptionsOperations +from .operations_async import TenantsOperations +from .. import models + + +class SubscriptionClient(object): + """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_async.Operations + :ivar subscriptions: SubscriptionsOperations operations + :vartype subscriptions: azure.mgmt.resource.subscriptions.v2016_06_01.aio.operations_async.SubscriptionsOperations + :ivar tenants: TenantsOperations operations + :vartype tenants: azure.mgmt.resource.subscriptions.v2016_06_01.aio.operations_async.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 + :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", + base_url: Optional[str] = None, + **kwargs: 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) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + + self.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 close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "SubscriptionClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/aio/operations_async/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/aio/operations_async/__init__.py new file mode 100644 index 000000000000..05cc20fe3ece --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/aio/operations_async/__init__.py @@ -0,0 +1,17 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._operations_async import Operations +from ._subscriptions_operations_async import SubscriptionsOperations +from ._tenants_operations_async import TenantsOperations + +__all__ = [ + 'Operations', + 'SubscriptionsOperations', + 'TenantsOperations', +] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/aio/operations_async/_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/aio/operations_async/_operations_async.py new file mode 100644 index 000000000000..ea39835c6c22 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/aio/operations_async/_operations_async.py @@ -0,0 +1,101 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import 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 ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class Operations: + """Operations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.subscriptions.v2016_06_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + **kwargs + ) -> AsyncIterable["models.OperationListResult"]: + """Lists all of the available Microsoft.Resources REST API operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of OperationListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-06-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('OperationListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.Resources/operations'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/aio/operations_async/_subscriptions_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/aio/operations_async/_subscriptions_operations_async.py new file mode 100644 index 000000000000..6eecd7a84344 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/aio/operations_async/_subscriptions_operations_async.py @@ -0,0 +1,220 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import 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 ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class SubscriptionsOperations: + """SubscriptionsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.subscriptions.v2016_06_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list_locations( + self, + subscription_id: str, + **kwargs + ) -> AsyncIterable["models.LocationListResult"]: + """This operation provides all the locations that are available for resource providers; however, each resource provider may support a subset of this list. + + Gets all available geo-locations. + + :param subscription_id: The ID of the target subscription. + :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 LocationListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-06-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('LocationListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_locations.metadata = {'url': '/subscriptions/{subscriptionId}/locations'} # type: ignore + + async def get( + self, + subscription_id: str, + **kwargs + ) -> "models.Subscription": + """Gets details about a specified subscription. + + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Subscription or the result of cls(response) + :rtype: ~azure.mgmt.resource.subscriptions.v2016_06_01.models.Subscription + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Subscription"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-06-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Subscription', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}'} # type: ignore + + def list( + self, + **kwargs + ) -> AsyncIterable["models.SubscriptionListResult"]: + """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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-06-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('SubscriptionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/aio/operations_async/_tenants_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/aio/operations_async/_tenants_operations_async.py new file mode 100644 index 000000000000..98167531c7c9 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/aio/operations_async/_tenants_operations_async.py @@ -0,0 +1,101 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import 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 ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class TenantsOperations: + """TenantsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.subscriptions.v2016_06_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + **kwargs + ) -> AsyncIterable["models.TenantListResult"]: + """Gets the tenants for your account. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of TenantListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-06-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('TenantListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/tenants'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/models/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/models/__init__.py index cd1fb5a0855e..4a05f8dc94cf 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/models/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/models/__init__.py @@ -1,48 +1,50 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- try: from ._models_py3 import Location + from ._models_py3 import LocationListResult from ._models_py3 import Operation from ._models_py3 import OperationDisplay + from ._models_py3 import OperationListResult from ._models_py3 import Subscription + from ._models_py3 import SubscriptionListResult from ._models_py3 import SubscriptionPolicies from ._models_py3 import TenantIdDescription + from ._models_py3 import TenantListResult except (SyntaxError, ImportError): - from ._models import Location - from ._models import Operation - from ._models import OperationDisplay - from ._models import Subscription - from ._models import SubscriptionPolicies - from ._models import TenantIdDescription -from ._paged_models import LocationPaged -from ._paged_models import OperationPaged -from ._paged_models import SubscriptionPaged -from ._paged_models import TenantIdDescriptionPaged + from ._models import Location # type: ignore + from ._models import LocationListResult # type: ignore + from ._models import Operation # type: ignore + from ._models import OperationDisplay # type: ignore + from ._models import OperationListResult # type: ignore + from ._models import Subscription # type: ignore + from ._models import SubscriptionListResult # type: ignore + from ._models import SubscriptionPolicies # type: ignore + from ._models import TenantIdDescription # type: ignore + from ._models import TenantListResult # type: ignore + from ._subscription_client_enums import ( - SubscriptionState, SpendingLimit, + SubscriptionState, ) __all__ = [ 'Location', + 'LocationListResult', 'Operation', 'OperationDisplay', + 'OperationListResult', 'Subscription', + 'SubscriptionListResult', 'SubscriptionPolicies', 'TenantIdDescription', - 'OperationPaged', - 'LocationPaged', - 'SubscriptionPaged', - 'TenantIdDescriptionPaged', - 'SubscriptionState', + 'TenantListResult', 'SpendingLimit', + 'SubscriptionState', ] 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 125586e447e0..e11afbf9b663 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 @@ -1,30 +1,18 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.serialization import Model +import msrest.serialization -class CloudError(Model): - """CloudError. - """ - - _attribute_map = { - } - - -class Location(Model): +class Location(msrest.serialization.Model): """Location information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The fully qualified ID of the location. For example, /subscriptions/00000000-0000-0000-0000-000000000000/locations/westus. @@ -59,7 +47,10 @@ class Location(Model): 'longitude': {'key': 'longitude', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Location, self).__init__(**kwargs) self.id = None self.subscription_id = None @@ -69,14 +60,32 @@ def __init__(self, **kwargs): self.longitude = None -class Operation(Model): +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] + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Location]'}, + } + + def __init__( + self, + **kwargs + ): + super(LocationListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + + +class Operation(msrest.serialization.Model): """Microsoft.Resources operation. - :param name: Operation name: {provider}/{resource}/{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 + :type display: ~azure.mgmt.resource.subscriptions.v2016_06_01.models.OperationDisplay """ _attribute_map = { @@ -84,19 +93,21 @@ class Operation(Model): 'display': {'key': 'display', 'type': 'OperationDisplay'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Operation, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.display = kwargs.get('display', None) -class OperationDisplay(Model): +class OperationDisplay(msrest.serialization.Model): """The object that represents the operation. - :param provider: Service provider: Microsoft.Resources + :param provider: Service provider: Microsoft.Resources. :type provider: str - :param resource: Resource on which the operation is performed: Profile, - endpoint, etc. + :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 @@ -111,7 +122,10 @@ class OperationDisplay(Model): 'description': {'key': 'description', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(OperationDisplay, self).__init__(**kwargs) self.provider = kwargs.get('provider', None) self.resource = kwargs.get('resource', None) @@ -119,11 +133,33 @@ def __init__(self, **kwargs): self.description = kwargs.get('description', None) -class Subscription(Model): +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 + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Operation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(OperationListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class Subscription(msrest.serialization.Model): """Subscription information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The fully qualified ID for the subscription. For example, /subscriptions/00000000-0000-0000-0000-000000000000. @@ -132,17 +168,15 @@ class Subscription(Model): :vartype subscription_id: str :ivar display_name: The subscription display name. :vartype display_name: str - :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 + :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: ~azure.mgmt.resource.subscriptions.v2016_06_01.models.SubscriptionPolicies - :param 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'. + :param 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 """ @@ -157,12 +191,15 @@ class Subscription(Model): 'id': {'key': 'id', 'type': 'str'}, 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, 'display_name': {'key': 'displayName', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'SubscriptionState'}, + 'state': {'key': 'state', 'type': 'str'}, 'subscription_policies': {'key': 'subscriptionPolicies', 'type': 'SubscriptionPolicies'}, 'authorization_source': {'key': 'authorizationSource', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Subscription, self).__init__(**kwargs) self.id = None self.subscription_id = None @@ -172,21 +209,48 @@ def __init__(self, **kwargs): self.authorization_source = kwargs.get('authorization_source', None) -class SubscriptionPolicies(Model): +class SubscriptionListResult(msrest.serialization.Model): + """Subscription list operation response. + + 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 + """ + + _validation = { + 'next_link': {'required': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Subscription]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(SubscriptionListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs['next_link'] + + +class SubscriptionPolicies(msrest.serialization.Model): """Subscription policies. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar location_placement_id: The subscription location placement ID. The - ID indicates which regions are visible for a subscription. For example, a - subscription with a location placement Id of Public_2014-09-01 has access - to Azure public regions. + :ivar location_placement_id: The subscription location placement ID. The ID indicates which + regions are visible for a subscription. For example, a subscription with a location placement + Id of Public_2014-09-01 has access to Azure public regions. :vartype location_placement_id: str :ivar quota_id: The subscription quota ID. :vartype quota_id: str - :ivar spending_limit: The subscription spending limit. Possible values - include: 'On', 'Off', 'CurrentPeriodOff' + :ivar spending_limit: The subscription spending limit. Possible values include: "On", "Off", + "CurrentPeriodOff". :vartype spending_limit: str or ~azure.mgmt.resource.subscriptions.v2016_06_01.models.SpendingLimit """ @@ -200,27 +264,28 @@ class SubscriptionPolicies(Model): _attribute_map = { 'location_placement_id': {'key': 'locationPlacementId', 'type': 'str'}, 'quota_id': {'key': 'quotaId', 'type': 'str'}, - 'spending_limit': {'key': 'spendingLimit', 'type': 'SpendingLimit'}, + 'spending_limit': {'key': 'spendingLimit', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(SubscriptionPolicies, self).__init__(**kwargs) self.location_placement_id = None self.quota_id = None self.spending_limit = None -class TenantIdDescription(Model): +class TenantIdDescription(msrest.serialization.Model): """Tenant Id information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The fully qualified ID of the tenant. For example, /tenants/00000000-0000-0000-0000-000000000000. :vartype id: str - :ivar tenant_id: The tenant ID. For example, - 00000000-0000-0000-0000-000000000000. + :ivar tenant_id: The tenant ID. For example, 00000000-0000-0000-0000-000000000000. :vartype tenant_id: str """ @@ -234,7 +299,39 @@ class TenantIdDescription(Model): 'tenant_id': {'key': 'tenantId', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(TenantIdDescription, self).__init__(**kwargs) self.id = None self.tenant_id = None + + +class TenantListResult(msrest.serialization.Model): + """Tenant Ids information. + + 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 + """ + + _validation = { + 'next_link': {'required': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[TenantIdDescription]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + 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 43c5a4f3d4fc..26c4b37031ab 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 @@ -1,30 +1,20 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.serialization import Model +from typing import List, Optional - -class CloudError(Model): - """CloudError. - """ - - _attribute_map = { - } +import msrest.serialization -class Location(Model): +class Location(msrest.serialization.Model): """Location information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The fully qualified ID of the location. For example, /subscriptions/00000000-0000-0000-0000-000000000000/locations/westus. @@ -59,7 +49,10 @@ class Location(Model): 'longitude': {'key': 'longitude', 'type': 'str'}, } - def __init__(self, **kwargs) -> None: + def __init__( + self, + **kwargs + ): super(Location, self).__init__(**kwargs) self.id = None self.subscription_id = None @@ -69,14 +62,34 @@ def __init__(self, **kwargs) -> None: self.longitude = None -class Operation(Model): +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] + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Location]'}, + } + + def __init__( + self, + *, + value: Optional[List["Location"]] = None, + **kwargs + ): + super(LocationListResult, self).__init__(**kwargs) + self.value = value + + +class Operation(msrest.serialization.Model): """Microsoft.Resources operation. - :param name: Operation name: {provider}/{resource}/{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 + :type display: ~azure.mgmt.resource.subscriptions.v2016_06_01.models.OperationDisplay """ _attribute_map = { @@ -84,19 +97,24 @@ class Operation(Model): 'display': {'key': 'display', 'type': 'OperationDisplay'}, } - def __init__(self, *, name: str=None, display=None, **kwargs) -> None: + def __init__( + self, + *, + name: Optional[str] = None, + display: Optional["OperationDisplay"] = None, + **kwargs + ): super(Operation, self).__init__(**kwargs) self.name = name self.display = display -class OperationDisplay(Model): +class OperationDisplay(msrest.serialization.Model): """The object that represents the operation. - :param provider: Service provider: Microsoft.Resources + :param provider: Service provider: Microsoft.Resources. :type provider: str - :param resource: Resource on which the operation is performed: Profile, - endpoint, etc. + :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 @@ -111,7 +129,15 @@ class OperationDisplay(Model): 'description': {'key': 'description', 'type': 'str'}, } - def __init__(self, *, provider: str=None, resource: str=None, operation: str=None, description: str=None, **kwargs) -> None: + def __init__( + self, + *, + provider: Optional[str] = None, + resource: Optional[str] = None, + operation: Optional[str] = None, + description: Optional[str] = None, + **kwargs + ): super(OperationDisplay, self).__init__(**kwargs) self.provider = provider self.resource = resource @@ -119,11 +145,36 @@ def __init__(self, *, provider: str=None, resource: str=None, operation: str=Non self.description = description -class Subscription(Model): +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 + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Operation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["Operation"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(OperationListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class Subscription(msrest.serialization.Model): """Subscription information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The fully qualified ID for the subscription. For example, /subscriptions/00000000-0000-0000-0000-000000000000. @@ -132,17 +183,15 @@ class Subscription(Model): :vartype subscription_id: str :ivar display_name: The subscription display name. :vartype display_name: str - :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 + :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: ~azure.mgmt.resource.subscriptions.v2016_06_01.models.SubscriptionPolicies - :param 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'. + :param 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 """ @@ -157,12 +206,18 @@ class Subscription(Model): 'id': {'key': 'id', 'type': 'str'}, 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, 'display_name': {'key': 'displayName', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'SubscriptionState'}, + 'state': {'key': 'state', 'type': 'str'}, 'subscription_policies': {'key': 'subscriptionPolicies', 'type': 'SubscriptionPolicies'}, 'authorization_source': {'key': 'authorizationSource', 'type': 'str'}, } - def __init__(self, *, subscription_policies=None, authorization_source: str=None, **kwargs) -> None: + def __init__( + self, + *, + subscription_policies: Optional["SubscriptionPolicies"] = None, + authorization_source: Optional[str] = None, + **kwargs + ): super(Subscription, self).__init__(**kwargs) self.id = None self.subscription_id = None @@ -172,21 +227,51 @@ def __init__(self, *, subscription_policies=None, authorization_source: str=None self.authorization_source = authorization_source -class SubscriptionPolicies(Model): +class SubscriptionListResult(msrest.serialization.Model): + """Subscription list operation response. + + 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 + """ + + _validation = { + 'next_link': {'required': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Subscription]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + next_link: str, + value: Optional[List["Subscription"]] = None, + **kwargs + ): + super(SubscriptionListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class SubscriptionPolicies(msrest.serialization.Model): """Subscription policies. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar location_placement_id: The subscription location placement ID. The - ID indicates which regions are visible for a subscription. For example, a - subscription with a location placement Id of Public_2014-09-01 has access - to Azure public regions. + :ivar location_placement_id: The subscription location placement ID. The ID indicates which + regions are visible for a subscription. For example, a subscription with a location placement + Id of Public_2014-09-01 has access to Azure public regions. :vartype location_placement_id: str :ivar quota_id: The subscription quota ID. :vartype quota_id: str - :ivar spending_limit: The subscription spending limit. Possible values - include: 'On', 'Off', 'CurrentPeriodOff' + :ivar spending_limit: The subscription spending limit. Possible values include: "On", "Off", + "CurrentPeriodOff". :vartype spending_limit: str or ~azure.mgmt.resource.subscriptions.v2016_06_01.models.SpendingLimit """ @@ -200,27 +285,28 @@ class SubscriptionPolicies(Model): _attribute_map = { 'location_placement_id': {'key': 'locationPlacementId', 'type': 'str'}, 'quota_id': {'key': 'quotaId', 'type': 'str'}, - 'spending_limit': {'key': 'spendingLimit', 'type': 'SpendingLimit'}, + 'spending_limit': {'key': 'spendingLimit', 'type': 'str'}, } - def __init__(self, **kwargs) -> None: + def __init__( + self, + **kwargs + ): super(SubscriptionPolicies, self).__init__(**kwargs) self.location_placement_id = None self.quota_id = None self.spending_limit = None -class TenantIdDescription(Model): +class TenantIdDescription(msrest.serialization.Model): """Tenant Id information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The fully qualified ID of the tenant. For example, /tenants/00000000-0000-0000-0000-000000000000. :vartype id: str - :ivar tenant_id: The tenant ID. For example, - 00000000-0000-0000-0000-000000000000. + :ivar tenant_id: The tenant ID. For example, 00000000-0000-0000-0000-000000000000. :vartype tenant_id: str """ @@ -234,7 +320,42 @@ class TenantIdDescription(Model): 'tenant_id': {'key': 'tenantId', 'type': 'str'}, } - def __init__(self, **kwargs) -> None: + def __init__( + self, + **kwargs + ): super(TenantIdDescription, self).__init__(**kwargs) self.id = None self.tenant_id = None + + +class TenantListResult(msrest.serialization.Model): + """Tenant Ids information. + + 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 + """ + + _validation = { + 'next_link': {'required': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[TenantIdDescription]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + next_link: str, + value: Optional[List["TenantIdDescription"]] = None, + **kwargs + ): + 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/_paged_models.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/models/_paged_models.py deleted file mode 100644 index 98d92fbff5ce..000000000000 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/models/_paged_models.py +++ /dev/null @@ -1,66 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.paging import Paged - - -class OperationPaged(Paged): - """ - A paging container for iterating over a list of :class:`Operation ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[Operation]'} - } - - def __init__(self, *args, **kwargs): - - super(OperationPaged, self).__init__(*args, **kwargs) -class LocationPaged(Paged): - """ - A paging container for iterating over a list of :class:`Location ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[Location]'} - } - - def __init__(self, *args, **kwargs): - - super(LocationPaged, self).__init__(*args, **kwargs) -class SubscriptionPaged(Paged): - """ - A paging container for iterating over a list of :class:`Subscription ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[Subscription]'} - } - - def __init__(self, *args, **kwargs): - - super(SubscriptionPaged, self).__init__(*args, **kwargs) -class TenantIdDescriptionPaged(Paged): - """ - A paging container for iterating over a list of :class:`TenantIdDescription ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[TenantIdDescription]'} - } - - def __init__(self, *args, **kwargs): - - super(TenantIdDescriptionPaged, self).__init__(*args, **kwargs) 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 bc846c09187b..85f50e46d3d8 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 @@ -1,28 +1,27 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from enum import Enum +class SpendingLimit(str, Enum): + """The subscription spending limit. + """ + + on = "On" + off = "Off" + current_period_off = "CurrentPeriodOff" class SubscriptionState(str, Enum): + """The subscription state. Possible values are Enabled, Warned, PastDue, Disabled, and Deleted. + """ enabled = "Enabled" warned = "Warned" past_due = "PastDue" disabled = "Disabled" deleted = "Deleted" - - -class SpendingLimit(str, Enum): - - on = "On" - off = "Off" - current_period_off = "CurrentPeriodOff" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/operations/__init__.py index 5b07794f3097..5ba2b6faf288 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/operations/__init__.py @@ -1,12 +1,9 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from ._operations import Operations 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 bcaba08cf08a..71e826d06ee3 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 @@ -1,102 +1,106 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class Operations(object): """Operations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.subscriptions.v2016_06_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for the operation. Constant value: "2016-06-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2016-06-01" - - self.config = config + self._config = config def list( - self, custom_headers=None, raw=False, **operation_config): + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.OperationListResult"] """Lists all of the available Microsoft.Resources REST API operations. - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of Operation - :rtype: - ~azure.mgmt.resource.subscriptions.v2016_06_01.models.OperationPaged[~azure.mgmt.resource.subscriptions.v2016_06_01.models.Operation] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of OperationListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-06-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['url'] - + url = self.list.metadata['url'] # type: ignore # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('OperationListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.OperationPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list.metadata = {'url': '/providers/Microsoft.Resources/operations'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.Resources/operations'} # 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 1b5ab1d052c1..9a6ea40b2497 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 @@ -1,232 +1,227 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class SubscriptionsOperations(object): """SubscriptionsOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.subscriptions.v2016_06_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for the operation. Constant value: "2016-06-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2016-06-01" - - self.config = config + self._config = config def list_locations( - self, subscription_id, custom_headers=None, raw=False, **operation_config): - """Gets all available geo-locations. + self, + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.LocationListResult"] + """This operation provides all the locations that are available for resource providers; however, each resource provider may support a subset of this list. - This operation provides all the locations that are available for - resource providers; however, each resource provider may support a - subset of this list. + Gets all available geo-locations. :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of Location - :rtype: - ~azure.mgmt.resource.subscriptions.v2016_06_01.models.LocationPaged[~azure.mgmt.resource.subscriptions.v2016_06_01.models.Location] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of LocationListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-06-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_locations.metadata['url'] + url = self.list_locations.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str') + 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('LocationListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.LocationPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list_locations.metadata = {'url': '/subscriptions/{subscriptionId}/locations'} + return ItemPaged( + get_next, extract_data + ) + list_locations.metadata = {'url': '/subscriptions/{subscriptionId}/locations'} # type: ignore def get( - self, subscription_id, custom_headers=None, raw=False, **operation_config): + self, + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.Subscription" """Gets details about a specified subscription. :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: Subscription or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.subscriptions.v2016_06_01.models.Subscription or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Subscription or the result of cls(response) + :rtype: ~azure.mgmt.resource.subscriptions.v2016_06_01.models.Subscription + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Subscription"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-06-01" + # Construct URL - url = self.get.metadata['url'] + url = self.get.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str') + 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('Subscription', response) + deserialized = self._deserialize('Subscription', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}'} # type: ignore def list( - self, custom_headers=None, raw=False, **operation_config): + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.SubscriptionListResult"] """Gets all subscriptions for a tenant. - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of Subscription - :rtype: - ~azure.mgmt.resource.subscriptions.v2016_06_01.models.SubscriptionPaged[~azure.mgmt.resource.subscriptions.v2016_06_01.models.Subscription] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-06-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['url'] - + url = self.list.metadata['url'] # type: ignore # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('SubscriptionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.SubscriptionPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list.metadata = {'url': '/subscriptions'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions'} # type: ignore 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 890babe9f99d..c432bb35b7e8 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 @@ -1,102 +1,106 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class TenantsOperations(object): """TenantsOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.subscriptions.v2016_06_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for the operation. Constant value: "2016-06-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2016-06-01" - - self.config = config + self._config = config def list( - self, custom_headers=None, raw=False, **operation_config): + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.TenantListResult"] """Gets the tenants for your account. - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of TenantIdDescription - :rtype: - ~azure.mgmt.resource.subscriptions.v2016_06_01.models.TenantIdDescriptionPaged[~azure.mgmt.resource.subscriptions.v2016_06_01.models.TenantIdDescription] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of TenantListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2016-06-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['url'] - + url = self.list.metadata['url'] # type: ignore # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('TenantListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.TenantIdDescriptionPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list.metadata = {'url': '/tenants'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/tenants'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/py.typed b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file 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 deleted file mode 100644 index b2fd3a7ffa39..000000000000 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2016_06_01/version.py +++ /dev/null @@ -1,13 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -VERSION = "2016-06-01" - 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 399e93fb102f..b07b0882922e 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 @@ -1,19 +1,16 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._configuration import SubscriptionClientConfiguration from ._subscription_client import SubscriptionClient -__all__ = ['SubscriptionClient', 'SubscriptionClientConfiguration'] - -from .version import VERSION - -__version__ = VERSION +__all__ = ['SubscriptionClient'] +try: + from ._patch import patch_sdk + patch_sdk() +except ImportError: + pass 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 935bf662873f..935ea6a253fe 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 @@ -1,43 +1,63 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrestazure import AzureConfiguration -from .version import VERSION +from typing import TYPE_CHECKING +from azure.core.configuration import Configuration +from azure.core.pipeline import policies -class SubscriptionClientConfiguration(AzureConfiguration): - """Configuration for SubscriptionClient - Note that all parameters used to create this instance are saved as instance - attributes. +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` - :param str base_url: Service URL - """ - - def __init__( - self, credentials, base_url=None): + from azure.core.credentials import TokenCredential - if credentials is None: - raise ValueError("Parameter 'credentials' must not be None.") - if not base_url: - base_url = 'https://management.azure.com' +VERSION = "unknown" - super(SubscriptionClientConfiguration, self).__init__(base_url) +class SubscriptionClientConfiguration(Configuration): + """Configuration for SubscriptionClient. - # Starting Autorest.Python 4.0.64, make connection pool activated by default - self.keep_alive = True + Note that all parameters used to create this instance are saved as instance + attributes. - self.add_user_agent('azure-mgmt-resource/{}'.format(VERSION)) - self.add_user_agent('Azure-SDK-For-Python') + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + """ - self.credentials = credentials + def __init__( + self, + credential, # type: "TokenCredential" + **kwargs # type: Any + ): + # type: (...) -> None + 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" + self.credential_scopes = ['https://management.azure.com/.default'] + self.credential_scopes.extend(kwargs.pop('credential_scopes', [])) + kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + 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) 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 new file mode 100644 index 000000000000..baca80a1b7b7 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/_metadata.json @@ -0,0 +1,43 @@ +{ + "chosen_version": "2018-06-01", + "total_api_version_list": ["2018-06-01"], + "client": { + "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." + }, + "global_parameters": { + "sync_method": { + "credential": { + "method_signature": "credential, # type: \"TokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials.TokenCredential", + "required": true + } + }, + "async_method": { + "credential": { + "method_signature": "credential, # type: \"AsyncTokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + } + }, + "constant": { + }, + "call": "credential" + }, + "config": { + "credential": true, + "credential_scopes": ["https://management.azure.com/.default"] + }, + "operation_groups": { + "operations": "Operations", + "subscriptions": "SubscriptionsOperations", + "tenants": "TenantsOperations" + }, + "operation_mixins": { + }, + "sync_imports": "None", + "async_imports": "None" +} \ 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 056165548568..641bc207e70f 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 @@ -1,16 +1,19 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.service_client import SDKClient -from msrest import Serializer, Deserializer +from typing import TYPE_CHECKING + +from azure.mgmt.core import ARMPipelineClient +from msrest import Deserializer, Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional from ._configuration import SubscriptionClientConfiguration from .operations import Operations @@ -19,39 +22,53 @@ from . import models -class SubscriptionClient(SDKClient): +class SubscriptionClient(object): """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 config: Configuration for client. - :vartype config: SubscriptionClientConfiguration - :ivar operations: Operations operations :vartype operations: azure.mgmt.resource.subscriptions.v2018_06_01.operations.Operations - :ivar subscriptions: Subscriptions operations + :ivar subscriptions: SubscriptionsOperations operations :vartype subscriptions: azure.mgmt.resource.subscriptions.v2018_06_01.operations.SubscriptionsOperations - :ivar tenants: Tenants operations + :ivar tenants: TenantsOperations operations :vartype tenants: azure.mgmt.resource.subscriptions.v2018_06_01.operations.TenantsOperations - - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential :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. """ def __init__( - self, credentials, base_url=None): - - self.config = SubscriptionClientConfiguration(credentials, base_url) - super(SubscriptionClient, self).__init__(self.config.credentials, self.config) + self, + credential, # type: "TokenCredential" + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + 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) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - self.api_version = '2018-06-01' self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self.operations = Operations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.subscriptions = SubscriptionsOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.tenants = TenantsOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> SubscriptionClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) 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 new file mode 100644 index 000000000000..345034cd2938 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/aio/__init__.py @@ -0,0 +1,10 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._subscription_client_async import SubscriptionClient +__all__ = ['SubscriptionClient'] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/aio/_configuration_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/aio/_configuration_async.py new file mode 100644 index 000000000000..5b0d339f7faa --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/aio/_configuration_async.py @@ -0,0 +1,59 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + +VERSION = "unknown" + +class SubscriptionClientConfiguration(Configuration): + """Configuration for SubscriptionClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + **kwargs: Any + ) -> None: + 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" + self.credential_scopes = ['https://management.azure.com/.default'] + self.credential_scopes.extend(kwargs.pop('credential_scopes', [])) + kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs: Any + ) -> None: + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + 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) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/aio/_subscription_client_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/aio/_subscription_client_async.py new file mode 100644 index 000000000000..0918da1158ea --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/aio/_subscription_client_async.py @@ -0,0 +1,66 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, Optional + +from azure.mgmt.core import AsyncARMPipelineClient +from msrest import Deserializer, Serializer + +from ._configuration_async import SubscriptionClientConfiguration +from .operations_async import Operations +from .operations_async import SubscriptionsOperations +from .operations_async import TenantsOperations +from .. import models + + +class SubscriptionClient(object): + """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_async.Operations + :ivar subscriptions: SubscriptionsOperations operations + :vartype subscriptions: azure.mgmt.resource.subscriptions.v2018_06_01.aio.operations_async.SubscriptionsOperations + :ivar tenants: TenantsOperations operations + :vartype tenants: azure.mgmt.resource.subscriptions.v2018_06_01.aio.operations_async.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 + :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", + base_url: Optional[str] = None, + **kwargs: 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) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + + self.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 close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "SubscriptionClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/aio/operations_async/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/aio/operations_async/__init__.py new file mode 100644 index 000000000000..05cc20fe3ece --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/aio/operations_async/__init__.py @@ -0,0 +1,17 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._operations_async import Operations +from ._subscriptions_operations_async import SubscriptionsOperations +from ._tenants_operations_async import TenantsOperations + +__all__ = [ + 'Operations', + 'SubscriptionsOperations', + 'TenantsOperations', +] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/aio/operations_async/_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/aio/operations_async/_operations_async.py new file mode 100644 index 000000000000..b7a60e0f97d8 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/aio/operations_async/_operations_async.py @@ -0,0 +1,101 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import 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 ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class Operations: + """Operations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.subscriptions.v2018_06_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + **kwargs + ) -> AsyncIterable["models.OperationListResult"]: + """Lists all of the available Microsoft.Resources REST API operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of OperationListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-06-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('OperationListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.Resources/operations'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/aio/operations_async/_subscriptions_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/aio/operations_async/_subscriptions_operations_async.py new file mode 100644 index 000000000000..6325c7022893 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/aio/operations_async/_subscriptions_operations_async.py @@ -0,0 +1,220 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import 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 ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class SubscriptionsOperations: + """SubscriptionsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.subscriptions.v2018_06_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list_locations( + self, + subscription_id: str, + **kwargs + ) -> AsyncIterable["models.LocationListResult"]: + """This operation provides all the locations that are available for resource providers; however, each resource provider may support a subset of this list. + + Gets all available geo-locations. + + :param subscription_id: The ID of the target subscription. + :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 LocationListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-06-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('LocationListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_locations.metadata = {'url': '/subscriptions/{subscriptionId}/locations'} # type: ignore + + async def get( + self, + subscription_id: str, + **kwargs + ) -> "models.Subscription": + """Gets details about a specified subscription. + + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Subscription or the result of cls(response) + :rtype: ~azure.mgmt.resource.subscriptions.v2018_06_01.models.Subscription + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Subscription"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-06-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Subscription', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}'} # type: ignore + + def list( + self, + **kwargs + ) -> AsyncIterable["models.SubscriptionListResult"]: + """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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-06-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('SubscriptionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/aio/operations_async/_tenants_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/aio/operations_async/_tenants_operations_async.py new file mode 100644 index 000000000000..c50408689296 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/aio/operations_async/_tenants_operations_async.py @@ -0,0 +1,101 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import 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 ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class TenantsOperations: + """TenantsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.subscriptions.v2018_06_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + **kwargs + ) -> AsyncIterable["models.TenantListResult"]: + """Gets the tenants for your account. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of TenantListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-06-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('TenantListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/tenants'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/models/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/models/__init__.py index cd1fb5a0855e..4a05f8dc94cf 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/models/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/models/__init__.py @@ -1,48 +1,50 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- try: from ._models_py3 import Location + from ._models_py3 import LocationListResult from ._models_py3 import Operation from ._models_py3 import OperationDisplay + from ._models_py3 import OperationListResult from ._models_py3 import Subscription + from ._models_py3 import SubscriptionListResult from ._models_py3 import SubscriptionPolicies from ._models_py3 import TenantIdDescription + from ._models_py3 import TenantListResult except (SyntaxError, ImportError): - from ._models import Location - from ._models import Operation - from ._models import OperationDisplay - from ._models import Subscription - from ._models import SubscriptionPolicies - from ._models import TenantIdDescription -from ._paged_models import LocationPaged -from ._paged_models import OperationPaged -from ._paged_models import SubscriptionPaged -from ._paged_models import TenantIdDescriptionPaged + from ._models import Location # type: ignore + from ._models import LocationListResult # type: ignore + from ._models import Operation # type: ignore + from ._models import OperationDisplay # type: ignore + from ._models import OperationListResult # type: ignore + from ._models import Subscription # type: ignore + from ._models import SubscriptionListResult # type: ignore + from ._models import SubscriptionPolicies # type: ignore + from ._models import TenantIdDescription # type: ignore + from ._models import TenantListResult # type: ignore + from ._subscription_client_enums import ( - SubscriptionState, SpendingLimit, + SubscriptionState, ) __all__ = [ 'Location', + 'LocationListResult', 'Operation', 'OperationDisplay', + 'OperationListResult', 'Subscription', + 'SubscriptionListResult', 'SubscriptionPolicies', 'TenantIdDescription', - 'OperationPaged', - 'LocationPaged', - 'SubscriptionPaged', - 'TenantIdDescriptionPaged', - 'SubscriptionState', + 'TenantListResult', 'SpendingLimit', + 'SubscriptionState', ] 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 21ba7cc06de9..fc434bb268ce 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 @@ -1,30 +1,18 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.serialization import Model +import msrest.serialization -class CloudError(Model): - """CloudError. - """ - - _attribute_map = { - } - - -class Location(Model): +class Location(msrest.serialization.Model): """Location information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The fully qualified ID of the location. For example, /subscriptions/00000000-0000-0000-0000-000000000000/locations/westus. @@ -59,7 +47,10 @@ class Location(Model): 'longitude': {'key': 'longitude', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Location, self).__init__(**kwargs) self.id = None self.subscription_id = None @@ -69,14 +60,32 @@ def __init__(self, **kwargs): self.longitude = None -class Operation(Model): +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] + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Location]'}, + } + + def __init__( + self, + **kwargs + ): + super(LocationListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + + +class Operation(msrest.serialization.Model): """Microsoft.Resources operation. - :param name: Operation name: {provider}/{resource}/{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 + :type display: ~azure.mgmt.resource.subscriptions.v2018_06_01.models.OperationDisplay """ _attribute_map = { @@ -84,19 +93,21 @@ class Operation(Model): 'display': {'key': 'display', 'type': 'OperationDisplay'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Operation, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.display = kwargs.get('display', None) -class OperationDisplay(Model): +class OperationDisplay(msrest.serialization.Model): """The object that represents the operation. - :param provider: Service provider: Microsoft.Resources + :param provider: Service provider: Microsoft.Resources. :type provider: str - :param resource: Resource on which the operation is performed: Profile, - endpoint, etc. + :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 @@ -111,7 +122,10 @@ class OperationDisplay(Model): 'description': {'key': 'description', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(OperationDisplay, self).__init__(**kwargs) self.provider = kwargs.get('provider', None) self.resource = kwargs.get('resource', None) @@ -119,11 +133,33 @@ def __init__(self, **kwargs): self.description = kwargs.get('description', None) -class Subscription(Model): +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 + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Operation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(OperationListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class Subscription(msrest.serialization.Model): """Subscription information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The fully qualified ID for the subscription. For example, /subscriptions/00000000-0000-0000-0000-000000000000. @@ -134,17 +170,15 @@ class Subscription(Model): :vartype display_name: str :ivar tenant_id: The subscription tenant ID. :vartype tenant_id: str - :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 + :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: ~azure.mgmt.resource.subscriptions.v2018_06_01.models.SubscriptionPolicies - :param 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'. + :param 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 """ @@ -161,12 +195,15 @@ class Subscription(Model): 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, 'display_name': {'key': 'displayName', 'type': 'str'}, 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'SubscriptionState'}, + 'state': {'key': 'state', 'type': 'str'}, 'subscription_policies': {'key': 'subscriptionPolicies', 'type': 'SubscriptionPolicies'}, 'authorization_source': {'key': 'authorizationSource', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Subscription, self).__init__(**kwargs) self.id = None self.subscription_id = None @@ -177,21 +214,48 @@ def __init__(self, **kwargs): self.authorization_source = kwargs.get('authorization_source', None) -class SubscriptionPolicies(Model): +class SubscriptionListResult(msrest.serialization.Model): + """Subscription list operation response. + + 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 + """ + + _validation = { + 'next_link': {'required': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Subscription]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(SubscriptionListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs['next_link'] + + +class SubscriptionPolicies(msrest.serialization.Model): """Subscription policies. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar location_placement_id: The subscription location placement ID. The - ID indicates which regions are visible for a subscription. For example, a - subscription with a location placement Id of Public_2014-09-01 has access - to Azure public regions. + :ivar location_placement_id: The subscription location placement ID. The ID indicates which + regions are visible for a subscription. For example, a subscription with a location placement + Id of Public_2014-09-01 has access to Azure public regions. :vartype location_placement_id: str :ivar quota_id: The subscription quota ID. :vartype quota_id: str - :ivar spending_limit: The subscription spending limit. Possible values - include: 'On', 'Off', 'CurrentPeriodOff' + :ivar spending_limit: The subscription spending limit. Possible values include: "On", "Off", + "CurrentPeriodOff". :vartype spending_limit: str or ~azure.mgmt.resource.subscriptions.v2018_06_01.models.SpendingLimit """ @@ -205,27 +269,28 @@ class SubscriptionPolicies(Model): _attribute_map = { 'location_placement_id': {'key': 'locationPlacementId', 'type': 'str'}, 'quota_id': {'key': 'quotaId', 'type': 'str'}, - 'spending_limit': {'key': 'spendingLimit', 'type': 'SpendingLimit'}, + 'spending_limit': {'key': 'spendingLimit', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(SubscriptionPolicies, self).__init__(**kwargs) self.location_placement_id = None self.quota_id = None self.spending_limit = None -class TenantIdDescription(Model): +class TenantIdDescription(msrest.serialization.Model): """Tenant Id information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The fully qualified ID of the tenant. For example, /tenants/00000000-0000-0000-0000-000000000000. :vartype id: str - :ivar tenant_id: The tenant ID. For example, - 00000000-0000-0000-0000-000000000000. + :ivar tenant_id: The tenant ID. For example, 00000000-0000-0000-0000-000000000000. :vartype tenant_id: str :ivar country: Country/region name of the address for the tenant. :vartype country: str @@ -255,7 +320,10 @@ class TenantIdDescription(Model): 'domains': {'key': 'domains', 'type': '[str]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(TenantIdDescription, self).__init__(**kwargs) self.id = None self.tenant_id = None @@ -263,3 +331,32 @@ def __init__(self, **kwargs): self.country_code = None self.display_name = None self.domains = None + + +class TenantListResult(msrest.serialization.Model): + """Tenant Ids information. + + 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 + """ + + _validation = { + 'next_link': {'required': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[TenantIdDescription]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + 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 b18427d606cc..7f56bf3f2989 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 @@ -1,30 +1,20 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.serialization import Model +from typing import List, Optional - -class CloudError(Model): - """CloudError. - """ - - _attribute_map = { - } +import msrest.serialization -class Location(Model): +class Location(msrest.serialization.Model): """Location information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The fully qualified ID of the location. For example, /subscriptions/00000000-0000-0000-0000-000000000000/locations/westus. @@ -59,7 +49,10 @@ class Location(Model): 'longitude': {'key': 'longitude', 'type': 'str'}, } - def __init__(self, **kwargs) -> None: + def __init__( + self, + **kwargs + ): super(Location, self).__init__(**kwargs) self.id = None self.subscription_id = None @@ -69,14 +62,34 @@ def __init__(self, **kwargs) -> None: self.longitude = None -class Operation(Model): +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] + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Location]'}, + } + + def __init__( + self, + *, + value: Optional[List["Location"]] = None, + **kwargs + ): + super(LocationListResult, self).__init__(**kwargs) + self.value = value + + +class Operation(msrest.serialization.Model): """Microsoft.Resources operation. - :param name: Operation name: {provider}/{resource}/{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 + :type display: ~azure.mgmt.resource.subscriptions.v2018_06_01.models.OperationDisplay """ _attribute_map = { @@ -84,19 +97,24 @@ class Operation(Model): 'display': {'key': 'display', 'type': 'OperationDisplay'}, } - def __init__(self, *, name: str=None, display=None, **kwargs) -> None: + def __init__( + self, + *, + name: Optional[str] = None, + display: Optional["OperationDisplay"] = None, + **kwargs + ): super(Operation, self).__init__(**kwargs) self.name = name self.display = display -class OperationDisplay(Model): +class OperationDisplay(msrest.serialization.Model): """The object that represents the operation. - :param provider: Service provider: Microsoft.Resources + :param provider: Service provider: Microsoft.Resources. :type provider: str - :param resource: Resource on which the operation is performed: Profile, - endpoint, etc. + :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 @@ -111,7 +129,15 @@ class OperationDisplay(Model): 'description': {'key': 'description', 'type': 'str'}, } - def __init__(self, *, provider: str=None, resource: str=None, operation: str=None, description: str=None, **kwargs) -> None: + def __init__( + self, + *, + provider: Optional[str] = None, + resource: Optional[str] = None, + operation: Optional[str] = None, + description: Optional[str] = None, + **kwargs + ): super(OperationDisplay, self).__init__(**kwargs) self.provider = provider self.resource = resource @@ -119,11 +145,36 @@ def __init__(self, *, provider: str=None, resource: str=None, operation: str=Non self.description = description -class Subscription(Model): +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 + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Operation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["Operation"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(OperationListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class Subscription(msrest.serialization.Model): """Subscription information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The fully qualified ID for the subscription. For example, /subscriptions/00000000-0000-0000-0000-000000000000. @@ -134,17 +185,15 @@ class Subscription(Model): :vartype display_name: str :ivar tenant_id: The subscription tenant ID. :vartype tenant_id: str - :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 + :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: ~azure.mgmt.resource.subscriptions.v2018_06_01.models.SubscriptionPolicies - :param 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'. + :param 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 """ @@ -161,12 +210,18 @@ class Subscription(Model): 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, 'display_name': {'key': 'displayName', 'type': 'str'}, 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'SubscriptionState'}, + 'state': {'key': 'state', 'type': 'str'}, 'subscription_policies': {'key': 'subscriptionPolicies', 'type': 'SubscriptionPolicies'}, 'authorization_source': {'key': 'authorizationSource', 'type': 'str'}, } - def __init__(self, *, subscription_policies=None, authorization_source: str=None, **kwargs) -> None: + def __init__( + self, + *, + subscription_policies: Optional["SubscriptionPolicies"] = None, + authorization_source: Optional[str] = None, + **kwargs + ): super(Subscription, self).__init__(**kwargs) self.id = None self.subscription_id = None @@ -177,21 +232,51 @@ def __init__(self, *, subscription_policies=None, authorization_source: str=None self.authorization_source = authorization_source -class SubscriptionPolicies(Model): +class SubscriptionListResult(msrest.serialization.Model): + """Subscription list operation response. + + 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 + """ + + _validation = { + 'next_link': {'required': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Subscription]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + next_link: str, + value: Optional[List["Subscription"]] = None, + **kwargs + ): + super(SubscriptionListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class SubscriptionPolicies(msrest.serialization.Model): """Subscription policies. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar location_placement_id: The subscription location placement ID. The - ID indicates which regions are visible for a subscription. For example, a - subscription with a location placement Id of Public_2014-09-01 has access - to Azure public regions. + :ivar location_placement_id: The subscription location placement ID. The ID indicates which + regions are visible for a subscription. For example, a subscription with a location placement + Id of Public_2014-09-01 has access to Azure public regions. :vartype location_placement_id: str :ivar quota_id: The subscription quota ID. :vartype quota_id: str - :ivar spending_limit: The subscription spending limit. Possible values - include: 'On', 'Off', 'CurrentPeriodOff' + :ivar spending_limit: The subscription spending limit. Possible values include: "On", "Off", + "CurrentPeriodOff". :vartype spending_limit: str or ~azure.mgmt.resource.subscriptions.v2018_06_01.models.SpendingLimit """ @@ -205,27 +290,28 @@ class SubscriptionPolicies(Model): _attribute_map = { 'location_placement_id': {'key': 'locationPlacementId', 'type': 'str'}, 'quota_id': {'key': 'quotaId', 'type': 'str'}, - 'spending_limit': {'key': 'spendingLimit', 'type': 'SpendingLimit'}, + 'spending_limit': {'key': 'spendingLimit', 'type': 'str'}, } - def __init__(self, **kwargs) -> None: + def __init__( + self, + **kwargs + ): super(SubscriptionPolicies, self).__init__(**kwargs) self.location_placement_id = None self.quota_id = None self.spending_limit = None -class TenantIdDescription(Model): +class TenantIdDescription(msrest.serialization.Model): """Tenant Id information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The fully qualified ID of the tenant. For example, /tenants/00000000-0000-0000-0000-000000000000. :vartype id: str - :ivar tenant_id: The tenant ID. For example, - 00000000-0000-0000-0000-000000000000. + :ivar tenant_id: The tenant ID. For example, 00000000-0000-0000-0000-000000000000. :vartype tenant_id: str :ivar country: Country/region name of the address for the tenant. :vartype country: str @@ -255,7 +341,10 @@ class TenantIdDescription(Model): 'domains': {'key': 'domains', 'type': '[str]'}, } - def __init__(self, **kwargs) -> None: + def __init__( + self, + **kwargs + ): super(TenantIdDescription, self).__init__(**kwargs) self.id = None self.tenant_id = None @@ -263,3 +352,35 @@ def __init__(self, **kwargs) -> None: self.country_code = None self.display_name = None self.domains = None + + +class TenantListResult(msrest.serialization.Model): + """Tenant Ids information. + + 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 + """ + + _validation = { + 'next_link': {'required': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[TenantIdDescription]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + next_link: str, + value: Optional[List["TenantIdDescription"]] = None, + **kwargs + ): + 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/_paged_models.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/models/_paged_models.py deleted file mode 100644 index abeccdbcc762..000000000000 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/models/_paged_models.py +++ /dev/null @@ -1,66 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.paging import Paged - - -class OperationPaged(Paged): - """ - A paging container for iterating over a list of :class:`Operation ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[Operation]'} - } - - def __init__(self, *args, **kwargs): - - super(OperationPaged, self).__init__(*args, **kwargs) -class LocationPaged(Paged): - """ - A paging container for iterating over a list of :class:`Location ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[Location]'} - } - - def __init__(self, *args, **kwargs): - - super(LocationPaged, self).__init__(*args, **kwargs) -class SubscriptionPaged(Paged): - """ - A paging container for iterating over a list of :class:`Subscription ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[Subscription]'} - } - - def __init__(self, *args, **kwargs): - - super(SubscriptionPaged, self).__init__(*args, **kwargs) -class TenantIdDescriptionPaged(Paged): - """ - A paging container for iterating over a list of :class:`TenantIdDescription ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[TenantIdDescription]'} - } - - def __init__(self, *args, **kwargs): - - super(TenantIdDescriptionPaged, self).__init__(*args, **kwargs) 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 bc846c09187b..85f50e46d3d8 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 @@ -1,28 +1,27 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from enum import Enum +class SpendingLimit(str, Enum): + """The subscription spending limit. + """ + + on = "On" + off = "Off" + current_period_off = "CurrentPeriodOff" class SubscriptionState(str, Enum): + """The subscription state. Possible values are Enabled, Warned, PastDue, Disabled, and Deleted. + """ enabled = "Enabled" warned = "Warned" past_due = "PastDue" disabled = "Disabled" deleted = "Deleted" - - -class SpendingLimit(str, Enum): - - on = "On" - off = "Off" - current_period_off = "CurrentPeriodOff" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/operations/__init__.py index 5b07794f3097..5ba2b6faf288 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/operations/__init__.py @@ -1,12 +1,9 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from ._operations import Operations 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 88f938fc4e31..51d6edf9598d 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 @@ -1,102 +1,106 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class Operations(object): """Operations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.subscriptions.v2018_06_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for the operation. Constant value: "2018-06-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2018-06-01" - - self.config = config + self._config = config def list( - self, custom_headers=None, raw=False, **operation_config): + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.OperationListResult"] """Lists all of the available Microsoft.Resources REST API operations. - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of Operation - :rtype: - ~azure.mgmt.resource.subscriptions.v2018_06_01.models.OperationPaged[~azure.mgmt.resource.subscriptions.v2018_06_01.models.Operation] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of OperationListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-06-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['url'] - + url = self.list.metadata['url'] # type: ignore # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('OperationListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.OperationPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list.metadata = {'url': '/providers/Microsoft.Resources/operations'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.Resources/operations'} # 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 bccda2e3bb8d..e7d0fffd7f8f 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 @@ -1,232 +1,227 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class SubscriptionsOperations(object): """SubscriptionsOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.subscriptions.v2018_06_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for the operation. Constant value: "2018-06-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2018-06-01" - - self.config = config + self._config = config def list_locations( - self, subscription_id, custom_headers=None, raw=False, **operation_config): - """Gets all available geo-locations. + self, + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.LocationListResult"] + """This operation provides all the locations that are available for resource providers; however, each resource provider may support a subset of this list. - This operation provides all the locations that are available for - resource providers; however, each resource provider may support a - subset of this list. + Gets all available geo-locations. :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of Location - :rtype: - ~azure.mgmt.resource.subscriptions.v2018_06_01.models.LocationPaged[~azure.mgmt.resource.subscriptions.v2018_06_01.models.Location] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of LocationListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-06-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_locations.metadata['url'] + url = self.list_locations.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str') + 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('LocationListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.LocationPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list_locations.metadata = {'url': '/subscriptions/{subscriptionId}/locations'} + return ItemPaged( + get_next, extract_data + ) + list_locations.metadata = {'url': '/subscriptions/{subscriptionId}/locations'} # type: ignore def get( - self, subscription_id, custom_headers=None, raw=False, **operation_config): + self, + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.Subscription" """Gets details about a specified subscription. :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: Subscription or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.subscriptions.v2018_06_01.models.Subscription or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Subscription or the result of cls(response) + :rtype: ~azure.mgmt.resource.subscriptions.v2018_06_01.models.Subscription + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Subscription"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-06-01" + # Construct URL - url = self.get.metadata['url'] + url = self.get.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str') + 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('Subscription', response) + deserialized = self._deserialize('Subscription', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}'} # type: ignore def list( - self, custom_headers=None, raw=False, **operation_config): + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.SubscriptionListResult"] """Gets all subscriptions for a tenant. - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of Subscription - :rtype: - ~azure.mgmt.resource.subscriptions.v2018_06_01.models.SubscriptionPaged[~azure.mgmt.resource.subscriptions.v2018_06_01.models.Subscription] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-06-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['url'] - + url = self.list.metadata['url'] # type: ignore # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('SubscriptionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.SubscriptionPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list.metadata = {'url': '/subscriptions'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions'} # type: ignore 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 d0e2fb118ff8..a1eed767dbdf 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 @@ -1,102 +1,106 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class TenantsOperations(object): """TenantsOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.subscriptions.v2018_06_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for the operation. Constant value: "2018-06-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2018-06-01" - - self.config = config + self._config = config def list( - self, custom_headers=None, raw=False, **operation_config): + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.TenantListResult"] """Gets the tenants for your account. - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of TenantIdDescription - :rtype: - ~azure.mgmt.resource.subscriptions.v2018_06_01.models.TenantIdDescriptionPaged[~azure.mgmt.resource.subscriptions.v2018_06_01.models.TenantIdDescription] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of TenantListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-06-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['url'] - + url = self.list.metadata['url'] # type: ignore # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('TenantListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.TenantIdDescriptionPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list.metadata = {'url': '/tenants'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/tenants'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/py.typed b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file 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 deleted file mode 100644 index 5f1af9fb17b6..000000000000 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2018_06_01/version.py +++ /dev/null @@ -1,13 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -VERSION = "2018-06-01" - 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 399e93fb102f..b07b0882922e 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 @@ -1,19 +1,16 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._configuration import SubscriptionClientConfiguration from ._subscription_client import SubscriptionClient -__all__ = ['SubscriptionClient', 'SubscriptionClientConfiguration'] - -from .version import VERSION - -__version__ = VERSION +__all__ = ['SubscriptionClient'] +try: + from ._patch import patch_sdk + patch_sdk() +except ImportError: + pass 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 935bf662873f..6ff6bf4d5904 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 @@ -1,43 +1,63 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrestazure import AzureConfiguration -from .version import VERSION +from typing import TYPE_CHECKING +from azure.core.configuration import Configuration +from azure.core.pipeline import policies -class SubscriptionClientConfiguration(AzureConfiguration): - """Configuration for SubscriptionClient - Note that all parameters used to create this instance are saved as instance - attributes. +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` - :param str base_url: Service URL - """ - - def __init__( - self, credentials, base_url=None): + from azure.core.credentials import TokenCredential - if credentials is None: - raise ValueError("Parameter 'credentials' must not be None.") - if not base_url: - base_url = 'https://management.azure.com' +VERSION = "unknown" - super(SubscriptionClientConfiguration, self).__init__(base_url) +class SubscriptionClientConfiguration(Configuration): + """Configuration for SubscriptionClient. - # Starting Autorest.Python 4.0.64, make connection pool activated by default - self.keep_alive = True + Note that all parameters used to create this instance are saved as instance + attributes. - self.add_user_agent('azure-mgmt-resource/{}'.format(VERSION)) - self.add_user_agent('Azure-SDK-For-Python') + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + """ - self.credentials = credentials + def __init__( + self, + credential, # type: "TokenCredential" + **kwargs # type: Any + ): + # type: (...) -> None + 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" + self.credential_scopes = ['https://management.azure.com/.default'] + self.credential_scopes.extend(kwargs.pop('credential_scopes', [])) + kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + 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) 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 new file mode 100644 index 000000000000..2677a4beed04 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/_metadata.json @@ -0,0 +1,43 @@ +{ + "chosen_version": "2019-06-01", + "total_api_version_list": ["2019-06-01"], + "client": { + "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." + }, + "global_parameters": { + "sync_method": { + "credential": { + "method_signature": "credential, # type: \"TokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials.TokenCredential", + "required": true + } + }, + "async_method": { + "credential": { + "method_signature": "credential, # type: \"AsyncTokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + } + }, + "constant": { + }, + "call": "credential" + }, + "config": { + "credential": true, + "credential_scopes": ["https://management.azure.com/.default"] + }, + "operation_groups": { + "operations": "Operations", + "subscriptions": "SubscriptionsOperations", + "tenants": "TenantsOperations" + }, + "operation_mixins": { + }, + "sync_imports": "None", + "async_imports": "None" +} \ 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 9bcc5e0e0053..1b44b2a1e4b2 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 @@ -1,16 +1,19 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.service_client import SDKClient -from msrest import Serializer, Deserializer +from typing import TYPE_CHECKING + +from azure.mgmt.core import ARMPipelineClient +from msrest import Deserializer, Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional from ._configuration import SubscriptionClientConfiguration from .operations import Operations @@ -19,39 +22,53 @@ from . import models -class SubscriptionClient(SDKClient): +class SubscriptionClient(object): """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 config: Configuration for client. - :vartype config: SubscriptionClientConfiguration - :ivar operations: Operations operations :vartype operations: azure.mgmt.resource.subscriptions.v2019_06_01.operations.Operations - :ivar subscriptions: Subscriptions operations + :ivar subscriptions: SubscriptionsOperations operations :vartype subscriptions: azure.mgmt.resource.subscriptions.v2019_06_01.operations.SubscriptionsOperations - :ivar tenants: Tenants operations + :ivar tenants: TenantsOperations operations :vartype tenants: azure.mgmt.resource.subscriptions.v2019_06_01.operations.TenantsOperations - - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential :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. """ def __init__( - self, credentials, base_url=None): - - self.config = SubscriptionClientConfiguration(credentials, base_url) - super(SubscriptionClient, self).__init__(self.config.credentials, self.config) + self, + credential, # type: "TokenCredential" + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + 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) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - self.api_version = '2019-06-01' self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self.operations = Operations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.subscriptions = SubscriptionsOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.tenants = TenantsOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> SubscriptionClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) 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 new file mode 100644 index 000000000000..345034cd2938 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/aio/__init__.py @@ -0,0 +1,10 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._subscription_client_async import SubscriptionClient +__all__ = ['SubscriptionClient'] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/aio/_configuration_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/aio/_configuration_async.py new file mode 100644 index 000000000000..8cd26dac5608 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/aio/_configuration_async.py @@ -0,0 +1,59 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + +VERSION = "unknown" + +class SubscriptionClientConfiguration(Configuration): + """Configuration for SubscriptionClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + **kwargs: Any + ) -> None: + 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" + self.credential_scopes = ['https://management.azure.com/.default'] + self.credential_scopes.extend(kwargs.pop('credential_scopes', [])) + kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs: Any + ) -> None: + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + 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) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/aio/_subscription_client_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/aio/_subscription_client_async.py new file mode 100644 index 000000000000..d1d477b9cc4b --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/aio/_subscription_client_async.py @@ -0,0 +1,66 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, Optional + +from azure.mgmt.core import AsyncARMPipelineClient +from msrest import Deserializer, Serializer + +from ._configuration_async import SubscriptionClientConfiguration +from .operations_async import Operations +from .operations_async import SubscriptionsOperations +from .operations_async import TenantsOperations +from .. import models + + +class SubscriptionClient(object): + """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_async.Operations + :ivar subscriptions: SubscriptionsOperations operations + :vartype subscriptions: azure.mgmt.resource.subscriptions.v2019_06_01.aio.operations_async.SubscriptionsOperations + :ivar tenants: TenantsOperations operations + :vartype tenants: azure.mgmt.resource.subscriptions.v2019_06_01.aio.operations_async.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 + :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", + base_url: Optional[str] = None, + **kwargs: 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) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + + self.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 close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "SubscriptionClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/aio/operations_async/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/aio/operations_async/__init__.py new file mode 100644 index 000000000000..05cc20fe3ece --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/aio/operations_async/__init__.py @@ -0,0 +1,17 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._operations_async import Operations +from ._subscriptions_operations_async import SubscriptionsOperations +from ._tenants_operations_async import TenantsOperations + +__all__ = [ + 'Operations', + 'SubscriptionsOperations', + 'TenantsOperations', +] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/aio/operations_async/_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/aio/operations_async/_operations_async.py new file mode 100644 index 000000000000..602001ff0637 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/aio/operations_async/_operations_async.py @@ -0,0 +1,101 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import 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 ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class Operations: + """Operations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.subscriptions.v2019_06_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + **kwargs + ) -> AsyncIterable["models.OperationListResult"]: + """Lists all of the available Microsoft.Resources REST API operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of OperationListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('OperationListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.Resources/operations'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/aio/operations_async/_subscriptions_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/aio/operations_async/_subscriptions_operations_async.py new file mode 100644 index 000000000000..2deb1f54a117 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/aio/operations_async/_subscriptions_operations_async.py @@ -0,0 +1,220 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import 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 ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class SubscriptionsOperations: + """SubscriptionsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.subscriptions.v2019_06_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list_locations( + self, + subscription_id: str, + **kwargs + ) -> AsyncIterable["models.LocationListResult"]: + """This operation provides all the locations that are available for resource providers; however, each resource provider may support a subset of this list. + + Gets all available geo-locations. + + :param subscription_id: The ID of the target subscription. + :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 LocationListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('LocationListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_locations.metadata = {'url': '/subscriptions/{subscriptionId}/locations'} # type: ignore + + async def get( + self, + subscription_id: str, + **kwargs + ) -> "models.Subscription": + """Gets details about a specified subscription. + + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Subscription or the result of cls(response) + :rtype: ~azure.mgmt.resource.subscriptions.v2019_06_01.models.Subscription + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Subscription"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Subscription', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}'} # type: ignore + + def list( + self, + **kwargs + ) -> AsyncIterable["models.SubscriptionListResult"]: + """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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('SubscriptionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/aio/operations_async/_tenants_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/aio/operations_async/_tenants_operations_async.py new file mode 100644 index 000000000000..9e177675031f --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/aio/operations_async/_tenants_operations_async.py @@ -0,0 +1,101 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import 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 ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class TenantsOperations: + """TenantsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.subscriptions.v2019_06_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + **kwargs + ) -> AsyncIterable["models.TenantListResult"]: + """Gets the tenants for your account. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of TenantListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('TenantListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/tenants'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/models/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/models/__init__.py index d7233118a968..fe0f04cc3aed 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/models/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/models/__init__.py @@ -1,53 +1,55 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- try: from ._models_py3 import Location + from ._models_py3 import LocationListResult from ._models_py3 import ManagedByTenant from ._models_py3 import Operation from ._models_py3 import OperationDisplay + from ._models_py3 import OperationListResult from ._models_py3 import Subscription + from ._models_py3 import SubscriptionListResult from ._models_py3 import SubscriptionPolicies from ._models_py3 import TenantIdDescription + from ._models_py3 import TenantListResult except (SyntaxError, ImportError): - from ._models import Location - from ._models import ManagedByTenant - from ._models import Operation - from ._models import OperationDisplay - from ._models import Subscription - from ._models import SubscriptionPolicies - from ._models import TenantIdDescription -from ._paged_models import LocationPaged -from ._paged_models import OperationPaged -from ._paged_models import SubscriptionPaged -from ._paged_models import TenantIdDescriptionPaged + from ._models import Location # type: ignore + from ._models import LocationListResult # type: ignore + from ._models import ManagedByTenant # type: ignore + from ._models import Operation # type: ignore + from ._models import OperationDisplay # type: ignore + from ._models import OperationListResult # type: ignore + from ._models import Subscription # type: ignore + from ._models import SubscriptionListResult # type: ignore + from ._models import SubscriptionPolicies # type: ignore + from ._models import TenantIdDescription # type: ignore + from ._models import TenantListResult # type: ignore + from ._subscription_client_enums import ( - SubscriptionState, SpendingLimit, + SubscriptionState, TenantCategory, ) __all__ = [ 'Location', + 'LocationListResult', 'ManagedByTenant', 'Operation', 'OperationDisplay', + 'OperationListResult', 'Subscription', + 'SubscriptionListResult', 'SubscriptionPolicies', 'TenantIdDescription', - 'OperationPaged', - 'LocationPaged', - 'SubscriptionPaged', - 'TenantIdDescriptionPaged', - 'SubscriptionState', + 'TenantListResult', 'SpendingLimit', + 'SubscriptionState', 'TenantCategory', ] 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 8d63331e9684..3a23caf3cee0 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 @@ -1,30 +1,18 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.serialization import Model +import msrest.serialization -class CloudError(Model): - """CloudError. - """ - - _attribute_map = { - } - - -class Location(Model): +class Location(msrest.serialization.Model): """Location information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The fully qualified ID of the location. For example, /subscriptions/00000000-0000-0000-0000-000000000000/locations/westus. @@ -59,7 +47,10 @@ class Location(Model): 'longitude': {'key': 'longitude', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Location, self).__init__(**kwargs) self.id = None self.subscription_id = None @@ -69,11 +60,29 @@ def __init__(self, **kwargs): self.longitude = None -class ManagedByTenant(Model): +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] + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Location]'}, + } + + def __init__( + self, + **kwargs + ): + super(LocationListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + + +class ManagedByTenant(msrest.serialization.Model): """Information about a tenant managing the subscription. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar tenant_id: The tenant ID of the managing tenant. This is a GUID. :vartype tenant_id: str @@ -87,19 +96,21 @@ class ManagedByTenant(Model): 'tenant_id': {'key': 'tenantId', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ManagedByTenant, self).__init__(**kwargs) self.tenant_id = None -class Operation(Model): +class Operation(msrest.serialization.Model): """Microsoft.Resources operation. - :param name: Operation name: {provider}/{resource}/{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 + :type display: ~azure.mgmt.resource.subscriptions.v2019_06_01.models.OperationDisplay """ _attribute_map = { @@ -107,19 +118,21 @@ class Operation(Model): 'display': {'key': 'display', 'type': 'OperationDisplay'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Operation, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.display = kwargs.get('display', None) -class OperationDisplay(Model): +class OperationDisplay(msrest.serialization.Model): """The object that represents the operation. - :param provider: Service provider: Microsoft.Resources + :param provider: Service provider: Microsoft.Resources. :type provider: str - :param resource: Resource on which the operation is performed: Profile, - endpoint, etc. + :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 @@ -134,7 +147,10 @@ class OperationDisplay(Model): 'description': {'key': 'description', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(OperationDisplay, self).__init__(**kwargs) self.provider = kwargs.get('provider', None) self.resource = kwargs.get('resource', None) @@ -142,11 +158,33 @@ def __init__(self, **kwargs): self.description = kwargs.get('description', None) -class Subscription(Model): +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 + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Operation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(OperationListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class Subscription(msrest.serialization.Model): """Subscription information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The fully qualified ID for the subscription. For example, /subscriptions/00000000-0000-0000-0000-000000000000. @@ -157,20 +195,17 @@ class Subscription(Model): :vartype display_name: str :ivar tenant_id: The subscription tenant ID. :vartype tenant_id: str - :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 + :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: ~azure.mgmt.resource.subscriptions.v2019_06_01.models.SubscriptionPolicies - :param 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'. + :param 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. + :param managed_by_tenants: An array containing the tenants managing the subscription. :type managed_by_tenants: list[~azure.mgmt.resource.subscriptions.v2019_06_01.models.ManagedByTenant] """ @@ -188,13 +223,16 @@ class Subscription(Model): 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, 'display_name': {'key': 'displayName', 'type': 'str'}, 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'SubscriptionState'}, + 'state': {'key': 'state', 'type': 'str'}, 'subscription_policies': {'key': 'subscriptionPolicies', 'type': 'SubscriptionPolicies'}, 'authorization_source': {'key': 'authorizationSource', 'type': 'str'}, 'managed_by_tenants': {'key': 'managedByTenants', 'type': '[ManagedByTenant]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Subscription, self).__init__(**kwargs) self.id = None self.subscription_id = None @@ -206,21 +244,48 @@ def __init__(self, **kwargs): self.managed_by_tenants = kwargs.get('managed_by_tenants', None) -class SubscriptionPolicies(Model): +class SubscriptionListResult(msrest.serialization.Model): + """Subscription list operation response. + + 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 + """ + + _validation = { + 'next_link': {'required': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Subscription]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(SubscriptionListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs['next_link'] + + +class SubscriptionPolicies(msrest.serialization.Model): """Subscription policies. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar location_placement_id: The subscription location placement ID. The - ID indicates which regions are visible for a subscription. For example, a - subscription with a location placement Id of Public_2014-09-01 has access - to Azure public regions. + :ivar location_placement_id: The subscription location placement ID. The ID indicates which + regions are visible for a subscription. For example, a subscription with a location placement + Id of Public_2014-09-01 has access to Azure public regions. :vartype location_placement_id: str :ivar quota_id: The subscription quota ID. :vartype quota_id: str - :ivar spending_limit: The subscription spending limit. Possible values - include: 'On', 'Off', 'CurrentPeriodOff' + :ivar spending_limit: The subscription spending limit. Possible values include: "On", "Off", + "CurrentPeriodOff". :vartype spending_limit: str or ~azure.mgmt.resource.subscriptions.v2019_06_01.models.SpendingLimit """ @@ -234,30 +299,31 @@ class SubscriptionPolicies(Model): _attribute_map = { 'location_placement_id': {'key': 'locationPlacementId', 'type': 'str'}, 'quota_id': {'key': 'quotaId', 'type': 'str'}, - 'spending_limit': {'key': 'spendingLimit', 'type': 'SpendingLimit'}, + 'spending_limit': {'key': 'spendingLimit', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(SubscriptionPolicies, self).__init__(**kwargs) self.location_placement_id = None self.quota_id = None self.spending_limit = None -class TenantIdDescription(Model): +class TenantIdDescription(msrest.serialization.Model): """Tenant Id information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The fully qualified ID of the tenant. For example, /tenants/00000000-0000-0000-0000-000000000000. :vartype id: str - :ivar tenant_id: The tenant ID. For example, - 00000000-0000-0000-0000-000000000000. + :ivar tenant_id: The tenant ID. For example, 00000000-0000-0000-0000-000000000000. :vartype tenant_id: str - :ivar tenant_category: The tenant category. Possible values include: - 'Home', 'ProjectedBy', 'ManagedBy' + :ivar tenant_category: The tenant category. Possible values include: "Home", "ProjectedBy", + "ManagedBy". :vartype tenant_category: str or ~azure.mgmt.resource.subscriptions.v2019_06_01.models.TenantCategory :ivar country: Country/region name of the address for the tenant. @@ -283,14 +349,17 @@ class TenantIdDescription(Model): _attribute_map = { 'id': {'key': 'id', 'type': 'str'}, 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'tenant_category': {'key': 'tenantCategory', 'type': 'TenantCategory'}, + 'tenant_category': {'key': 'tenantCategory', 'type': 'str'}, 'country': {'key': 'country', 'type': 'str'}, 'country_code': {'key': 'countryCode', 'type': 'str'}, 'display_name': {'key': 'displayName', 'type': 'str'}, 'domains': {'key': 'domains', 'type': '[str]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(TenantIdDescription, self).__init__(**kwargs) self.id = None self.tenant_id = None @@ -299,3 +368,32 @@ def __init__(self, **kwargs): self.country_code = None self.display_name = None self.domains = None + + +class TenantListResult(msrest.serialization.Model): + """Tenant Ids information. + + 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 + """ + + _validation = { + 'next_link': {'required': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[TenantIdDescription]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + 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 fa15df1e87e3..aa8046de37fa 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 @@ -1,30 +1,20 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.serialization import Model +from typing import List, Optional - -class CloudError(Model): - """CloudError. - """ - - _attribute_map = { - } +import msrest.serialization -class Location(Model): +class Location(msrest.serialization.Model): """Location information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The fully qualified ID of the location. For example, /subscriptions/00000000-0000-0000-0000-000000000000/locations/westus. @@ -59,7 +49,10 @@ class Location(Model): 'longitude': {'key': 'longitude', 'type': 'str'}, } - def __init__(self, **kwargs) -> None: + def __init__( + self, + **kwargs + ): super(Location, self).__init__(**kwargs) self.id = None self.subscription_id = None @@ -69,11 +62,31 @@ def __init__(self, **kwargs) -> None: self.longitude = None -class ManagedByTenant(Model): +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] + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Location]'}, + } + + def __init__( + self, + *, + value: Optional[List["Location"]] = None, + **kwargs + ): + super(LocationListResult, self).__init__(**kwargs) + self.value = value + + +class ManagedByTenant(msrest.serialization.Model): """Information about a tenant managing the subscription. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar tenant_id: The tenant ID of the managing tenant. This is a GUID. :vartype tenant_id: str @@ -87,19 +100,21 @@ class ManagedByTenant(Model): 'tenant_id': {'key': 'tenantId', 'type': 'str'}, } - def __init__(self, **kwargs) -> None: + def __init__( + self, + **kwargs + ): super(ManagedByTenant, self).__init__(**kwargs) self.tenant_id = None -class Operation(Model): +class Operation(msrest.serialization.Model): """Microsoft.Resources operation. - :param name: Operation name: {provider}/{resource}/{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 + :type display: ~azure.mgmt.resource.subscriptions.v2019_06_01.models.OperationDisplay """ _attribute_map = { @@ -107,19 +122,24 @@ class Operation(Model): 'display': {'key': 'display', 'type': 'OperationDisplay'}, } - def __init__(self, *, name: str=None, display=None, **kwargs) -> None: + def __init__( + self, + *, + name: Optional[str] = None, + display: Optional["OperationDisplay"] = None, + **kwargs + ): super(Operation, self).__init__(**kwargs) self.name = name self.display = display -class OperationDisplay(Model): +class OperationDisplay(msrest.serialization.Model): """The object that represents the operation. - :param provider: Service provider: Microsoft.Resources + :param provider: Service provider: Microsoft.Resources. :type provider: str - :param resource: Resource on which the operation is performed: Profile, - endpoint, etc. + :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 @@ -134,7 +154,15 @@ class OperationDisplay(Model): 'description': {'key': 'description', 'type': 'str'}, } - def __init__(self, *, provider: str=None, resource: str=None, operation: str=None, description: str=None, **kwargs) -> None: + def __init__( + self, + *, + provider: Optional[str] = None, + resource: Optional[str] = None, + operation: Optional[str] = None, + description: Optional[str] = None, + **kwargs + ): super(OperationDisplay, self).__init__(**kwargs) self.provider = provider self.resource = resource @@ -142,11 +170,36 @@ def __init__(self, *, provider: str=None, resource: str=None, operation: str=Non self.description = description -class Subscription(Model): +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 + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Operation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["Operation"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(OperationListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class Subscription(msrest.serialization.Model): """Subscription information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The fully qualified ID for the subscription. For example, /subscriptions/00000000-0000-0000-0000-000000000000. @@ -157,20 +210,17 @@ class Subscription(Model): :vartype display_name: str :ivar tenant_id: The subscription tenant ID. :vartype tenant_id: str - :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 + :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: ~azure.mgmt.resource.subscriptions.v2019_06_01.models.SubscriptionPolicies - :param 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'. + :param 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. + :param managed_by_tenants: An array containing the tenants managing the subscription. :type managed_by_tenants: list[~azure.mgmt.resource.subscriptions.v2019_06_01.models.ManagedByTenant] """ @@ -188,13 +238,20 @@ class Subscription(Model): 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, 'display_name': {'key': 'displayName', 'type': 'str'}, 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'SubscriptionState'}, + 'state': {'key': 'state', 'type': 'str'}, 'subscription_policies': {'key': 'subscriptionPolicies', 'type': 'SubscriptionPolicies'}, 'authorization_source': {'key': 'authorizationSource', 'type': 'str'}, 'managed_by_tenants': {'key': 'managedByTenants', 'type': '[ManagedByTenant]'}, } - def __init__(self, *, subscription_policies=None, authorization_source: str=None, managed_by_tenants=None, **kwargs) -> None: + def __init__( + self, + *, + subscription_policies: Optional["SubscriptionPolicies"] = None, + authorization_source: Optional[str] = None, + managed_by_tenants: Optional[List["ManagedByTenant"]] = None, + **kwargs + ): super(Subscription, self).__init__(**kwargs) self.id = None self.subscription_id = None @@ -206,21 +263,51 @@ def __init__(self, *, subscription_policies=None, authorization_source: str=None self.managed_by_tenants = managed_by_tenants -class SubscriptionPolicies(Model): +class SubscriptionListResult(msrest.serialization.Model): + """Subscription list operation response. + + 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 + """ + + _validation = { + 'next_link': {'required': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Subscription]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + next_link: str, + value: Optional[List["Subscription"]] = None, + **kwargs + ): + super(SubscriptionListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class SubscriptionPolicies(msrest.serialization.Model): """Subscription policies. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar location_placement_id: The subscription location placement ID. The - ID indicates which regions are visible for a subscription. For example, a - subscription with a location placement Id of Public_2014-09-01 has access - to Azure public regions. + :ivar location_placement_id: The subscription location placement ID. The ID indicates which + regions are visible for a subscription. For example, a subscription with a location placement + Id of Public_2014-09-01 has access to Azure public regions. :vartype location_placement_id: str :ivar quota_id: The subscription quota ID. :vartype quota_id: str - :ivar spending_limit: The subscription spending limit. Possible values - include: 'On', 'Off', 'CurrentPeriodOff' + :ivar spending_limit: The subscription spending limit. Possible values include: "On", "Off", + "CurrentPeriodOff". :vartype spending_limit: str or ~azure.mgmt.resource.subscriptions.v2019_06_01.models.SpendingLimit """ @@ -234,30 +321,31 @@ class SubscriptionPolicies(Model): _attribute_map = { 'location_placement_id': {'key': 'locationPlacementId', 'type': 'str'}, 'quota_id': {'key': 'quotaId', 'type': 'str'}, - 'spending_limit': {'key': 'spendingLimit', 'type': 'SpendingLimit'}, + 'spending_limit': {'key': 'spendingLimit', 'type': 'str'}, } - def __init__(self, **kwargs) -> None: + def __init__( + self, + **kwargs + ): super(SubscriptionPolicies, self).__init__(**kwargs) self.location_placement_id = None self.quota_id = None self.spending_limit = None -class TenantIdDescription(Model): +class TenantIdDescription(msrest.serialization.Model): """Tenant Id information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The fully qualified ID of the tenant. For example, /tenants/00000000-0000-0000-0000-000000000000. :vartype id: str - :ivar tenant_id: The tenant ID. For example, - 00000000-0000-0000-0000-000000000000. + :ivar tenant_id: The tenant ID. For example, 00000000-0000-0000-0000-000000000000. :vartype tenant_id: str - :ivar tenant_category: The tenant category. Possible values include: - 'Home', 'ProjectedBy', 'ManagedBy' + :ivar tenant_category: The tenant category. Possible values include: "Home", "ProjectedBy", + "ManagedBy". :vartype tenant_category: str or ~azure.mgmt.resource.subscriptions.v2019_06_01.models.TenantCategory :ivar country: Country/region name of the address for the tenant. @@ -283,14 +371,17 @@ class TenantIdDescription(Model): _attribute_map = { 'id': {'key': 'id', 'type': 'str'}, 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'tenant_category': {'key': 'tenantCategory', 'type': 'TenantCategory'}, + 'tenant_category': {'key': 'tenantCategory', 'type': 'str'}, 'country': {'key': 'country', 'type': 'str'}, 'country_code': {'key': 'countryCode', 'type': 'str'}, 'display_name': {'key': 'displayName', 'type': 'str'}, 'domains': {'key': 'domains', 'type': '[str]'}, } - def __init__(self, **kwargs) -> None: + def __init__( + self, + **kwargs + ): super(TenantIdDescription, self).__init__(**kwargs) self.id = None self.tenant_id = None @@ -299,3 +390,35 @@ def __init__(self, **kwargs) -> None: self.country_code = None self.display_name = None self.domains = None + + +class TenantListResult(msrest.serialization.Model): + """Tenant Ids information. + + 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 + """ + + _validation = { + 'next_link': {'required': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[TenantIdDescription]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + next_link: str, + value: Optional[List["TenantIdDescription"]] = None, + **kwargs + ): + 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/_paged_models.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/models/_paged_models.py deleted file mode 100644 index ec499fadcf5b..000000000000 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/models/_paged_models.py +++ /dev/null @@ -1,66 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.paging import Paged - - -class OperationPaged(Paged): - """ - A paging container for iterating over a list of :class:`Operation ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[Operation]'} - } - - def __init__(self, *args, **kwargs): - - super(OperationPaged, self).__init__(*args, **kwargs) -class LocationPaged(Paged): - """ - A paging container for iterating over a list of :class:`Location ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[Location]'} - } - - def __init__(self, *args, **kwargs): - - super(LocationPaged, self).__init__(*args, **kwargs) -class SubscriptionPaged(Paged): - """ - A paging container for iterating over a list of :class:`Subscription ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[Subscription]'} - } - - def __init__(self, *args, **kwargs): - - super(SubscriptionPaged, self).__init__(*args, **kwargs) -class TenantIdDescriptionPaged(Paged): - """ - A paging container for iterating over a list of :class:`TenantIdDescription ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[TenantIdDescription]'} - } - - def __init__(self, *args, **kwargs): - - super(TenantIdDescriptionPaged, self).__init__(*args, **kwargs) 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 7def5956d33d..0bc0d2215c9b 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 @@ -1,18 +1,24 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from enum import Enum +class SpendingLimit(str, Enum): + """The subscription spending limit. + """ + + on = "On" + off = "Off" + current_period_off = "CurrentPeriodOff" class SubscriptionState(str, Enum): + """The subscription state. Possible values are Enabled, Warned, PastDue, Disabled, and Deleted. + """ enabled = "Enabled" warned = "Warned" @@ -20,15 +26,9 @@ class SubscriptionState(str, Enum): disabled = "Disabled" deleted = "Deleted" - -class SpendingLimit(str, Enum): - - on = "On" - off = "Off" - current_period_off = "CurrentPeriodOff" - - class TenantCategory(str, Enum): + """The tenant category. + """ home = "Home" projected_by = "ProjectedBy" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/operations/__init__.py index 5b07794f3097..5ba2b6faf288 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/operations/__init__.py @@ -1,12 +1,9 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from ._operations import Operations 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 fc49ec262c81..92e450ee0eea 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 @@ -1,102 +1,106 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class Operations(object): """Operations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.subscriptions.v2019_06_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for the operation. Constant value: "2019-06-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-06-01" - - self.config = config + self._config = config def list( - self, custom_headers=None, raw=False, **operation_config): + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.OperationListResult"] """Lists all of the available Microsoft.Resources REST API operations. - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of Operation - :rtype: - ~azure.mgmt.resource.subscriptions.v2019_06_01.models.OperationPaged[~azure.mgmt.resource.subscriptions.v2019_06_01.models.Operation] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of OperationListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['url'] - + url = self.list.metadata['url'] # type: ignore # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('OperationListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.OperationPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list.metadata = {'url': '/providers/Microsoft.Resources/operations'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.Resources/operations'} # 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 ec4240c5b85d..da356790f09a 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 @@ -1,232 +1,227 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class SubscriptionsOperations(object): """SubscriptionsOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.subscriptions.v2019_06_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for the operation. Constant value: "2019-06-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-06-01" - - self.config = config + self._config = config def list_locations( - self, subscription_id, custom_headers=None, raw=False, **operation_config): - """Gets all available geo-locations. + self, + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.LocationListResult"] + """This operation provides all the locations that are available for resource providers; however, each resource provider may support a subset of this list. - This operation provides all the locations that are available for - resource providers; however, each resource provider may support a - subset of this list. + Gets all available geo-locations. :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of Location - :rtype: - ~azure.mgmt.resource.subscriptions.v2019_06_01.models.LocationPaged[~azure.mgmt.resource.subscriptions.v2019_06_01.models.Location] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of LocationListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_locations.metadata['url'] + url = self.list_locations.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str') + 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('LocationListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.LocationPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list_locations.metadata = {'url': '/subscriptions/{subscriptionId}/locations'} + return ItemPaged( + get_next, extract_data + ) + list_locations.metadata = {'url': '/subscriptions/{subscriptionId}/locations'} # type: ignore def get( - self, subscription_id, custom_headers=None, raw=False, **operation_config): + self, + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.Subscription" """Gets details about a specified subscription. :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: Subscription or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.subscriptions.v2019_06_01.models.Subscription or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Subscription or the result of cls(response) + :rtype: ~azure.mgmt.resource.subscriptions.v2019_06_01.models.Subscription + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Subscription"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + # Construct URL - url = self.get.metadata['url'] + url = self.get.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str') + 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('Subscription', response) + deserialized = self._deserialize('Subscription', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}'} # type: ignore def list( - self, custom_headers=None, raw=False, **operation_config): + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.SubscriptionListResult"] """Gets all subscriptions for a tenant. - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of Subscription - :rtype: - ~azure.mgmt.resource.subscriptions.v2019_06_01.models.SubscriptionPaged[~azure.mgmt.resource.subscriptions.v2019_06_01.models.Subscription] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['url'] - + url = self.list.metadata['url'] # type: ignore # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('SubscriptionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.SubscriptionPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list.metadata = {'url': '/subscriptions'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions'} # type: ignore 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 feb6b028e57a..6cd540e8ff7f 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 @@ -1,102 +1,106 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class TenantsOperations(object): """TenantsOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.subscriptions.v2019_06_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for the operation. Constant value: "2019-06-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-06-01" - - self.config = config + self._config = config def list( - self, custom_headers=None, raw=False, **operation_config): + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.TenantListResult"] """Gets the tenants for your account. - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of TenantIdDescription - :rtype: - ~azure.mgmt.resource.subscriptions.v2019_06_01.models.TenantIdDescriptionPaged[~azure.mgmt.resource.subscriptions.v2019_06_01.models.TenantIdDescription] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of TenantListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-06-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['url'] - + url = self.list.metadata['url'] # type: ignore # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('TenantListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.TenantIdDescriptionPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list.metadata = {'url': '/tenants'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/tenants'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/py.typed b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file 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 deleted file mode 100644 index 4174449873ab..000000000000 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_06_01/version.py +++ /dev/null @@ -1,13 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -VERSION = "2019-06-01" - 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 399e93fb102f..b07b0882922e 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 @@ -1,19 +1,16 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._configuration import SubscriptionClientConfiguration from ._subscription_client import SubscriptionClient -__all__ = ['SubscriptionClient', 'SubscriptionClientConfiguration'] - -from .version import VERSION - -__version__ = VERSION +__all__ = ['SubscriptionClient'] +try: + from ._patch import patch_sdk + patch_sdk() +except ImportError: + pass 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 935bf662873f..a7be5d9af264 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 @@ -1,43 +1,63 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrestazure import AzureConfiguration -from .version import VERSION +from typing import TYPE_CHECKING +from azure.core.configuration import Configuration +from azure.core.pipeline import policies -class SubscriptionClientConfiguration(AzureConfiguration): - """Configuration for SubscriptionClient - Note that all parameters used to create this instance are saved as instance - attributes. +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` - :param str base_url: Service URL - """ - - def __init__( - self, credentials, base_url=None): + from azure.core.credentials import TokenCredential - if credentials is None: - raise ValueError("Parameter 'credentials' must not be None.") - if not base_url: - base_url = 'https://management.azure.com' +VERSION = "unknown" - super(SubscriptionClientConfiguration, self).__init__(base_url) +class SubscriptionClientConfiguration(Configuration): + """Configuration for SubscriptionClient. - # Starting Autorest.Python 4.0.64, make connection pool activated by default - self.keep_alive = True + Note that all parameters used to create this instance are saved as instance + attributes. - self.add_user_agent('azure-mgmt-resource/{}'.format(VERSION)) - self.add_user_agent('Azure-SDK-For-Python') + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + """ - self.credentials = credentials + def __init__( + self, + credential, # type: "TokenCredential" + **kwargs # type: Any + ): + # type: (...) -> None + 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" + self.credential_scopes = ['https://management.azure.com/.default'] + self.credential_scopes.extend(kwargs.pop('credential_scopes', [])) + kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + 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) 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 new file mode 100644 index 000000000000..4fbc9a86fb64 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/_metadata.json @@ -0,0 +1,43 @@ +{ + "chosen_version": "2019-11-01", + "total_api_version_list": ["2019-11-01"], + "client": { + "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." + }, + "global_parameters": { + "sync_method": { + "credential": { + "method_signature": "credential, # type: \"TokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials.TokenCredential", + "required": true + } + }, + "async_method": { + "credential": { + "method_signature": "credential, # type: \"AsyncTokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + } + }, + "constant": { + }, + "call": "credential" + }, + "config": { + "credential": true, + "credential_scopes": ["https://management.azure.com/.default"] + }, + "operation_groups": { + "operations": "Operations", + "subscriptions": "SubscriptionsOperations", + "tenants": "TenantsOperations" + }, + "operation_mixins": { + }, + "sync_imports": "None", + "async_imports": "None" +} \ 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 7b2d8ff052cc..a86d3aa10e1c 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 @@ -1,16 +1,19 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.service_client import SDKClient -from msrest import Serializer, Deserializer +from typing import TYPE_CHECKING + +from azure.mgmt.core import ARMPipelineClient +from msrest import Deserializer, Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional from ._configuration import SubscriptionClientConfiguration from .operations import Operations @@ -19,39 +22,53 @@ from . import models -class SubscriptionClient(SDKClient): +class SubscriptionClient(object): """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 config: Configuration for client. - :vartype config: SubscriptionClientConfiguration - :ivar operations: Operations operations :vartype operations: azure.mgmt.resource.subscriptions.v2019_11_01.operations.Operations - :ivar subscriptions: Subscriptions operations + :ivar subscriptions: SubscriptionsOperations operations :vartype subscriptions: azure.mgmt.resource.subscriptions.v2019_11_01.operations.SubscriptionsOperations - :ivar tenants: Tenants operations + :ivar tenants: TenantsOperations operations :vartype tenants: azure.mgmt.resource.subscriptions.v2019_11_01.operations.TenantsOperations - - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential :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. """ def __init__( - self, credentials, base_url=None): - - self.config = SubscriptionClientConfiguration(credentials, base_url) - super(SubscriptionClient, self).__init__(self.config.credentials, self.config) + self, + credential, # type: "TokenCredential" + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + 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) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - self.api_version = '2019-11-01' self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self.operations = Operations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.subscriptions = SubscriptionsOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.tenants = TenantsOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> SubscriptionClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) 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 new file mode 100644 index 000000000000..345034cd2938 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/aio/__init__.py @@ -0,0 +1,10 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._subscription_client_async import SubscriptionClient +__all__ = ['SubscriptionClient'] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/aio/_configuration_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/aio/_configuration_async.py new file mode 100644 index 000000000000..afd5dc4a4a9a --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/aio/_configuration_async.py @@ -0,0 +1,59 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + +VERSION = "unknown" + +class SubscriptionClientConfiguration(Configuration): + """Configuration for SubscriptionClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + **kwargs: Any + ) -> None: + 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" + self.credential_scopes = ['https://management.azure.com/.default'] + self.credential_scopes.extend(kwargs.pop('credential_scopes', [])) + kwargs.setdefault('sdk_moniker', 'mgmt-resource/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs: Any + ) -> None: + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + 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) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/aio/_subscription_client_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/aio/_subscription_client_async.py new file mode 100644 index 000000000000..f8a8146dd9f9 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/aio/_subscription_client_async.py @@ -0,0 +1,66 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, Optional + +from azure.mgmt.core import AsyncARMPipelineClient +from msrest import Deserializer, Serializer + +from ._configuration_async import SubscriptionClientConfiguration +from .operations_async import Operations +from .operations_async import SubscriptionsOperations +from .operations_async import TenantsOperations +from .. import models + + +class SubscriptionClient(object): + """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_async.Operations + :ivar subscriptions: SubscriptionsOperations operations + :vartype subscriptions: azure.mgmt.resource.subscriptions.v2019_11_01.aio.operations_async.SubscriptionsOperations + :ivar tenants: TenantsOperations operations + :vartype tenants: azure.mgmt.resource.subscriptions.v2019_11_01.aio.operations_async.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 + :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", + base_url: Optional[str] = None, + **kwargs: 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) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + + self.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 close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "SubscriptionClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/aio/operations_async/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/aio/operations_async/__init__.py new file mode 100644 index 000000000000..05cc20fe3ece --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/aio/operations_async/__init__.py @@ -0,0 +1,17 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._operations_async import Operations +from ._subscriptions_operations_async import SubscriptionsOperations +from ._tenants_operations_async import TenantsOperations + +__all__ = [ + 'Operations', + 'SubscriptionsOperations', + 'TenantsOperations', +] diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/aio/operations_async/_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/aio/operations_async/_operations_async.py new file mode 100644 index 000000000000..87953e721831 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/aio/operations_async/_operations_async.py @@ -0,0 +1,101 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import 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 ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class Operations: + """Operations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.subscriptions.v2019_11_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + **kwargs + ) -> AsyncIterable["models.OperationListResult"]: + """Lists all of the available Microsoft.Resources REST API operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of OperationListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-11-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('OperationListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.Resources/operations'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/aio/operations_async/_subscriptions_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/aio/operations_async/_subscriptions_operations_async.py new file mode 100644 index 000000000000..332bafc989be --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/aio/operations_async/_subscriptions_operations_async.py @@ -0,0 +1,220 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import 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 ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class SubscriptionsOperations: + """SubscriptionsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.subscriptions.v2019_11_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list_locations( + self, + subscription_id: str, + **kwargs + ) -> AsyncIterable["models.LocationListResult"]: + """This operation provides all the locations that are available for resource providers; however, each resource provider may support a subset of this list. + + Gets all available geo-locations. + + :param subscription_id: The ID of the target subscription. + :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 LocationListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-11-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('LocationListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_locations.metadata = {'url': '/subscriptions/{subscriptionId}/locations'} # type: ignore + + async def get( + self, + subscription_id: str, + **kwargs + ) -> "models.Subscription": + """Gets details about a specified subscription. + + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Subscription or the result of cls(response) + :rtype: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.Subscription + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Subscription"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-11-01" + + # 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'] = 'application/json' + + # Construct and send request + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Subscription', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}'} # type: ignore + + def list( + self, + **kwargs + ) -> AsyncIterable["models.SubscriptionListResult"]: + """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 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-11-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('SubscriptionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/aio/operations_async/_tenants_operations_async.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/aio/operations_async/_tenants_operations_async.py new file mode 100644 index 000000000000..30631d508e07 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/aio/operations_async/_tenants_operations_async.py @@ -0,0 +1,101 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import 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 ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class TenantsOperations: + """TenantsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.subscriptions.v2019_11_01.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + **kwargs + ) -> AsyncIterable["models.TenantListResult"]: + """Gets the tenants for your account. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of TenantListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-11-01" + + def prepare_request(next_link=None): + 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') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('TenantListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/tenants'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/models/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/models/__init__.py index ccb68724c045..0880e6f4cf8f 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/models/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/models/__init__.py @@ -1,63 +1,65 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- try: from ._models_py3 import Location + from ._models_py3 import LocationListResult from ._models_py3 import LocationMetadata from ._models_py3 import ManagedByTenant from ._models_py3 import Operation from ._models_py3 import OperationDisplay + from ._models_py3 import OperationListResult from ._models_py3 import PairedRegion from ._models_py3 import Subscription + from ._models_py3 import SubscriptionListResult from ._models_py3 import SubscriptionPolicies from ._models_py3 import TenantIdDescription + from ._models_py3 import TenantListResult except (SyntaxError, ImportError): - from ._models import Location - from ._models import LocationMetadata - from ._models import ManagedByTenant - from ._models import Operation - from ._models import OperationDisplay - from ._models import PairedRegion - from ._models import Subscription - from ._models import SubscriptionPolicies - from ._models import TenantIdDescription -from ._paged_models import LocationPaged -from ._paged_models import OperationPaged -from ._paged_models import SubscriptionPaged -from ._paged_models import TenantIdDescriptionPaged + from ._models import Location # type: ignore + from ._models import LocationListResult # type: ignore + from ._models import LocationMetadata # type: ignore + from ._models import ManagedByTenant # type: ignore + from ._models import Operation # type: ignore + from ._models import OperationDisplay # type: ignore + from ._models import OperationListResult # type: ignore + from ._models import PairedRegion # type: ignore + from ._models import Subscription # type: ignore + from ._models import SubscriptionListResult # type: ignore + from ._models import SubscriptionPolicies # type: ignore + from ._models import TenantIdDescription # type: ignore + from ._models import TenantListResult # type: ignore + from ._subscription_client_enums import ( - RegionType, RegionCategory, - SubscriptionState, + RegionType, SpendingLimit, + SubscriptionState, TenantCategory, ) __all__ = [ 'Location', + 'LocationListResult', 'LocationMetadata', 'ManagedByTenant', 'Operation', 'OperationDisplay', + 'OperationListResult', 'PairedRegion', 'Subscription', + 'SubscriptionListResult', 'SubscriptionPolicies', 'TenantIdDescription', - 'OperationPaged', - 'LocationPaged', - 'SubscriptionPaged', - 'TenantIdDescriptionPaged', - 'RegionType', + 'TenantListResult', 'RegionCategory', - 'SubscriptionState', + 'RegionType', 'SpendingLimit', + 'SubscriptionState', 'TenantCategory', ] 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 ce8cef294927..b0f74f8caa5d 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 @@ -1,30 +1,18 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.serialization import Model +import msrest.serialization -class CloudError(Model): - """CloudError. - """ - - _attribute_map = { - } - - -class Location(Model): +class Location(msrest.serialization.Model): """Location information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The fully qualified ID of the location. For example, /subscriptions/00000000-0000-0000-0000-000000000000/locations/westus. @@ -35,13 +23,10 @@ class Location(Model): :vartype name: str :ivar display_name: The display name of the location. :vartype display_name: str - :ivar regional_display_name: The display name of the location and its - region. + :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 + :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 """ _validation = { @@ -61,7 +46,10 @@ class Location(Model): 'metadata': {'key': 'metadata', 'type': 'LocationMetadata'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Location, self).__init__(**kwargs) self.id = None self.subscription_id = None @@ -71,18 +59,34 @@ def __init__(self, **kwargs): self.metadata = kwargs.get('metadata', None) -class LocationMetadata(Model): +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] + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Location]'}, + } + + def __init__( + self, + **kwargs + ): + super(LocationListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + + +class LocationMetadata(msrest.serialization.Model): """Location metadata information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar region_type: The type of the region. Possible values include: - 'Physical', 'Logical' - :vartype region_type: str or - ~azure.mgmt.resource.subscriptions.v2019_11_01.models.RegionType - :ivar region_category: The category of the region. Possible values - include: 'Recommended', 'Other' + :ivar region_type: The type of the region. Possible values include: "Physical", "Logical". + :vartype region_type: str or ~azure.mgmt.resource.subscriptions.v2019_11_01.models.RegionType + :ivar region_category: The category of the region. Possible values include: "Recommended", + "Other". :vartype region_category: str or ~azure.mgmt.resource.subscriptions.v2019_11_01.models.RegionCategory :ivar geography_group: The geography group of the location. @@ -94,8 +98,7 @@ class LocationMetadata(Model): :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] + :type paired_region: list[~azure.mgmt.resource.subscriptions.v2019_11_01.models.PairedRegion] """ _validation = { @@ -117,7 +120,10 @@ class LocationMetadata(Model): 'paired_region': {'key': 'pairedRegion', 'type': '[PairedRegion]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(LocationMetadata, self).__init__(**kwargs) self.region_type = None self.region_category = None @@ -128,11 +134,10 @@ def __init__(self, **kwargs): self.paired_region = kwargs.get('paired_region', None) -class ManagedByTenant(Model): +class ManagedByTenant(msrest.serialization.Model): """Information about a tenant managing the subscription. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar tenant_id: The tenant ID of the managing tenant. This is a GUID. :vartype tenant_id: str @@ -146,19 +151,21 @@ class ManagedByTenant(Model): 'tenant_id': {'key': 'tenantId', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ManagedByTenant, self).__init__(**kwargs) self.tenant_id = None -class Operation(Model): +class Operation(msrest.serialization.Model): """Microsoft.Resources operation. - :param name: Operation name: {provider}/{resource}/{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 + :type display: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.OperationDisplay """ _attribute_map = { @@ -166,19 +173,21 @@ class Operation(Model): 'display': {'key': 'display', 'type': 'OperationDisplay'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Operation, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.display = kwargs.get('display', None) -class OperationDisplay(Model): +class OperationDisplay(msrest.serialization.Model): """The object that represents the operation. - :param provider: Service provider: Microsoft.Resources + :param provider: Service provider: Microsoft.Resources. :type provider: str - :param resource: Resource on which the operation is performed: Profile, - endpoint, etc. + :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 @@ -193,7 +202,10 @@ class OperationDisplay(Model): 'description': {'key': 'description', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(OperationDisplay, self).__init__(**kwargs) self.provider = kwargs.get('provider', None) self.resource = kwargs.get('resource', None) @@ -201,11 +213,33 @@ def __init__(self, **kwargs): self.description = kwargs.get('description', None) -class PairedRegion(Model): +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 + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Operation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(OperationListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class PairedRegion(msrest.serialization.Model): """Information regarding paired region. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar name: The name of the paired region. :vartype name: str @@ -228,18 +262,20 @@ class PairedRegion(Model): 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(PairedRegion, self).__init__(**kwargs) self.name = None self.id = None self.subscription_id = None -class Subscription(Model): +class Subscription(msrest.serialization.Model): """Subscription information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The fully qualified ID for the subscription. For example, /subscriptions/00000000-0000-0000-0000-000000000000. @@ -250,23 +286,20 @@ class Subscription(Model): :vartype display_name: str :ivar tenant_id: The subscription tenant ID. :vartype tenant_id: str - :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 + :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: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.SubscriptionPolicies - :param 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'. + :param 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. + :param managed_by_tenants: An array containing the tenants managing the subscription. :type managed_by_tenants: list[~azure.mgmt.resource.subscriptions.v2019_11_01.models.ManagedByTenant] - :param tags: The tags attached to the subscription. + :param tags: A set of tags. The tags attached to the subscription. :type tags: dict[str, str] """ @@ -283,14 +316,17 @@ class Subscription(Model): 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, 'display_name': {'key': 'displayName', 'type': 'str'}, 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'SubscriptionState'}, + 'state': {'key': 'state', 'type': 'str'}, 'subscription_policies': {'key': 'subscriptionPolicies', 'type': 'SubscriptionPolicies'}, 'authorization_source': {'key': 'authorizationSource', 'type': 'str'}, 'managed_by_tenants': {'key': 'managedByTenants', 'type': '[ManagedByTenant]'}, 'tags': {'key': 'tags', 'type': '{str}'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Subscription, self).__init__(**kwargs) self.id = None self.subscription_id = None @@ -303,21 +339,48 @@ def __init__(self, **kwargs): self.tags = kwargs.get('tags', None) -class SubscriptionPolicies(Model): +class SubscriptionListResult(msrest.serialization.Model): + """Subscription list operation response. + + 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 + """ + + _validation = { + 'next_link': {'required': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Subscription]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(SubscriptionListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs['next_link'] + + +class SubscriptionPolicies(msrest.serialization.Model): """Subscription policies. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar location_placement_id: The subscription location placement ID. The - ID indicates which regions are visible for a subscription. For example, a - subscription with a location placement Id of Public_2014-09-01 has access - to Azure public regions. + :ivar location_placement_id: The subscription location placement ID. The ID indicates which + regions are visible for a subscription. For example, a subscription with a location placement + Id of Public_2014-09-01 has access to Azure public regions. :vartype location_placement_id: str :ivar quota_id: The subscription quota ID. :vartype quota_id: str - :ivar spending_limit: The subscription spending limit. Possible values - include: 'On', 'Off', 'CurrentPeriodOff' + :ivar spending_limit: The subscription spending limit. Possible values include: "On", "Off", + "CurrentPeriodOff". :vartype spending_limit: str or ~azure.mgmt.resource.subscriptions.v2019_11_01.models.SpendingLimit """ @@ -331,30 +394,31 @@ class SubscriptionPolicies(Model): _attribute_map = { 'location_placement_id': {'key': 'locationPlacementId', 'type': 'str'}, 'quota_id': {'key': 'quotaId', 'type': 'str'}, - 'spending_limit': {'key': 'spendingLimit', 'type': 'SpendingLimit'}, + 'spending_limit': {'key': 'spendingLimit', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(SubscriptionPolicies, self).__init__(**kwargs) self.location_placement_id = None self.quota_id = None self.spending_limit = None -class TenantIdDescription(Model): +class TenantIdDescription(msrest.serialization.Model): """Tenant Id information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The fully qualified ID of the tenant. For example, /tenants/00000000-0000-0000-0000-000000000000. :vartype id: str - :ivar tenant_id: The tenant ID. For example, - 00000000-0000-0000-0000-000000000000. + :ivar tenant_id: The tenant ID. For example, 00000000-0000-0000-0000-000000000000. :vartype tenant_id: str - :ivar tenant_category: Category of the tenant. Possible values include: - 'Home', 'ProjectedBy', 'ManagedBy' + :ivar tenant_category: Category of the tenant. Possible values include: "Home", "ProjectedBy", + "ManagedBy". :vartype tenant_category: str or ~azure.mgmt.resource.subscriptions.v2019_11_01.models.TenantCategory :ivar country: Country/region name of the address for the tenant. @@ -380,14 +444,17 @@ class TenantIdDescription(Model): _attribute_map = { 'id': {'key': 'id', 'type': 'str'}, 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'tenant_category': {'key': 'tenantCategory', 'type': 'TenantCategory'}, + 'tenant_category': {'key': 'tenantCategory', 'type': 'str'}, 'country': {'key': 'country', 'type': 'str'}, 'country_code': {'key': 'countryCode', 'type': 'str'}, 'display_name': {'key': 'displayName', 'type': 'str'}, 'domains': {'key': 'domains', 'type': '[str]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(TenantIdDescription, self).__init__(**kwargs) self.id = None self.tenant_id = None @@ -396,3 +463,32 @@ def __init__(self, **kwargs): self.country_code = None self.display_name = None self.domains = None + + +class TenantListResult(msrest.serialization.Model): + """Tenant Ids information. + + 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 + """ + + _validation = { + 'next_link': {'required': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[TenantIdDescription]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + 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 b8c47711b3b9..6059c37ad69e 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 @@ -1,30 +1,20 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.serialization import Model +from typing import Dict, List, Optional - -class CloudError(Model): - """CloudError. - """ - - _attribute_map = { - } +import msrest.serialization -class Location(Model): +class Location(msrest.serialization.Model): """Location information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The fully qualified ID of the location. For example, /subscriptions/00000000-0000-0000-0000-000000000000/locations/westus. @@ -35,13 +25,10 @@ class Location(Model): :vartype name: str :ivar display_name: The display name of the location. :vartype display_name: str - :ivar regional_display_name: The display name of the location and its - region. + :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 + :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 """ _validation = { @@ -61,7 +48,12 @@ class Location(Model): 'metadata': {'key': 'metadata', 'type': 'LocationMetadata'}, } - def __init__(self, *, metadata=None, **kwargs) -> None: + def __init__( + self, + *, + metadata: Optional["LocationMetadata"] = None, + **kwargs + ): super(Location, self).__init__(**kwargs) self.id = None self.subscription_id = None @@ -71,18 +63,36 @@ def __init__(self, *, metadata=None, **kwargs) -> None: self.metadata = metadata -class LocationMetadata(Model): +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] + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Location]'}, + } + + def __init__( + self, + *, + value: Optional[List["Location"]] = None, + **kwargs + ): + super(LocationListResult, self).__init__(**kwargs) + self.value = value + + +class LocationMetadata(msrest.serialization.Model): """Location metadata information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar region_type: The type of the region. Possible values include: - 'Physical', 'Logical' - :vartype region_type: str or - ~azure.mgmt.resource.subscriptions.v2019_11_01.models.RegionType - :ivar region_category: The category of the region. Possible values - include: 'Recommended', 'Other' + :ivar region_type: The type of the region. Possible values include: "Physical", "Logical". + :vartype region_type: str or ~azure.mgmt.resource.subscriptions.v2019_11_01.models.RegionType + :ivar region_category: The category of the region. Possible values include: "Recommended", + "Other". :vartype region_category: str or ~azure.mgmt.resource.subscriptions.v2019_11_01.models.RegionCategory :ivar geography_group: The geography group of the location. @@ -94,8 +104,7 @@ class LocationMetadata(Model): :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] + :type paired_region: list[~azure.mgmt.resource.subscriptions.v2019_11_01.models.PairedRegion] """ _validation = { @@ -117,7 +126,12 @@ class LocationMetadata(Model): 'paired_region': {'key': 'pairedRegion', 'type': '[PairedRegion]'}, } - def __init__(self, *, paired_region=None, **kwargs) -> None: + def __init__( + self, + *, + paired_region: Optional[List["PairedRegion"]] = None, + **kwargs + ): super(LocationMetadata, self).__init__(**kwargs) self.region_type = None self.region_category = None @@ -128,11 +142,10 @@ def __init__(self, *, paired_region=None, **kwargs) -> None: self.paired_region = paired_region -class ManagedByTenant(Model): +class ManagedByTenant(msrest.serialization.Model): """Information about a tenant managing the subscription. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar tenant_id: The tenant ID of the managing tenant. This is a GUID. :vartype tenant_id: str @@ -146,19 +159,21 @@ class ManagedByTenant(Model): 'tenant_id': {'key': 'tenantId', 'type': 'str'}, } - def __init__(self, **kwargs) -> None: + def __init__( + self, + **kwargs + ): super(ManagedByTenant, self).__init__(**kwargs) self.tenant_id = None -class Operation(Model): +class Operation(msrest.serialization.Model): """Microsoft.Resources operation. - :param name: Operation name: {provider}/{resource}/{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 + :type display: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.OperationDisplay """ _attribute_map = { @@ -166,19 +181,24 @@ class Operation(Model): 'display': {'key': 'display', 'type': 'OperationDisplay'}, } - def __init__(self, *, name: str=None, display=None, **kwargs) -> None: + def __init__( + self, + *, + name: Optional[str] = None, + display: Optional["OperationDisplay"] = None, + **kwargs + ): super(Operation, self).__init__(**kwargs) self.name = name self.display = display -class OperationDisplay(Model): +class OperationDisplay(msrest.serialization.Model): """The object that represents the operation. - :param provider: Service provider: Microsoft.Resources + :param provider: Service provider: Microsoft.Resources. :type provider: str - :param resource: Resource on which the operation is performed: Profile, - endpoint, etc. + :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 @@ -193,7 +213,15 @@ class OperationDisplay(Model): 'description': {'key': 'description', 'type': 'str'}, } - def __init__(self, *, provider: str=None, resource: str=None, operation: str=None, description: str=None, **kwargs) -> None: + def __init__( + self, + *, + provider: Optional[str] = None, + resource: Optional[str] = None, + operation: Optional[str] = None, + description: Optional[str] = None, + **kwargs + ): super(OperationDisplay, self).__init__(**kwargs) self.provider = provider self.resource = resource @@ -201,11 +229,36 @@ def __init__(self, *, provider: str=None, resource: str=None, operation: str=Non self.description = description -class PairedRegion(Model): +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 + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Operation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["Operation"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(OperationListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class PairedRegion(msrest.serialization.Model): """Information regarding paired region. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar name: The name of the paired region. :vartype name: str @@ -228,18 +281,20 @@ class PairedRegion(Model): 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, } - def __init__(self, **kwargs) -> None: + def __init__( + self, + **kwargs + ): super(PairedRegion, self).__init__(**kwargs) self.name = None self.id = None self.subscription_id = None -class Subscription(Model): +class Subscription(msrest.serialization.Model): """Subscription information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The fully qualified ID for the subscription. For example, /subscriptions/00000000-0000-0000-0000-000000000000. @@ -250,23 +305,20 @@ class Subscription(Model): :vartype display_name: str :ivar tenant_id: The subscription tenant ID. :vartype tenant_id: str - :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 + :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: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.SubscriptionPolicies - :param 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'. + :param 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. + :param managed_by_tenants: An array containing the tenants managing the subscription. :type managed_by_tenants: list[~azure.mgmt.resource.subscriptions.v2019_11_01.models.ManagedByTenant] - :param tags: The tags attached to the subscription. + :param tags: A set of tags. The tags attached to the subscription. :type tags: dict[str, str] """ @@ -283,14 +335,22 @@ class Subscription(Model): 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, 'display_name': {'key': 'displayName', 'type': 'str'}, 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'SubscriptionState'}, + 'state': {'key': 'state', 'type': 'str'}, 'subscription_policies': {'key': 'subscriptionPolicies', 'type': 'SubscriptionPolicies'}, 'authorization_source': {'key': 'authorizationSource', 'type': 'str'}, 'managed_by_tenants': {'key': 'managedByTenants', 'type': '[ManagedByTenant]'}, 'tags': {'key': 'tags', 'type': '{str}'}, } - def __init__(self, *, subscription_policies=None, authorization_source: str=None, managed_by_tenants=None, tags=None, **kwargs) -> None: + def __init__( + self, + *, + subscription_policies: Optional["SubscriptionPolicies"] = None, + authorization_source: Optional[str] = None, + managed_by_tenants: Optional[List["ManagedByTenant"]] = None, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): super(Subscription, self).__init__(**kwargs) self.id = None self.subscription_id = None @@ -303,21 +363,51 @@ def __init__(self, *, subscription_policies=None, authorization_source: str=None self.tags = tags -class SubscriptionPolicies(Model): +class SubscriptionListResult(msrest.serialization.Model): + """Subscription list operation response. + + 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 + """ + + _validation = { + 'next_link': {'required': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Subscription]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + next_link: str, + value: Optional[List["Subscription"]] = None, + **kwargs + ): + super(SubscriptionListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class SubscriptionPolicies(msrest.serialization.Model): """Subscription policies. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar location_placement_id: The subscription location placement ID. The - ID indicates which regions are visible for a subscription. For example, a - subscription with a location placement Id of Public_2014-09-01 has access - to Azure public regions. + :ivar location_placement_id: The subscription location placement ID. The ID indicates which + regions are visible for a subscription. For example, a subscription with a location placement + Id of Public_2014-09-01 has access to Azure public regions. :vartype location_placement_id: str :ivar quota_id: The subscription quota ID. :vartype quota_id: str - :ivar spending_limit: The subscription spending limit. Possible values - include: 'On', 'Off', 'CurrentPeriodOff' + :ivar spending_limit: The subscription spending limit. Possible values include: "On", "Off", + "CurrentPeriodOff". :vartype spending_limit: str or ~azure.mgmt.resource.subscriptions.v2019_11_01.models.SpendingLimit """ @@ -331,30 +421,31 @@ class SubscriptionPolicies(Model): _attribute_map = { 'location_placement_id': {'key': 'locationPlacementId', 'type': 'str'}, 'quota_id': {'key': 'quotaId', 'type': 'str'}, - 'spending_limit': {'key': 'spendingLimit', 'type': 'SpendingLimit'}, + 'spending_limit': {'key': 'spendingLimit', 'type': 'str'}, } - def __init__(self, **kwargs) -> None: + def __init__( + self, + **kwargs + ): super(SubscriptionPolicies, self).__init__(**kwargs) self.location_placement_id = None self.quota_id = None self.spending_limit = None -class TenantIdDescription(Model): +class TenantIdDescription(msrest.serialization.Model): """Tenant Id information. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The fully qualified ID of the tenant. For example, /tenants/00000000-0000-0000-0000-000000000000. :vartype id: str - :ivar tenant_id: The tenant ID. For example, - 00000000-0000-0000-0000-000000000000. + :ivar tenant_id: The tenant ID. For example, 00000000-0000-0000-0000-000000000000. :vartype tenant_id: str - :ivar tenant_category: Category of the tenant. Possible values include: - 'Home', 'ProjectedBy', 'ManagedBy' + :ivar tenant_category: Category of the tenant. Possible values include: "Home", "ProjectedBy", + "ManagedBy". :vartype tenant_category: str or ~azure.mgmt.resource.subscriptions.v2019_11_01.models.TenantCategory :ivar country: Country/region name of the address for the tenant. @@ -380,14 +471,17 @@ class TenantIdDescription(Model): _attribute_map = { 'id': {'key': 'id', 'type': 'str'}, 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'tenant_category': {'key': 'tenantCategory', 'type': 'TenantCategory'}, + 'tenant_category': {'key': 'tenantCategory', 'type': 'str'}, 'country': {'key': 'country', 'type': 'str'}, 'country_code': {'key': 'countryCode', 'type': 'str'}, 'display_name': {'key': 'displayName', 'type': 'str'}, 'domains': {'key': 'domains', 'type': '[str]'}, } - def __init__(self, **kwargs) -> None: + def __init__( + self, + **kwargs + ): super(TenantIdDescription, self).__init__(**kwargs) self.id = None self.tenant_id = None @@ -396,3 +490,35 @@ def __init__(self, **kwargs) -> None: self.country_code = None self.display_name = None self.domains = None + + +class TenantListResult(msrest.serialization.Model): + """Tenant Ids information. + + 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 + """ + + _validation = { + 'next_link': {'required': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[TenantIdDescription]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + next_link: str, + value: Optional[List["TenantIdDescription"]] = None, + **kwargs + ): + 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/_paged_models.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/models/_paged_models.py deleted file mode 100644 index b46b75589169..000000000000 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/models/_paged_models.py +++ /dev/null @@ -1,66 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.paging import Paged - - -class OperationPaged(Paged): - """ - A paging container for iterating over a list of :class:`Operation ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[Operation]'} - } - - def __init__(self, *args, **kwargs): - - super(OperationPaged, self).__init__(*args, **kwargs) -class LocationPaged(Paged): - """ - A paging container for iterating over a list of :class:`Location ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[Location]'} - } - - def __init__(self, *args, **kwargs): - - super(LocationPaged, self).__init__(*args, **kwargs) -class SubscriptionPaged(Paged): - """ - A paging container for iterating over a list of :class:`Subscription ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[Subscription]'} - } - - def __init__(self, *args, **kwargs): - - super(SubscriptionPaged, self).__init__(*args, **kwargs) -class TenantIdDescriptionPaged(Paged): - """ - A paging container for iterating over a list of :class:`TenantIdDescription ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[TenantIdDescription]'} - } - - def __init__(self, *args, **kwargs): - - super(TenantIdDescriptionPaged, self).__init__(*args, **kwargs) 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 3fee1db7fd51..bdac328047d3 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 @@ -1,30 +1,38 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from enum import Enum +class RegionCategory(str, Enum): + """The category of the region. + """ + + recommended = "Recommended" + other = "Other" class RegionType(str, Enum): + """The type of the region. + """ physical = "Physical" logical = "Logical" +class SpendingLimit(str, Enum): + """The subscription spending limit. + """ -class RegionCategory(str, Enum): - - recommended = "Recommended" - other = "Other" - + on = "On" + off = "Off" + current_period_off = "CurrentPeriodOff" class SubscriptionState(str, Enum): + """The subscription state. Possible values are Enabled, Warned, PastDue, Disabled, and Deleted. + """ enabled = "Enabled" warned = "Warned" @@ -32,15 +40,9 @@ class SubscriptionState(str, Enum): disabled = "Disabled" deleted = "Deleted" - -class SpendingLimit(str, Enum): - - on = "On" - off = "Off" - current_period_off = "CurrentPeriodOff" - - class TenantCategory(str, Enum): + """Category of the tenant. + """ home = "Home" projected_by = "ProjectedBy" diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/operations/__init__.py b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/operations/__init__.py index 5b07794f3097..5ba2b6faf288 100644 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/operations/__init__.py +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/operations/__init__.py @@ -1,12 +1,9 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from ._operations import Operations 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 cd646a42e97f..bc4d3bcc191d 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 @@ -1,102 +1,106 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class Operations(object): """Operations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.subscriptions.v2019_11_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for the operation. Constant value: "2019-11-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-11-01" - - self.config = config + self._config = config def list( - self, custom_headers=None, raw=False, **operation_config): + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.OperationListResult"] """Lists all of the available Microsoft.Resources REST API operations. - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of Operation - :rtype: - ~azure.mgmt.resource.subscriptions.v2019_11_01.models.OperationPaged[~azure.mgmt.resource.subscriptions.v2019_11_01.models.Operation] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of OperationListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-11-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['url'] - + url = self.list.metadata['url'] # type: ignore # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('OperationListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.OperationPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list.metadata = {'url': '/providers/Microsoft.Resources/operations'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.Resources/operations'} # 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 f89095a02e4d..88776f31b5a9 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 @@ -1,232 +1,227 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class SubscriptionsOperations(object): """SubscriptionsOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.subscriptions.v2019_11_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for the operation. Constant value: "2019-11-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-11-01" - - self.config = config + self._config = config def list_locations( - self, subscription_id, custom_headers=None, raw=False, **operation_config): - """Gets all available geo-locations. + self, + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.LocationListResult"] + """This operation provides all the locations that are available for resource providers; however, each resource provider may support a subset of this list. - This operation provides all the locations that are available for - resource providers; however, each resource provider may support a - subset of this list. + Gets all available geo-locations. :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of Location - :rtype: - ~azure.mgmt.resource.subscriptions.v2019_11_01.models.LocationPaged[~azure.mgmt.resource.subscriptions.v2019_11_01.models.Location] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of LocationListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-11-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list_locations.metadata['url'] + url = self.list_locations.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str') + 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('LocationListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.LocationPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list_locations.metadata = {'url': '/subscriptions/{subscriptionId}/locations'} + return ItemPaged( + get_next, extract_data + ) + list_locations.metadata = {'url': '/subscriptions/{subscriptionId}/locations'} # type: ignore def get( - self, subscription_id, custom_headers=None, raw=False, **operation_config): + self, + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.Subscription" """Gets details about a specified subscription. :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: Subscription or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.resource.subscriptions.v2019_11_01.models.Subscription or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Subscription or the result of cls(response) + :rtype: ~azure.mgmt.resource.subscriptions.v2019_11_01.models.Subscription + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Subscription"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-11-01" + # Construct URL - url = self.get.metadata['url'] + url = self.get.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str') + 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('Subscription', response) + deserialized = self._deserialize('Subscription', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}'} # type: ignore def list( - self, custom_headers=None, raw=False, **operation_config): + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.SubscriptionListResult"] """Gets all subscriptions for a tenant. - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of Subscription - :rtype: - ~azure.mgmt.resource.subscriptions.v2019_11_01.models.SubscriptionPaged[~azure.mgmt.resource.subscriptions.v2019_11_01.models.Subscription] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of 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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-11-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['url'] - + url = self.list.metadata['url'] # type: ignore # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('SubscriptionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.SubscriptionPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list.metadata = {'url': '/subscriptions'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions'} # type: ignore 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 4da6dc3f13b9..ae9832c95a3c 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 @@ -1,102 +1,106 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, 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 from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class TenantsOperations(object): """TenantsOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.resource.subscriptions.v2019_11_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: The API version to use for the operation. Constant value: "2019-11-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-11-01" - - self.config = config + self._config = config def list( - self, custom_headers=None, raw=False, **operation_config): + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.TenantListResult"] """Gets the tenants for your account. - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of TenantIdDescription - :rtype: - ~azure.mgmt.resource.subscriptions.v2019_11_01.models.TenantIdDescriptionPaged[~azure.mgmt.resource.subscriptions.v2019_11_01.models.TenantIdDescription] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of TenantListResult or the result of cls(response) + :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"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-11-01" + def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['url'] - + url = self.list.metadata['url'] # type: ignore # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link - query_parameters = {} - + query_parameters = {} # type: Dict[str, Any] # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('TenantListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.TenantIdDescriptionPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list.metadata = {'url': '/tenants'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/tenants'} # type: ignore diff --git a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/py.typed b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file 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 deleted file mode 100644 index 93d376dfdcc7..000000000000 --- a/sdk/resources/azure-mgmt-resource/azure/mgmt/resource/subscriptions/v2019_11_01/version.py +++ /dev/null @@ -1,13 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -VERSION = "2019-11-01" -